From 3bf0892c748739882a0a1830eead7e8b6dab5e75 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Mon, 20 Jun 2022 11:42:19 +0200 Subject: [PATCH] mod_mix_pam: Do roster pushes on join/leave Before the channels were added/removed from the database but the clients were not notified of it. --- src/mod_mix_pam.erl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mod_mix_pam.erl b/src/mod_mix_pam.erl index 9bf75d1ba..9491d217a 100644 --- a/src/mod_mix_pam.erl +++ b/src/mod_mix_pam.erl @@ -293,6 +293,18 @@ process_join_result(#iq{from = Channel, #iq{to = To} = IQ) -> case add_channel(To, Channel, ID) of ok -> + % Do roster push + #jid{luser = ChannelName, lserver = Service} = Channel, + mod_roster:push_item(To, #roster{}, #roster{ + jid = {ChannelName, Service, <<>>}, + name = <<>>, + subscription = none, + ask = none, + groups = [], + askmessage = <<>>, + mix_participant_id = ID + }), + % send IQ result ChanID = make_channel_id(Channel, ID), Join1 = Join#mix_join{id = <<"">>, jid = ChanID}, ResIQ = xmpp:make_iq_result(IQ, #mix_client_join{join = Join1}), @@ -304,7 +316,15 @@ process_join_result(Err, IQ) -> process_iq_error(Err, IQ). -spec process_leave_result(iq(), iq()) -> ok. -process_leave_result(#iq{type = result, sub_els = [#mix_leave{} = Leave]}, IQ) -> +process_leave_result(#iq{from = Channel, type = result, sub_els = [#mix_leave{} = Leave]}, + #iq{to = User} = IQ) -> + % Do roster push + #jid{luser = ChannelName, lserver = Service} = Channel, + mod_roster:push_item(User, + #roster{jid = {ChannelName, Service, <<>>}, subscription = none}, + #roster{jid = {ChannelName, Service, <<>>}, + subscription = remove}), + % send iq result ResIQ = xmpp:make_iq_result(IQ, #mix_client_leave{leave = Leave}), ejabberd_router:route(ResIQ); process_leave_result(Err, IQ) ->