25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Merge pull request #592 from weiss/omit-subject-body

Don't add body element to MUC subject messages
This commit is contained in:
badlop 2015-06-04 11:04:05 +02:00
commit 7206bff4a4

View File

@ -1883,7 +1883,7 @@ add_new_user(From, Nick,
Shift = count_stanza_shift(Nick, Els, NewState), Shift = count_stanza_shift(Nick, Els, NewState),
case send_history(From, Shift, NewState) of case send_history(From, Shift, NewState) of
true -> ok; true -> ok;
_ -> send_subject(From, Lang, StateData) _ -> send_subject(From, StateData)
end, end,
case NewState#state.just_created of case NewState#state.just_created of
true -> NewState#state{just_created = false}; true -> NewState#state{just_created = false};
@ -2502,25 +2502,15 @@ send_history(JID, Shift, StateData) ->
lists:nthtail(Shift, lists:nthtail(Shift,
lqueue_to_list(StateData#state.history))). lqueue_to_list(StateData#state.history))).
send_subject(JID, Lang, StateData) -> send_subject(_JID, #state{subject_author = <<"">>}) -> ok;
case StateData#state.subject_author of send_subject(JID, StateData) ->
<<"">> -> ok;
Nick ->
Subject = StateData#state.subject, Subject = StateData#state.subject,
Packet = #xmlel{name = <<"message">>, Packet = #xmlel{name = <<"message">>,
attrs = [{<<"type">>, <<"groupchat">>}], attrs = [{<<"type">>, <<"groupchat">>}],
children = children =
[#xmlel{name = <<"subject">>, attrs = [], [#xmlel{name = <<"subject">>, attrs = [],
children = [{xmlcdata, Subject}]}, children = [{xmlcdata, Subject}]}]},
#xmlel{name = <<"body">>, attrs = [], ejabberd_router:route(StateData#state.jid, JID, Packet).
children =
[{xmlcdata,
<<Nick/binary,
(translate:translate(Lang,
<<" has set the subject to: ">>))/binary,
Subject/binary>>}]}]},
ejabberd_router:route(StateData#state.jid, JID, Packet)
end.
check_subject(Packet) -> check_subject(Packet) ->
case xml:get_subtag(Packet, <<"subject">>) of case xml:get_subtag(Packet, <<"subject">>) of