Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing jiffy:encode #4420

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/event_pusher/mod_event_pusher_push_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ decode_row({NodeID, PubSubBin, FormJSON}) ->
NodeID,
decode_form(FormJSON)}.

-spec encode_form(mod_event_pusher_push:form()) -> iodata().
encode_form(Form) ->
jiffy:encode(Form).

Expand Down
4 changes: 2 additions & 2 deletions src/event_pusher/mod_event_pusher_rabbit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
-spec presence_msg(JID :: jid:jid(), Status :: atom()) -> binary().
presence_msg(JID, Status) ->
Msg = #{user_id => jid:to_binary(jid:to_lower(JID)), present => is_user_online(Status)},
jiffy:encode(Msg).
iolist_to_binary(jiffy:encode(Msg)).

Check warning on line 181 in src/event_pusher/mod_event_pusher_rabbit.erl

View check run for this annotation

Codecov / codecov/patch

src/event_pusher/mod_event_pusher_rabbit.erl#L181

Added line #L181 was not covered by tests

-spec chat_msg(From :: jid:jid(), To :: jid:jid(), UserMsg :: binary()) ->
binary().
chat_msg(From, To, UserMsg) ->
Msg = #{to_user_id => jid:to_binary(jid:to_lower(To)),
message => UserMsg,
from_user_id => jid:to_binary(jid:to_lower(From))},
jiffy:encode(Msg).
iolist_to_binary(jiffy:encode(Msg)).

Check warning on line 189 in src/event_pusher/mod_event_pusher_rabbit.erl

View check run for this annotation

Codecov / codecov/patch

src/event_pusher/mod_event_pusher_rabbit.erl#L189

Added line #L189 was not covered by tests

-spec is_user_online(online | offline) -> boolean().
is_user_online(online) -> true;
Expand Down
4 changes: 2 additions & 2 deletions src/mongoose_client_api/mongoose_client_api_sse.erl
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ terminate(_Reason, _Req, _State) ->
ok.

maybe_send_message_event(<<"chat">>, Packet, Timestamp, #{id := ID} = State) ->
Data = jiffy:encode(mongoose_client_api_messages:encode(Packet, Timestamp)),
Data = iolist_to_binary(jiffy:encode(mongoose_client_api_messages:encode(Packet, Timestamp))),
Event = #{id => integer_to_binary(ID), event => <<"message">>, data => Data},
{send, Event, State#{id := ID + 1}};
maybe_send_message_event(<<"groupchat">>, Packet, Timestamp, #{id := ID} = State) ->
Data = jiffy:encode(mongoose_client_api_rooms_messages:encode(Packet, Timestamp)),
Data = iolist_to_binary(jiffy:encode(mongoose_client_api_rooms_messages:encode(Packet, Timestamp))),
Event = #{id => integer_to_binary(ID), event => <<"room.message">>, data => Data},
{send, Event, State#{id := ID + 1}};
maybe_send_message_event(_, _, _, State) ->
Expand Down
4 changes: 2 additions & 2 deletions src/muc/mod_muc_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ store_nick_transaction(HostType, MucHost, Jid, Nick, true) ->
Error -> Error
end.

-spec store_room_transaction(mongooseim:host_type(), muc_host(), jid:luser(), binary(), term()) -> ok.
-spec store_room_transaction(mongooseim:host_type(), muc_host(), jid:luser(), iodata(), term()) -> ok.
store_room_transaction(HostType, MucHost, RoomName, ExtOpts, Affs) ->
execute_insert_room(HostType, MucHost, RoomName, ExtOpts),
Result = execute_select_room_id(HostType, MucHost, RoomName),
Expand Down Expand Up @@ -249,7 +249,7 @@ forget_room_transaction(HostType, MucHost, RoomName) ->

%% Execute call functions

-spec execute_insert_room(mongooseim:host_type(), muc_host(), jid:luser(), binary()) -> ok.
-spec execute_insert_room(mongooseim:host_type(), muc_host(), jid:luser(), iodata()) -> ok.
execute_insert_room(HostType, MucHost, RoomName, ExtOpts) ->
Args = [MucHost, RoomName, ExtOpts],
execute_successfully(HostType, muc_insert_room, Args),
Expand Down
4 changes: 2 additions & 2 deletions src/rdbms/mongoose_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@
-type rdbms_msg() :: {sql_query, _}
| {sql_transaction, fun()}
| {sql_dirty, fun()}
| {sql_execute, atom(), [binary() | boolean() | integer()]}
| {sql_execute_wrapped, atom(), [binary() | boolean() | integer()], request_wrapper()}.
| {sql_execute, atom(), [iodata() | boolean() | integer()]}
| {sql_execute_wrapped, atom(), [iodata() | boolean() | integer()], request_wrapper()}.
-type single_query_result() :: {selected, [tuple()]} |
{updated, non_neg_integer() | undefined} |
{updated, non_neg_integer(), [tuple()]} |
Expand Down