From d0a1572807ea9a71ff611c16b2c12bf0aa0651e5 Mon Sep 17 00:00:00 2001 From: Janusz Jakubiec Date: Fri, 6 Dec 2024 09:36:23 +0100 Subject: [PATCH 1/2] Changing jiffy:encode to [jiffy:encode] everywhere in the code to check where returning io_list except of binary causes problems --- src/ejabberd_ctl.erl | 3 ++- src/event_pusher/mod_event_pusher_push_rdbms.erl | 3 ++- src/event_pusher/mod_event_pusher_rabbit.erl | 4 ++-- src/graphql/mongoose_graphql_handler.erl | 3 ++- src/graphql/mongoose_graphql_sse_handler.erl | 3 ++- src/mod_caps_rdbms.erl | 3 ++- src/mod_push_service_mongoosepush.erl | 3 ++- src/mongoose_admin_api/mongoose_admin_api.erl | 6 ++++-- .../mongoose_admin_api_contacts.erl | 3 ++- .../mongoose_admin_api_domain.erl | 3 ++- .../mongoose_admin_api_messages.erl | 3 ++- .../mongoose_admin_api_metrics.erl | 12 ++++++++---- .../mongoose_admin_api_sessions.erl | 3 ++- .../mongoose_admin_api_users.erl | 3 ++- src/mongoose_client_api/mongoose_client_api.erl | 3 ++- .../mongoose_client_api_contacts.erl | 6 ++++-- .../mongoose_client_api_messages.erl | 6 ++++-- .../mongoose_client_api_rooms.erl | 9 ++++++--- .../mongoose_client_api_rooms_messages.erl | 6 ++++-- .../mongoose_client_api_sse.erl | 4 ++-- src/muc/mod_muc_rdbms.erl | 3 ++- src/pubsub/mod_pubsub_db_rdbms.erl | 15 ++++++++++----- .../mongoose_system_metrics_file.erl | 3 ++- .../mongoose_system_metrics_sender.erl | 3 ++- 24 files changed, 74 insertions(+), 39 deletions(-) diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 80ebf418f39..26e470cd8e5 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -188,7 +188,8 @@ handle_graphql_result({ok, Result}) -> end; handle_graphql_result({error, Reason}) -> {_Code, Error} = mongoose_graphql_errors:format_error(Reason), - JSONResult = jiffy:encode(#{errors => [Error]}, [pretty]), + %CHANGED + JSONResult = [jiffy:encode(#{errors => [Error]}, [pretty])], ?PRINT("~s\n", [JSONResult]), ?STATUS_ERROR. diff --git a/src/event_pusher/mod_event_pusher_push_rdbms.erl b/src/event_pusher/mod_event_pusher_push_rdbms.erl index cdde39a887b..fb76c3c3028 100644 --- a/src/event_pusher/mod_event_pusher_push_rdbms.erl +++ b/src/event_pusher/mod_event_pusher_push_rdbms.erl @@ -82,7 +82,8 @@ decode_row({NodeID, PubSubBin, FormJSON}) -> decode_form(FormJSON)}. encode_form(Form) -> - jiffy:encode(Form). + %CHANGED + [jiffy:encode(Form)]. decode_form(FormJSON) -> jiffy:decode(FormJSON, [return_maps]). diff --git a/src/event_pusher/mod_event_pusher_rabbit.erl b/src/event_pusher/mod_event_pusher_rabbit.erl index 98118f17e72..7fe2ed4c0b1 100644 --- a/src/event_pusher/mod_event_pusher_rabbit.erl +++ b/src/event_pusher/mod_event_pusher_rabbit.erl @@ -178,7 +178,7 @@ 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(). @@ -186,7 +186,7 @@ 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; diff --git a/src/graphql/mongoose_graphql_handler.erl b/src/graphql/mongoose_graphql_handler.erl index 17cf5caea25..5e3df6e4fe1 100644 --- a/src/graphql/mongoose_graphql_handler.erl +++ b/src/graphql/mongoose_graphql_handler.erl @@ -274,7 +274,8 @@ make_error(Phase, Term) -> reply_error(Msg, Req, State) -> {Code, Error} = mongoose_graphql_errors:format_error(Msg), - Body = jiffy:encode(#{errors => [Error]}), + %CHANGED + Body = [jiffy:encode(#{errors => [Error]})], Req2 = cowboy_req:set_resp_body(Body, Req), Reply = cowboy_req:reply(Code, Req2), {stop, Reply, State}. diff --git a/src/graphql/mongoose_graphql_sse_handler.erl b/src/graphql/mongoose_graphql_sse_handler.erl index df4410daf42..f3697d5d203 100644 --- a/src/graphql/mongoose_graphql_sse_handler.erl +++ b/src/graphql/mongoose_graphql_sse_handler.erl @@ -107,5 +107,6 @@ make_error(Phase, Term) -> reply_error(Reason, Req, State) -> {Code, Error} = mongoose_graphql_errors:format_error(Reason), - Body = jiffy:encode(#{errors => [Error]}), + %CHANGED + Body = [jiffy:encode(#{errors => [Error]})], {shutdown, Code, #{}, Body, Req, State}. diff --git a/src/mod_caps_rdbms.erl b/src/mod_caps_rdbms.erl index 4baf42a9e7e..9f2cb0edb91 100644 --- a/src/mod_caps_rdbms.erl +++ b/src/mod_caps_rdbms.erl @@ -31,7 +31,8 @@ read(HostType, {Node, SubNode}) -> -spec write(mongooseim:host_type(), mod_caps:node_pair(), mod_caps:maybe_pending_features()) -> ok. write(HostType, {Node, SubNode}, Features) -> - Encoded = jiffy:encode(Features), + %CHANGED + Encoded = [jiffy:encode(Features)], InsertParams = [Node, SubNode, Encoded], UpdateParams = [Encoded], UniqueKeyValues = [Node, SubNode], diff --git a/src/mod_push_service_mongoosepush.erl b/src/mod_push_service_mongoosepush.erl index ae0f057c91f..afd62f685ce 100644 --- a/src/mod_push_service_mongoosepush.erl +++ b/src/mod_push_service_mongoosepush.erl @@ -100,7 +100,8 @@ push_notifications(AccIn, ReqHeaders = [{<<"content-type">>, <<"application/json">>}], {ok, JSON} = make_notification(Notification, Options), - Payload = jiffy:encode(JSON), + %CHANGED + Payload = [jiffy:encode(JSON)], call(Host, ?MODULE, http_notification, [Host, post, Path, ReqHeaders, Payload]) end, {ok, send_push_notifications(Notifications, Fun, ok)}. diff --git a/src/mongoose_admin_api/mongoose_admin_api.erl b/src/mongoose_admin_api/mongoose_admin_api.erl index 645a35fede3..4eaa0384427 100644 --- a/src/mongoose_admin_api/mongoose_admin_api.erl +++ b/src/mongoose_admin_api/mongoose_admin_api.erl @@ -139,7 +139,8 @@ resource_created(Req, State, Path, Body) -> %% @doc Send response when it can't be returned in a tuple from the handler (e.g. for DELETE) -spec respond(req(), state(), jiffy:json_value()) -> {stop, req(), state()}. respond(Req, State, Response) -> - Req2 = cowboy_req:set_resp_body(jiffy:encode(Response), Req), + %CHANGED + Req2 = cowboy_req:set_resp_body([jiffy:encode(Response)], Req), Req3 = cowboy_req:reply(200, Req2), {stop, Req3, State}. @@ -150,7 +151,8 @@ error_response(ErrorType, Message, Req, State) -> error_type => ErrorType, message => BinMessage, req => Req}), - Req1 = cowboy_req:reply(error_code(ErrorType), #{}, jiffy:encode(BinMessage), Req), + %CHANGED + Req1 = cowboy_req:reply(error_code(ErrorType), #{}, [jiffy:encode(BinMessage)], Req), {stop, Req1, State}. -spec error_code(error_type()) -> non_neg_integer(). diff --git a/src/mongoose_admin_api/mongoose_admin_api_contacts.erl b/src/mongoose_admin_api/mongoose_admin_api_contacts.erl index 87e68d1236c..73e763af898 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_contacts.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_contacts.erl @@ -77,7 +77,8 @@ handle_get(Req, State) -> UserJid = get_user_jid(Bindings), case mod_roster_api:list_contacts(UserJid) of {ok, Rosters} -> - {jiffy:encode(lists:map(fun roster_info/1, Rosters)), Req, State}; + %CHANGED + {[jiffy:encode(lists:map(fun roster_info/1, Rosters))], Req, State}; {unknown_domain, Reason} -> throw_error(not_found, Reason) end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_domain.erl b/src/mongoose_admin_api/mongoose_admin_api_domain.erl index 9566ea3ddc5..1441a3dcb0f 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_domain.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_domain.erl @@ -92,7 +92,8 @@ handle_get(Req, State) -> Domain = get_domain(Bindings), case mongoose_domain_api:get_domain_details(Domain) of {ok, Props} -> - {jiffy:encode(maps:with([host_type, status], Props)), Req, State}; + %CHANGED + {[jiffy:encode(maps:with([host_type, status], Props))], Req, State}; {not_found, Msg} -> throw_error(not_found, Msg); {_, Msg} -> diff --git a/src/mongoose_admin_api/mongoose_admin_api_messages.erl b/src/mongoose_admin_api/mongoose_admin_api_messages.erl index 729b8d98629..f37e04d21f5 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_messages.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_messages.erl @@ -72,7 +72,8 @@ handle_get(Req, State) -> case mongoose_stanza_api:lookup_recent_messages(OwnerJid, WithJid, Before, Limit, true) of {ok, {Rows, _Limit}} -> Messages = lists:map(fun row_to_map/1, Rows), - {jiffy:encode(Messages), Req, State}; + %CHANGED + {[jiffy:encode(Messages)], Req, State}; {unknown_user, Msg} -> throw_error(bad_request, Msg) end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_metrics.erl b/src/mongoose_admin_api/mongoose_admin_api_metrics.erl index 83c8034e928..92b607f3b85 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_metrics.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_metrics.erl @@ -64,7 +64,8 @@ handle_get(Req, State = #{suffix := all}) -> end; all_metrics -> Values = get_sum_metrics(), - {jiffy:encode(#{metrics => Values}), Req, State} + %CHANGED + {[jiffy:encode(#{metrics => Values})], Req, State} end; handle_get(Req, State = #{suffix := global}) -> Bindings = cowboy_req:bindings(Req), @@ -80,7 +81,8 @@ handle_get(Req, State) -> Reply = #{host_types => HostTypes, metrics => lists:map(fun prepare_name/1, Metrics), global => lists:map(fun prepare_name/1, Global)}, - {jiffy:encode(Reply), Req, State} + %CHANGED + {[jiffy:encode(Reply)], Req, State} end. handle_get_values(Req, State, Bindings, HostType) -> @@ -88,7 +90,8 @@ handle_get_values(Req, State, Bindings, HostType) -> {metric, Metric} -> case mongoose_instrument_exometer:get_metric_value(HostType, Metric) of {ok, Value} -> - {jiffy:encode(#{metric => prepare_value(Value)}), Req, State}; + %CHANGED + {[jiffy:encode(#{metric => prepare_value(Value)})], Req, State}; _Other -> throw_error(not_found, <<"Metric not found">>) end; @@ -98,7 +101,8 @@ handle_get_values(Req, State, Bindings, HostType) -> throw_error(not_found, <<"No metrics found">>); Metrics -> Values = prepare_metrics(Metrics), - {jiffy:encode(#{metrics => Values}), Req, State} + %CHANGED + {[jiffy:encode(#{metrics => Values})], Req, State} end end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_sessions.erl b/src/mongoose_admin_api/mongoose_admin_api_sessions.erl index 074f6fc8df1..7c401a95422 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_sessions.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_sessions.erl @@ -56,7 +56,8 @@ delete_resource(Req, State) -> handle_get(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), {ok, Sessions} = mongoose_session_api:list_resources(Domain), - {jiffy:encode(Sessions), Req, State}. + %CHANGED + {[jiffy:encode(Sessions)], Req, State}. handle_delete(Req, State) -> #{domain := Domain} = Bindings = cowboy_req:bindings(Req), diff --git a/src/mongoose_admin_api/mongoose_admin_api_users.erl b/src/mongoose_admin_api/mongoose_admin_api_users.erl index e8d5a70f2e9..fc4464ca6d8 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_users.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_users.erl @@ -75,7 +75,8 @@ handle_get(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), Users = mongoose_account_api:list_users(Domain), {_, UsersList} = Users, - {jiffy:encode(UsersList), Req, State}. + %CHANGED + {[jiffy:encode(UsersList)], Req, State}. handle_post(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), diff --git a/src/mongoose_client_api/mongoose_client_api.erl b/src/mongoose_client_api/mongoose_client_api.erl index 950cc787d2f..3354f57ad80 100644 --- a/src/mongoose_client_api/mongoose_client_api.erl +++ b/src/mongoose_client_api/mongoose_client_api.erl @@ -168,7 +168,8 @@ error_response(ErrorType, Message, Req, State) -> error_type => ErrorType, message => BinMessage, req => Req}), - Req1 = cowboy_req:reply(error_code(ErrorType), #{}, jiffy:encode(BinMessage), Req), + %CHANGED + Req1 = cowboy_req:reply(error_code(ErrorType), #{}, [jiffy:encode(BinMessage)], Req), {stop, Req1, State}. -spec error_code(error_type()) -> non_neg_integer(). diff --git a/src/mongoose_client_api/mongoose_client_api_contacts.erl b/src/mongoose_client_api/mongoose_client_api_contacts.erl index d85cd831ed9..7e767a561ca 100644 --- a/src/mongoose_client_api/mongoose_client_api_contacts.erl +++ b/src/mongoose_client_api/mongoose_client_api_contacts.erl @@ -80,7 +80,8 @@ handle_get(Req, State = #{jid := UserJid}) -> Bindings = cowboy_req:bindings(Req), assert_no_jid(Bindings), {ok, Contacts} = mod_roster_api:list_contacts(UserJid), - {jiffy:encode(lists:map(fun roster_info/1, Contacts)), Req, State}. + %CHANGED + {[jiffy:encode(lists:map(fun roster_info/1, Contacts))], Req, State}. handle_post(Req, State = #{jid := UserJid}) -> Args = parse_body(Req), @@ -109,7 +110,8 @@ handle_delete(Req, State = #{jid := UserJid}) -> ContactJids = get_jids_to_delete(Args), NotDeleted = delete_contacts(UserJid, ContactJids), RespBody = #{not_deleted => lists:map(fun jid:to_binary/1, NotDeleted)}, - Req2 = cowboy_req:set_resp_body(jiffy:encode(RespBody), Req), + %CHANGED + Req2 = cowboy_req:set_resp_body([jiffy:encode(RespBody)], Req), Req3 = cowboy_req:set_resp_header(<<"content-type">>, <<"application/json">>, Req2), {true, Req3, State}; ContactJid -> diff --git a/src/mongoose_client_api/mongoose_client_api_messages.erl b/src/mongoose_client_api/mongoose_client_api_messages.erl index 20ccaec84a3..3e43f9d8768 100644 --- a/src/mongoose_client_api/mongoose_client_api_messages.erl +++ b/src/mongoose_client_api/mongoose_client_api_messages.erl @@ -77,14 +77,16 @@ handle_get(Req, State = #{jid := OwnerJid}) -> {ok, {Rows, _Limit}} = mongoose_stanza_api:lookup_recent_messages(OwnerJid, WithJid, Before, Limit, false), Resp = [make_json_msg(Msg, MAMId) || #{id := MAMId, packet := Msg} <- Rows], - {jiffy:encode(Resp), Req, State}. + %CHANGED + {[jiffy:encode(Resp)], Req, State}. handle_post(Req, State = #{jid := UserJid}) -> Args = parse_body(Req), To = get_to(Args), Body = get_body(Args), {ok, Resp} = mongoose_stanza_api:send_chat_message(UserJid, undefined, To, Body), - Req2 = cowboy_req:set_resp_body(jiffy:encode(Resp), Req), + %CHANGED + Req2 = cowboy_req:set_resp_body([jiffy:encode(Resp)], Req), {true, Req2, State}. get_limit(#{limit := LimitBin}) -> diff --git a/src/mongoose_client_api/mongoose_client_api_rooms.erl b/src/mongoose_client_api/mongoose_client_api_rooms.erl index 4e893e3080e..418fe553b99 100644 --- a/src/mongoose_client_api/mongoose_client_api_rooms.erl +++ b/src/mongoose_client_api/mongoose_client_api_rooms.erl @@ -81,11 +81,13 @@ handle_get(Req, State = #{jid := UserJid}) -> case get_room_jid(Bindings, State, optional) of undefined -> {ok, Rooms} = mod_muc_light_api:get_user_rooms(UserJid), - {jiffy:encode(lists:flatmap(fun room_us_to_json/1, Rooms)), Req, State}; + %CHANGED + {[jiffy:encode(lists:flatmap(fun room_us_to_json/1, Rooms))], Req, State}; RoomJid -> case mod_muc_light_api:get_room_info(RoomJid, UserJid) of {ok, Info} -> - {jiffy:encode(room_info_to_json(Info)), Req, State}; + %CHANGED + {[jiffy:encode(room_info_to_json(Info))], Req, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); {not_room_member, Msg} -> @@ -118,7 +120,8 @@ handle_put(Req, State = #{jid := UserJid}) -> room_created(Req, State, RoomJid) -> RespBody = #{<<"id">> => RoomJid#jid.luser}, - Req2 = cowboy_req:set_resp_body(jiffy:encode(RespBody), Req), + %CHANGED + Req2 = cowboy_req:set_resp_body([jiffy:encode(RespBody)], Req), Req3 = cowboy_req:reply(201, Req2), {stop, Req3, State}. diff --git a/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl b/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl index 24a7030dc8d..38a8a790e90 100644 --- a/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl +++ b/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl @@ -75,7 +75,8 @@ handle_get(Req, State = #{jid := UserJid}) -> case mod_muc_light_api:get_room_messages(RoomJid, UserJid, Limit, Before) of {ok, Msgs} -> JSONData = [make_json_item(Msg) || Msg <- Msgs], - {jiffy:encode(JSONData), Req, State}; + %CHANGED + {[jiffy:encode(JSONData)], Req, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); {not_room_member, Msg} -> @@ -92,7 +93,8 @@ handle_post(Req, State = #{jid := UserJid}) -> case mod_muc_light_api:send_message(RoomJid, UserJid, Children, Attrs) of {ok, _} -> Resp = #{id => UUID}, - Req3 = cowboy_req:set_resp_body(jiffy:encode(Resp), Req), + %CHANGED + Req3 = cowboy_req:set_resp_body([jiffy:encode(Resp)], Req), {true, Req3, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); diff --git a/src/mongoose_client_api/mongoose_client_api_sse.erl b/src/mongoose_client_api/mongoose_client_api_sse.erl index 786dfba6d69..118c033d3f2 100644 --- a/src/mongoose_client_api/mongoose_client_api_sse.erl +++ b/src/mongoose_client_api/mongoose_client_api_sse.erl @@ -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) -> diff --git a/src/muc/mod_muc_rdbms.erl b/src/muc/mod_muc_rdbms.erl index ca8f4c5ed3f..2aeab3bf242 100644 --- a/src/muc/mod_muc_rdbms.erl +++ b/src/muc/mod_muc_rdbms.erl @@ -126,7 +126,8 @@ remove_domain(HostType, MucHost, Domain) -> store_room(HostType, MucHost, RoomName, Opts) -> Affs = proplists:get_value(affiliations, Opts), NewOpts = proplists:delete(affiliations, Opts), - ExtOpts = jiffy:encode({NewOpts}), + %CHANGED + ExtOpts = [jiffy:encode({NewOpts})], F = fun() -> forget_room_transaction(HostType, MucHost, RoomName), store_room_transaction(HostType, MucHost, RoomName, ExtOpts, Affs) diff --git a/src/pubsub/mod_pubsub_db_rdbms.erl b/src/pubsub/mod_pubsub_db_rdbms.erl index 1fcf315f164..215454be2b3 100644 --- a/src/pubsub/mod_pubsub_db_rdbms.erl +++ b/src/pubsub/mod_pubsub_db_rdbms.erl @@ -711,8 +711,10 @@ del_node(Nidx) -> set_node(#pubsub_node{nodeid = {Key, Name}, id = undefined, type = Type, owners = Owners, options = Opts, parents = Parents}) -> ExtKey = encode_key(Key), - ExtOwners = jiffy:encode([jid:to_binary(Owner) || Owner <- Owners]), - ExtOpts = jiffy:encode({Opts}), + %CHANGED + ExtOwners = [jiffy:encode([jid:to_binary(Owner) || Owner <- Owners])], + %CHANGED + ExtOpts = [jiffy:encode({Opts})], {updated, 1} = execute_insert_pubsub_node(ExtKey, Name, Type, ExtOwners, ExtOpts), {selected, [Row]} = execute_select_node_by_key_and_name(ExtKey, Name), #pubsub_node{id = Nidx} = decode_pubsub_node_row(Row), @@ -722,7 +724,8 @@ set_node(#pubsub_node{nodeid = {Key, Name}, id = undefined, type = Type, set_node(#pubsub_node{nodeid = {_, Name}, id = Nidx, type = Type, owners = Owners, options = Opts, parents = Parents}) -> OwnersJid = [jid:to_binary(Owner) || Owner <- Owners], - execute_update_pubsub_node(Type, jiffy:encode(OwnersJid), jiffy:encode({Opts}), Nidx), + %CHANGED + execute_update_pubsub_node(Type, [jiffy:encode(OwnersJid)], [jiffy:encode({Opts})], Nidx), execute_del_parents(Name), set_parents(Name, Parents), {ok, Nidx}. @@ -915,7 +918,8 @@ get_affiliation(Nidx, { LU, LS, _ }) -> SubId :: mod_pubsub:subId(), SubOpts :: mod_pubsub:subOptions()) -> ok. add_subscription(Nidx, { LU, LS, LR }, Sub, SubId, SubOpts) -> - EncodedOpts = jiffy:encode({SubOpts}), + %CHANGED + EncodedOpts = [jiffy:encode({SubOpts})], {updated, _} = execute_insert_subscription(Nidx, LU, LS, LR, sub2int(Sub), SubId, EncodedOpts), ok. @@ -924,7 +928,8 @@ add_subscription(Nidx, { LU, LS, LR }, Sub, SubId, SubOpts) -> SubId :: mod_pubsub:subId(), Opts :: mod_pubsub:subOptions()) -> ok. set_subscription_opts(Nidx, { LU, LS, LR }, SubId, Opts) -> - EncodedOpts = jiffy:encode({Opts}), + %CHANGED + EncodedOpts = [jiffy:encode({Opts})], {updated, _} = execute_update_subscription_opts(EncodedOpts, Nidx, LU, LS, LR, SubId), ok. diff --git a/src/system_metrics/mongoose_system_metrics_file.erl b/src/system_metrics/mongoose_system_metrics_file.erl index 28b115a06fb..bf78f93355d 100644 --- a/src/system_metrics/mongoose_system_metrics_file.erl +++ b/src/system_metrics/mongoose_system_metrics_file.erl @@ -12,6 +12,7 @@ location() -> -spec save([mongoose_system_metrics_collector:report_struct()]) -> ok. save(Reports) -> - JSON = jiffy:encode(Reports, [pretty]), + %CHANGED + JSON = [jiffy:encode(Reports, [pretty])], file:write_file(location(), JSON), ok. diff --git a/src/system_metrics/mongoose_system_metrics_sender.erl b/src/system_metrics/mongoose_system_metrics_sender.erl index 694a4433bd3..d9529c44ca1 100644 --- a/src/system_metrics/mongoose_system_metrics_sender.erl +++ b/src/system_metrics/mongoose_system_metrics_sender.erl @@ -28,7 +28,8 @@ flush_reports(ReportUrl, Reports, ClientId, #{id := TrackingId, secret := TrackingSecret}) when length(Reports) =< 25 -> Headers = [], ContentType = "application/json", - Body = jiffy:encode(#{client_id => list_to_binary(ClientId), events => Reports}), + %CHANGED + Body = [jiffy:encode(#{client_id => list_to_binary(ClientId), events => Reports})], ReportUrl2 = uri_string:normalize( ReportUrl ++ "?api_secret=" ++ TrackingSecret ++ "&measurement_id=" ++ TrackingId), Request = {ReportUrl2, Headers, ContentType, Body}, From d603ba0e57216bba1943ba74f1ec1ce8024e369a Mon Sep 17 00:00:00 2001 From: Janusz Jakubiec Date: Wed, 11 Dec 2024 09:25:55 +0100 Subject: [PATCH 2/2] Fixing dialyzer and removing square brackets around jiffy:encode used for locating lines that need changes. --- src/ejabberd_ctl.erl | 3 +-- src/event_pusher/mod_event_pusher_push_rdbms.erl | 4 ++-- src/graphql/mongoose_graphql_handler.erl | 3 +-- src/graphql/mongoose_graphql_sse_handler.erl | 3 +-- src/mod_caps_rdbms.erl | 3 +-- src/mod_push_service_mongoosepush.erl | 3 +-- src/mongoose_admin_api/mongoose_admin_api.erl | 6 ++---- .../mongoose_admin_api_contacts.erl | 3 +-- .../mongoose_admin_api_domain.erl | 3 +-- .../mongoose_admin_api_messages.erl | 3 +-- .../mongoose_admin_api_metrics.erl | 12 ++++-------- .../mongoose_admin_api_sessions.erl | 3 +-- .../mongoose_admin_api_users.erl | 3 +-- src/mongoose_client_api/mongoose_client_api.erl | 3 +-- .../mongoose_client_api_contacts.erl | 6 ++---- .../mongoose_client_api_messages.erl | 6 ++---- .../mongoose_client_api_rooms.erl | 9 +++------ .../mongoose_client_api_rooms_messages.erl | 6 ++---- src/muc/mod_muc_rdbms.erl | 7 +++---- src/pubsub/mod_pubsub_db_rdbms.erl | 15 +++++---------- src/rdbms/mongoose_rdbms.erl | 4 ++-- .../mongoose_system_metrics_file.erl | 3 +-- .../mongoose_system_metrics_sender.erl | 3 +-- 23 files changed, 40 insertions(+), 74 deletions(-) diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 26e470cd8e5..80ebf418f39 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -188,8 +188,7 @@ handle_graphql_result({ok, Result}) -> end; handle_graphql_result({error, Reason}) -> {_Code, Error} = mongoose_graphql_errors:format_error(Reason), - %CHANGED - JSONResult = [jiffy:encode(#{errors => [Error]}, [pretty])], + JSONResult = jiffy:encode(#{errors => [Error]}, [pretty]), ?PRINT("~s\n", [JSONResult]), ?STATUS_ERROR. diff --git a/src/event_pusher/mod_event_pusher_push_rdbms.erl b/src/event_pusher/mod_event_pusher_push_rdbms.erl index fb76c3c3028..6970c624154 100644 --- a/src/event_pusher/mod_event_pusher_push_rdbms.erl +++ b/src/event_pusher/mod_event_pusher_push_rdbms.erl @@ -81,9 +81,9 @@ decode_row({NodeID, PubSubBin, FormJSON}) -> NodeID, decode_form(FormJSON)}. +-spec encode_form(mod_event_pusher_push:form()) -> iodata(). encode_form(Form) -> - %CHANGED - [jiffy:encode(Form)]. + jiffy:encode(Form). decode_form(FormJSON) -> jiffy:decode(FormJSON, [return_maps]). diff --git a/src/graphql/mongoose_graphql_handler.erl b/src/graphql/mongoose_graphql_handler.erl index 5e3df6e4fe1..17cf5caea25 100644 --- a/src/graphql/mongoose_graphql_handler.erl +++ b/src/graphql/mongoose_graphql_handler.erl @@ -274,8 +274,7 @@ make_error(Phase, Term) -> reply_error(Msg, Req, State) -> {Code, Error} = mongoose_graphql_errors:format_error(Msg), - %CHANGED - Body = [jiffy:encode(#{errors => [Error]})], + Body = jiffy:encode(#{errors => [Error]}), Req2 = cowboy_req:set_resp_body(Body, Req), Reply = cowboy_req:reply(Code, Req2), {stop, Reply, State}. diff --git a/src/graphql/mongoose_graphql_sse_handler.erl b/src/graphql/mongoose_graphql_sse_handler.erl index f3697d5d203..df4410daf42 100644 --- a/src/graphql/mongoose_graphql_sse_handler.erl +++ b/src/graphql/mongoose_graphql_sse_handler.erl @@ -107,6 +107,5 @@ make_error(Phase, Term) -> reply_error(Reason, Req, State) -> {Code, Error} = mongoose_graphql_errors:format_error(Reason), - %CHANGED - Body = [jiffy:encode(#{errors => [Error]})], + Body = jiffy:encode(#{errors => [Error]}), {shutdown, Code, #{}, Body, Req, State}. diff --git a/src/mod_caps_rdbms.erl b/src/mod_caps_rdbms.erl index 9f2cb0edb91..4baf42a9e7e 100644 --- a/src/mod_caps_rdbms.erl +++ b/src/mod_caps_rdbms.erl @@ -31,8 +31,7 @@ read(HostType, {Node, SubNode}) -> -spec write(mongooseim:host_type(), mod_caps:node_pair(), mod_caps:maybe_pending_features()) -> ok. write(HostType, {Node, SubNode}, Features) -> - %CHANGED - Encoded = [jiffy:encode(Features)], + Encoded = jiffy:encode(Features), InsertParams = [Node, SubNode, Encoded], UpdateParams = [Encoded], UniqueKeyValues = [Node, SubNode], diff --git a/src/mod_push_service_mongoosepush.erl b/src/mod_push_service_mongoosepush.erl index afd62f685ce..ae0f057c91f 100644 --- a/src/mod_push_service_mongoosepush.erl +++ b/src/mod_push_service_mongoosepush.erl @@ -100,8 +100,7 @@ push_notifications(AccIn, ReqHeaders = [{<<"content-type">>, <<"application/json">>}], {ok, JSON} = make_notification(Notification, Options), - %CHANGED - Payload = [jiffy:encode(JSON)], + Payload = jiffy:encode(JSON), call(Host, ?MODULE, http_notification, [Host, post, Path, ReqHeaders, Payload]) end, {ok, send_push_notifications(Notifications, Fun, ok)}. diff --git a/src/mongoose_admin_api/mongoose_admin_api.erl b/src/mongoose_admin_api/mongoose_admin_api.erl index 4eaa0384427..645a35fede3 100644 --- a/src/mongoose_admin_api/mongoose_admin_api.erl +++ b/src/mongoose_admin_api/mongoose_admin_api.erl @@ -139,8 +139,7 @@ resource_created(Req, State, Path, Body) -> %% @doc Send response when it can't be returned in a tuple from the handler (e.g. for DELETE) -spec respond(req(), state(), jiffy:json_value()) -> {stop, req(), state()}. respond(Req, State, Response) -> - %CHANGED - Req2 = cowboy_req:set_resp_body([jiffy:encode(Response)], Req), + Req2 = cowboy_req:set_resp_body(jiffy:encode(Response), Req), Req3 = cowboy_req:reply(200, Req2), {stop, Req3, State}. @@ -151,8 +150,7 @@ error_response(ErrorType, Message, Req, State) -> error_type => ErrorType, message => BinMessage, req => Req}), - %CHANGED - Req1 = cowboy_req:reply(error_code(ErrorType), #{}, [jiffy:encode(BinMessage)], Req), + Req1 = cowboy_req:reply(error_code(ErrorType), #{}, jiffy:encode(BinMessage), Req), {stop, Req1, State}. -spec error_code(error_type()) -> non_neg_integer(). diff --git a/src/mongoose_admin_api/mongoose_admin_api_contacts.erl b/src/mongoose_admin_api/mongoose_admin_api_contacts.erl index 73e763af898..87e68d1236c 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_contacts.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_contacts.erl @@ -77,8 +77,7 @@ handle_get(Req, State) -> UserJid = get_user_jid(Bindings), case mod_roster_api:list_contacts(UserJid) of {ok, Rosters} -> - %CHANGED - {[jiffy:encode(lists:map(fun roster_info/1, Rosters))], Req, State}; + {jiffy:encode(lists:map(fun roster_info/1, Rosters)), Req, State}; {unknown_domain, Reason} -> throw_error(not_found, Reason) end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_domain.erl b/src/mongoose_admin_api/mongoose_admin_api_domain.erl index 1441a3dcb0f..9566ea3ddc5 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_domain.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_domain.erl @@ -92,8 +92,7 @@ handle_get(Req, State) -> Domain = get_domain(Bindings), case mongoose_domain_api:get_domain_details(Domain) of {ok, Props} -> - %CHANGED - {[jiffy:encode(maps:with([host_type, status], Props))], Req, State}; + {jiffy:encode(maps:with([host_type, status], Props)), Req, State}; {not_found, Msg} -> throw_error(not_found, Msg); {_, Msg} -> diff --git a/src/mongoose_admin_api/mongoose_admin_api_messages.erl b/src/mongoose_admin_api/mongoose_admin_api_messages.erl index f37e04d21f5..729b8d98629 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_messages.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_messages.erl @@ -72,8 +72,7 @@ handle_get(Req, State) -> case mongoose_stanza_api:lookup_recent_messages(OwnerJid, WithJid, Before, Limit, true) of {ok, {Rows, _Limit}} -> Messages = lists:map(fun row_to_map/1, Rows), - %CHANGED - {[jiffy:encode(Messages)], Req, State}; + {jiffy:encode(Messages), Req, State}; {unknown_user, Msg} -> throw_error(bad_request, Msg) end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_metrics.erl b/src/mongoose_admin_api/mongoose_admin_api_metrics.erl index 92b607f3b85..83c8034e928 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_metrics.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_metrics.erl @@ -64,8 +64,7 @@ handle_get(Req, State = #{suffix := all}) -> end; all_metrics -> Values = get_sum_metrics(), - %CHANGED - {[jiffy:encode(#{metrics => Values})], Req, State} + {jiffy:encode(#{metrics => Values}), Req, State} end; handle_get(Req, State = #{suffix := global}) -> Bindings = cowboy_req:bindings(Req), @@ -81,8 +80,7 @@ handle_get(Req, State) -> Reply = #{host_types => HostTypes, metrics => lists:map(fun prepare_name/1, Metrics), global => lists:map(fun prepare_name/1, Global)}, - %CHANGED - {[jiffy:encode(Reply)], Req, State} + {jiffy:encode(Reply), Req, State} end. handle_get_values(Req, State, Bindings, HostType) -> @@ -90,8 +88,7 @@ handle_get_values(Req, State, Bindings, HostType) -> {metric, Metric} -> case mongoose_instrument_exometer:get_metric_value(HostType, Metric) of {ok, Value} -> - %CHANGED - {[jiffy:encode(#{metric => prepare_value(Value)})], Req, State}; + {jiffy:encode(#{metric => prepare_value(Value)}), Req, State}; _Other -> throw_error(not_found, <<"Metric not found">>) end; @@ -101,8 +98,7 @@ handle_get_values(Req, State, Bindings, HostType) -> throw_error(not_found, <<"No metrics found">>); Metrics -> Values = prepare_metrics(Metrics), - %CHANGED - {[jiffy:encode(#{metrics => Values})], Req, State} + {jiffy:encode(#{metrics => Values}), Req, State} end end. diff --git a/src/mongoose_admin_api/mongoose_admin_api_sessions.erl b/src/mongoose_admin_api/mongoose_admin_api_sessions.erl index 7c401a95422..074f6fc8df1 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_sessions.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_sessions.erl @@ -56,8 +56,7 @@ delete_resource(Req, State) -> handle_get(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), {ok, Sessions} = mongoose_session_api:list_resources(Domain), - %CHANGED - {[jiffy:encode(Sessions)], Req, State}. + {jiffy:encode(Sessions), Req, State}. handle_delete(Req, State) -> #{domain := Domain} = Bindings = cowboy_req:bindings(Req), diff --git a/src/mongoose_admin_api/mongoose_admin_api_users.erl b/src/mongoose_admin_api/mongoose_admin_api_users.erl index fc4464ca6d8..e8d5a70f2e9 100644 --- a/src/mongoose_admin_api/mongoose_admin_api_users.erl +++ b/src/mongoose_admin_api/mongoose_admin_api_users.erl @@ -75,8 +75,7 @@ handle_get(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), Users = mongoose_account_api:list_users(Domain), {_, UsersList} = Users, - %CHANGED - {[jiffy:encode(UsersList)], Req, State}. + {jiffy:encode(UsersList), Req, State}. handle_post(Req, State) -> #{domain := Domain} = cowboy_req:bindings(Req), diff --git a/src/mongoose_client_api/mongoose_client_api.erl b/src/mongoose_client_api/mongoose_client_api.erl index 3354f57ad80..950cc787d2f 100644 --- a/src/mongoose_client_api/mongoose_client_api.erl +++ b/src/mongoose_client_api/mongoose_client_api.erl @@ -168,8 +168,7 @@ error_response(ErrorType, Message, Req, State) -> error_type => ErrorType, message => BinMessage, req => Req}), - %CHANGED - Req1 = cowboy_req:reply(error_code(ErrorType), #{}, [jiffy:encode(BinMessage)], Req), + Req1 = cowboy_req:reply(error_code(ErrorType), #{}, jiffy:encode(BinMessage), Req), {stop, Req1, State}. -spec error_code(error_type()) -> non_neg_integer(). diff --git a/src/mongoose_client_api/mongoose_client_api_contacts.erl b/src/mongoose_client_api/mongoose_client_api_contacts.erl index 7e767a561ca..d85cd831ed9 100644 --- a/src/mongoose_client_api/mongoose_client_api_contacts.erl +++ b/src/mongoose_client_api/mongoose_client_api_contacts.erl @@ -80,8 +80,7 @@ handle_get(Req, State = #{jid := UserJid}) -> Bindings = cowboy_req:bindings(Req), assert_no_jid(Bindings), {ok, Contacts} = mod_roster_api:list_contacts(UserJid), - %CHANGED - {[jiffy:encode(lists:map(fun roster_info/1, Contacts))], Req, State}. + {jiffy:encode(lists:map(fun roster_info/1, Contacts)), Req, State}. handle_post(Req, State = #{jid := UserJid}) -> Args = parse_body(Req), @@ -110,8 +109,7 @@ handle_delete(Req, State = #{jid := UserJid}) -> ContactJids = get_jids_to_delete(Args), NotDeleted = delete_contacts(UserJid, ContactJids), RespBody = #{not_deleted => lists:map(fun jid:to_binary/1, NotDeleted)}, - %CHANGED - Req2 = cowboy_req:set_resp_body([jiffy:encode(RespBody)], Req), + Req2 = cowboy_req:set_resp_body(jiffy:encode(RespBody), Req), Req3 = cowboy_req:set_resp_header(<<"content-type">>, <<"application/json">>, Req2), {true, Req3, State}; ContactJid -> diff --git a/src/mongoose_client_api/mongoose_client_api_messages.erl b/src/mongoose_client_api/mongoose_client_api_messages.erl index 3e43f9d8768..20ccaec84a3 100644 --- a/src/mongoose_client_api/mongoose_client_api_messages.erl +++ b/src/mongoose_client_api/mongoose_client_api_messages.erl @@ -77,16 +77,14 @@ handle_get(Req, State = #{jid := OwnerJid}) -> {ok, {Rows, _Limit}} = mongoose_stanza_api:lookup_recent_messages(OwnerJid, WithJid, Before, Limit, false), Resp = [make_json_msg(Msg, MAMId) || #{id := MAMId, packet := Msg} <- Rows], - %CHANGED - {[jiffy:encode(Resp)], Req, State}. + {jiffy:encode(Resp), Req, State}. handle_post(Req, State = #{jid := UserJid}) -> Args = parse_body(Req), To = get_to(Args), Body = get_body(Args), {ok, Resp} = mongoose_stanza_api:send_chat_message(UserJid, undefined, To, Body), - %CHANGED - Req2 = cowboy_req:set_resp_body([jiffy:encode(Resp)], Req), + Req2 = cowboy_req:set_resp_body(jiffy:encode(Resp), Req), {true, Req2, State}. get_limit(#{limit := LimitBin}) -> diff --git a/src/mongoose_client_api/mongoose_client_api_rooms.erl b/src/mongoose_client_api/mongoose_client_api_rooms.erl index 418fe553b99..4e893e3080e 100644 --- a/src/mongoose_client_api/mongoose_client_api_rooms.erl +++ b/src/mongoose_client_api/mongoose_client_api_rooms.erl @@ -81,13 +81,11 @@ handle_get(Req, State = #{jid := UserJid}) -> case get_room_jid(Bindings, State, optional) of undefined -> {ok, Rooms} = mod_muc_light_api:get_user_rooms(UserJid), - %CHANGED - {[jiffy:encode(lists:flatmap(fun room_us_to_json/1, Rooms))], Req, State}; + {jiffy:encode(lists:flatmap(fun room_us_to_json/1, Rooms)), Req, State}; RoomJid -> case mod_muc_light_api:get_room_info(RoomJid, UserJid) of {ok, Info} -> - %CHANGED - {[jiffy:encode(room_info_to_json(Info))], Req, State}; + {jiffy:encode(room_info_to_json(Info)), Req, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); {not_room_member, Msg} -> @@ -120,8 +118,7 @@ handle_put(Req, State = #{jid := UserJid}) -> room_created(Req, State, RoomJid) -> RespBody = #{<<"id">> => RoomJid#jid.luser}, - %CHANGED - Req2 = cowboy_req:set_resp_body([jiffy:encode(RespBody)], Req), + Req2 = cowboy_req:set_resp_body(jiffy:encode(RespBody), Req), Req3 = cowboy_req:reply(201, Req2), {stop, Req3, State}. diff --git a/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl b/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl index 38a8a790e90..24a7030dc8d 100644 --- a/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl +++ b/src/mongoose_client_api/mongoose_client_api_rooms_messages.erl @@ -75,8 +75,7 @@ handle_get(Req, State = #{jid := UserJid}) -> case mod_muc_light_api:get_room_messages(RoomJid, UserJid, Limit, Before) of {ok, Msgs} -> JSONData = [make_json_item(Msg) || Msg <- Msgs], - %CHANGED - {[jiffy:encode(JSONData)], Req, State}; + {jiffy:encode(JSONData), Req, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); {not_room_member, Msg} -> @@ -93,8 +92,7 @@ handle_post(Req, State = #{jid := UserJid}) -> case mod_muc_light_api:send_message(RoomJid, UserJid, Children, Attrs) of {ok, _} -> Resp = #{id => UUID}, - %CHANGED - Req3 = cowboy_req:set_resp_body([jiffy:encode(Resp)], Req), + Req3 = cowboy_req:set_resp_body(jiffy:encode(Resp), Req), {true, Req3, State}; {room_not_found, Msg} -> throw_error(not_found, Msg); diff --git a/src/muc/mod_muc_rdbms.erl b/src/muc/mod_muc_rdbms.erl index 2aeab3bf242..ca21a3ce0ab 100644 --- a/src/muc/mod_muc_rdbms.erl +++ b/src/muc/mod_muc_rdbms.erl @@ -126,8 +126,7 @@ remove_domain(HostType, MucHost, Domain) -> store_room(HostType, MucHost, RoomName, Opts) -> Affs = proplists:get_value(affiliations, Opts), NewOpts = proplists:delete(affiliations, Opts), - %CHANGED - ExtOpts = [jiffy:encode({NewOpts})], + ExtOpts = jiffy:encode({NewOpts}), F = fun() -> forget_room_transaction(HostType, MucHost, RoomName), store_room_transaction(HostType, MucHost, RoomName, ExtOpts, Affs) @@ -220,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), @@ -250,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), diff --git a/src/pubsub/mod_pubsub_db_rdbms.erl b/src/pubsub/mod_pubsub_db_rdbms.erl index 215454be2b3..1fcf315f164 100644 --- a/src/pubsub/mod_pubsub_db_rdbms.erl +++ b/src/pubsub/mod_pubsub_db_rdbms.erl @@ -711,10 +711,8 @@ del_node(Nidx) -> set_node(#pubsub_node{nodeid = {Key, Name}, id = undefined, type = Type, owners = Owners, options = Opts, parents = Parents}) -> ExtKey = encode_key(Key), - %CHANGED - ExtOwners = [jiffy:encode([jid:to_binary(Owner) || Owner <- Owners])], - %CHANGED - ExtOpts = [jiffy:encode({Opts})], + ExtOwners = jiffy:encode([jid:to_binary(Owner) || Owner <- Owners]), + ExtOpts = jiffy:encode({Opts}), {updated, 1} = execute_insert_pubsub_node(ExtKey, Name, Type, ExtOwners, ExtOpts), {selected, [Row]} = execute_select_node_by_key_and_name(ExtKey, Name), #pubsub_node{id = Nidx} = decode_pubsub_node_row(Row), @@ -724,8 +722,7 @@ set_node(#pubsub_node{nodeid = {Key, Name}, id = undefined, type = Type, set_node(#pubsub_node{nodeid = {_, Name}, id = Nidx, type = Type, owners = Owners, options = Opts, parents = Parents}) -> OwnersJid = [jid:to_binary(Owner) || Owner <- Owners], - %CHANGED - execute_update_pubsub_node(Type, [jiffy:encode(OwnersJid)], [jiffy:encode({Opts})], Nidx), + execute_update_pubsub_node(Type, jiffy:encode(OwnersJid), jiffy:encode({Opts}), Nidx), execute_del_parents(Name), set_parents(Name, Parents), {ok, Nidx}. @@ -918,8 +915,7 @@ get_affiliation(Nidx, { LU, LS, _ }) -> SubId :: mod_pubsub:subId(), SubOpts :: mod_pubsub:subOptions()) -> ok. add_subscription(Nidx, { LU, LS, LR }, Sub, SubId, SubOpts) -> - %CHANGED - EncodedOpts = [jiffy:encode({SubOpts})], + EncodedOpts = jiffy:encode({SubOpts}), {updated, _} = execute_insert_subscription(Nidx, LU, LS, LR, sub2int(Sub), SubId, EncodedOpts), ok. @@ -928,8 +924,7 @@ add_subscription(Nidx, { LU, LS, LR }, Sub, SubId, SubOpts) -> SubId :: mod_pubsub:subId(), Opts :: mod_pubsub:subOptions()) -> ok. set_subscription_opts(Nidx, { LU, LS, LR }, SubId, Opts) -> - %CHANGED - EncodedOpts = [jiffy:encode({Opts})], + EncodedOpts = jiffy:encode({Opts}), {updated, _} = execute_update_subscription_opts(EncodedOpts, Nidx, LU, LS, LR, SubId), ok. diff --git a/src/rdbms/mongoose_rdbms.erl b/src/rdbms/mongoose_rdbms.erl index 2a7abde452a..0167536eb29 100644 --- a/src/rdbms/mongoose_rdbms.erl +++ b/src/rdbms/mongoose_rdbms.erl @@ -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()]} | diff --git a/src/system_metrics/mongoose_system_metrics_file.erl b/src/system_metrics/mongoose_system_metrics_file.erl index bf78f93355d..28b115a06fb 100644 --- a/src/system_metrics/mongoose_system_metrics_file.erl +++ b/src/system_metrics/mongoose_system_metrics_file.erl @@ -12,7 +12,6 @@ location() -> -spec save([mongoose_system_metrics_collector:report_struct()]) -> ok. save(Reports) -> - %CHANGED - JSON = [jiffy:encode(Reports, [pretty])], + JSON = jiffy:encode(Reports, [pretty]), file:write_file(location(), JSON), ok. diff --git a/src/system_metrics/mongoose_system_metrics_sender.erl b/src/system_metrics/mongoose_system_metrics_sender.erl index d9529c44ca1..694a4433bd3 100644 --- a/src/system_metrics/mongoose_system_metrics_sender.erl +++ b/src/system_metrics/mongoose_system_metrics_sender.erl @@ -28,8 +28,7 @@ flush_reports(ReportUrl, Reports, ClientId, #{id := TrackingId, secret := TrackingSecret}) when length(Reports) =< 25 -> Headers = [], ContentType = "application/json", - %CHANGED - Body = [jiffy:encode(#{client_id => list_to_binary(ClientId), events => Reports})], + Body = jiffy:encode(#{client_id => list_to_binary(ClientId), events => Reports}), ReportUrl2 = uri_string:normalize( ReportUrl ++ "?api_secret=" ++ TrackingSecret ++ "&measurement_id=" ++ TrackingId), Request = {ReportUrl2, Headers, ContentType, Body},