25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Allow changing invitation message from muc_invite hook

This commit is contained in:
Paweł Chmielowski 2018-09-21 16:37:52 +02:00
parent 1b3a6dd54a
commit 0394baaa7a

View File

@ -860,7 +860,7 @@ process_normal_message(From, #message{lang = Lang} = Pkt, StateData) ->
{ok, [#muc_invite{}|_] = Invitations} -> {ok, [#muc_invite{}|_] = Invitations} ->
lists:foldl( lists:foldl(
fun(Invitation, AccState) -> fun(Invitation, AccState) ->
process_invitation(From, Invitation, Lang, AccState) process_invitation(From, Pkt, Invitation, Lang, AccState)
end, StateData, Invitations); end, StateData, Invitations);
{ok, [{role, participant}]} -> {ok, [{role, participant}]} ->
process_voice_request(From, Pkt, StateData); process_voice_request(From, Pkt, StateData);
@ -873,9 +873,9 @@ process_normal_message(From, #message{lang = Lang} = Pkt, StateData) ->
StateData StateData
end. end.
-spec process_invitation(jid(), muc_invite(), binary(), state()) -> state(). -spec process_invitation(jid(), message(), muc_invite(), binary(), state()) -> state().
process_invitation(From, Invitation, Lang, StateData) -> process_invitation(From, Pkt, Invitation, Lang, StateData) ->
IJID = route_invitation(From, Invitation, Lang, StateData), IJID = route_invitation(From, Pkt, Invitation, Lang, StateData),
Config = StateData#state.config, Config = StateData#state.config,
case Config#config.members_only of case Config#config.members_only of
true -> true ->
@ -4192,8 +4192,8 @@ check_invitation(From, Invitations, Lang, StateData) ->
{error, xmpp:err_not_allowed(Txt, Lang)} {error, xmpp:err_not_allowed(Txt, Lang)}
end. end.
-spec route_invitation(jid(), muc_invite(), binary(), state()) -> jid(). -spec route_invitation(jid(), message(), muc_invite(), binary(), state()) -> jid().
route_invitation(From, Invitation, Lang, StateData) -> route_invitation(From, Pkt, Invitation, Lang, StateData) ->
#muc_invite{to = JID, reason = Reason} = Invitation, #muc_invite{to = JID, reason = Reason} = Invitation,
Invite = Invitation#muc_invite{to = undefined, from = From}, Invite = Invitation#muc_invite{to = undefined, from = From},
Password = case (StateData#state.config)#config.password_protected of Password = case (StateData#state.config)#config.password_protected of
@ -4232,10 +4232,12 @@ route_invitation(From, Invitation, Lang, StateData) ->
type = normal, type = normal,
body = xmpp:mk_text(Body), body = xmpp:mk_text(Body),
sub_els = [XUser, XConference]}, sub_els = [XUser, XConference]},
ejabberd_hooks:run(muc_invite, StateData#state.server_host, Msg2 = ejabberd_hooks:run_fold(muc_invite,
[StateData#state.jid, StateData#state.config, StateData#state.server_host,
From, JID, Reason]), Msg,
ejabberd_router:route(Msg), [StateData#state.jid, StateData#state.config,
From, JID, Reason, Pkt]),
ejabberd_router:route(Msg2),
JID. JID.
%% Handle a message sent to the room by a non-participant. %% Handle a message sent to the room by a non-participant.