Skip to content

Commit

Permalink
Add support for XEP-0425 version 0.3.0, keep supporting 0.2.1 (proces…
Browse files Browse the repository at this point in the history
  • Loading branch information
badlop committed May 28, 2024
1 parent 0459ee1 commit fc2e91c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"stringprep": {:hex, :stringprep, "1.0.29", "02f23e8c3a219a3dfe40a22e908bece3a2f68af0ff599ea8a7b714ecb21e62ee", [:rebar3], [{:p1_utils, "1.0.25", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "928eba304c3006eb1512110ebd7b87db163b00859a09375a1e4466152c6c462a"},
"stun": {:hex, :stun, "1.2.12", "a65df67a8aaaecb6a94d687977b2e9f161820819910cb97bbe26a3525356525b", [:rebar3], [{:fast_tls, "1.1.19", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.25", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm", "a2055032b6d338d0454142004bcb12fafb0c64ab1f273f1d0c6923ebbc8ede40"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},
"xmpp": {:git, "https://github.com/processone/xmpp", "281b42c544d6dc2028fd4f3d62e553638ab8bdd9", []},
"xmpp": {:git, "https://github.com/processone/xmpp", "a1fb778bd385d832f913e564558152ea507dac37", []},
"yconf": {:hex, :yconf, "1.0.15", "e22998b3d7728270bdd06162a9515bd142b14fae8927cbdbd3ef639c32aa6f7a", [:rebar3], [{:fast_yaml, "1.0.36", [hex: :fast_yaml, repo: "hexpm", optional: false]}], "hexpm", "7ff2ab24d3c9833842716b9aaaa01a8f96641a7695cbb701b03445c4def01117"},
}
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},1},
{<<"xmpp">>,
{git,"https://github.com/processone/xmpp",
{ref,"281b42c544d6dc2028fd4f3d62e553638ab8bdd9"}},
{ref,"a1fb778bd385d832f913e564558152ea507dac37"}},
0},
{<<"yconf">>,{pkg,<<"yconf">>,<<"1.0.15">>},0}]}.
[
Expand Down
2 changes: 1 addition & 1 deletion src/mod_mam.erl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
-protocol({xep, 313, '0.6.1', '15.06', "", ""}).
-protocol({xep, 334, '0.2'}).
-protocol({xep, 359, '0.5.0'}).
-protocol({xep, 425, '0.2.1', '23.04', "", ""}).
-protocol({xep, 425, '0.3.0', '24.xx', "", ""}).
-protocol({xep, 441, '0.2.0'}).

-behaviour(gen_mod).
Expand Down
41 changes: 28 additions & 13 deletions src/mod_muc_room.erl
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,12 @@ normal_state({route, <<"">>,
process_iq_adhoc(From, IQ, StateData);
#register{} ->
mod_muc:process_iq_register(IQ);
#fasten_apply_to{} = ApplyTo ->
#message_moderate{} = Moderate -> % moderate:1
process_iq_moderate(From, IQ, Moderate, StateData);
#fasten_apply_to{id = ModerateId} = ApplyTo ->
case xmpp:get_subtag(ApplyTo, #message_moderate{}) of
#message_moderate{} = Moderate ->
process_iq_moderate(From, IQ, ApplyTo, Moderate, StateData);
#message_moderate{} = Moderate -> % moderate:0
process_iq_moderate(From, IQ, Moderate#message_moderate{id = ModerateId}, StateData);
_ ->
Txt = ?T("The feature requested is not "
"supported by the conference"),
Expand Down Expand Up @@ -4399,7 +4401,9 @@ make_disco_info(From, StateData) ->
ServerHost = StateData#state.server_host,
AccessRegister = mod_muc_opt:access_register(ServerHost),
Feats = [?NS_VCARD, ?NS_MUC, ?NS_DISCO_INFO, ?NS_DISCO_ITEMS,
?NS_COMMANDS, ?NS_MESSAGE_MODERATE, ?NS_MESSAGE_RETRACT,
?NS_COMMANDS,
?NS_MESSAGE_MODERATE_0, ?NS_MESSAGE_MODERATE_1,
?NS_MESSAGE_RETRACT,
?CONFIG_OPT_TO_FEATURE((Config#config.public),
<<"muc_public">>, <<"muc_hidden">>),
?CONFIG_OPT_TO_FEATURE((Config#config.persistent),
Expand Down Expand Up @@ -5158,14 +5162,13 @@ add_presence_hats(JID, Pres, StateData) ->
Pres
end.

-spec process_iq_moderate(jid(), iq(), fasten_apply_to(), message_moderate(), state()) ->
-spec process_iq_moderate(jid(), iq(), message_moderate(), state()) ->
{result, undefined, state()} |
{error, stanza_error()}.
process_iq_moderate(_From, #iq{type = get}, _ApplyTo, _Moderate, _StateData) ->
process_iq_moderate(_From, #iq{type = get}, _Moderate, _StateData) ->
{error, xmpp:err_bad_request()};
process_iq_moderate(From, #iq{type = set, lang = Lang},
#fasten_apply_to{id = Id},
#message_moderate{reason = Reason},
#message_moderate{id = Id, reason = Reason, xmlns = Xmlns},
#state{config = Config, room = Room, host = Host,
jid = JID, server_host = Server} = StateData) ->
FAffiliation = get_affiliation(From, StateData),
Expand All @@ -5186,13 +5189,25 @@ process_iq_moderate(From, #iq{type = set, lang = Lang},
ok
end,
By = jid:replace_resource(JID, find_nick_by_jid(From, StateData)),
SubEl = case Xmlns of
?NS_MESSAGE_MODERATE_0 ->
SubEls = [#xmlel{name = <<"reason">>,
attrs = [],
children = [{xmlcdata, Reason}]},
#message_retract{id = Id}],
ModeratedEl = #message_moderated{by = By,
sub_els = SubEls},
#fasten_apply_to{id = Id,
sub_els = [ModeratedEl]};
?NS_MESSAGE_MODERATE_1 ->
ModeratedEl = #message_moderated{by = By},
#message_retract{id = Id,
reason = Reason,
moderated = ModeratedEl}
end,
Packet0 = #message{type = groupchat,
from = From,
sub_els = [
#fasten_apply_to{id = Id, sub_els = [
#message_moderated{by = By, reason = Reason,
retract = #message_retract{id = Id}}
]}]},
sub_els = [SubEl]},
{FromNick, _Role} = get_participant_data(From, StateData),
Packet = ejabberd_hooks:run_fold(muc_filter_message,
StateData#state.server_host,
Expand Down

0 comments on commit fc2e91c

Please sign in to comment.