Skip to content

Commit

Permalink
Merge pull request #4420 from esl/jiffy_encode_fix
Browse files Browse the repository at this point in the history
Fixing jiffy:encode
  • Loading branch information
arcusfelis authored Dec 11, 2024
2 parents df8f801 + d603ba0 commit 3b5713a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
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 @@ user_topic_routing_key(JID, Topic) ->
-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)).

-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)).

-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

0 comments on commit 3b5713a

Please sign in to comment.