25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Change logic for archiving mucsub messages

This change should apply usual logic for message wrapped in mucsub except
check for groupchat message, so messages without bodies for example
should be rejected
This commit is contained in:
Paweł Chmielowski 2018-10-10 18:02:45 +02:00
parent d1e072821e
commit 914fae3d3e
2 changed files with 34 additions and 4 deletions

View File

@ -648,9 +648,20 @@ should_archive(#message{body = Body, subject = Subject,
none when Type == headline -> none when Type == headline ->
false; false;
none -> none ->
xmpp:get_text(Body) /= <<>> orelse case xmpp:get_text(Body) /= <<>> orelse
xmpp:get_text(Subject) /= <<>> orelse xmpp:get_text(Subject) /= <<>> of
xmpp:has_subtag(Pkt, #ps_event{}) true ->
true;
_ ->
case mod_muc_room:unwrap_mucsub_message(Pkt) of
#message{type = groupchat} = Msg ->
should_archive(Msg#message{type = chat}, LServer);
#message{} = Msg ->
should_archive(Msg, LServer);
_ ->
false
end
end
end end
end; end;
should_archive(_, _LServer) -> should_archive(_, _LServer) ->

View File

@ -39,7 +39,8 @@
is_occupant_or_admin/2, is_occupant_or_admin/2,
route/2, route/2,
expand_opts/1, expand_opts/1,
config_fields/0]). config_fields/0,
unwrap_mucsub_message/1]).
%% gen_fsm callbacks %% gen_fsm callbacks
-export([init/1, -export([init/1,
@ -4459,6 +4460,24 @@ wrap(From, To, Packet, Node) ->
id = p1_rand:get_string(), id = p1_rand:get_string(),
sub_els = [El]}]}}]}. sub_els = [El]}]}}]}.
-spec unwrap_mucsub_message(xmpp_element()) -> message() | false.
unwrap_mucsub_message(#message{} = Packet) ->
case xmpp:get_subtag(Packet, #ps_event{}) of
#ps_event{
items = #ps_items{
node = Node,
items = [
#ps_item{
sub_els = [#message{} = Message]} | _]}}
when Node == ?NS_MUCSUB_NODES_MESSAGES;
Node == ?NS_MUCSUB_NODES_SUBJECT ->
Message;
_ ->
false
end;
unwrap_mucsub_message(_Packet) ->
false.
%% -spec send_multiple(jid(), binary(), [#user{}], stanza()) -> ok. %% -spec send_multiple(jid(), binary(), [#user{}], stanza()) -> ok.
%% send_multiple(From, Server, Users, Packet) -> %% send_multiple(From, Server, Users, Packet) ->
%% JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)], %% JIDs = [ User#user.jid || {_, User} <- ?DICT:to_list(Users)],