diff options
author | Linus Jahn <lnj@kaidan.im> | 2022-07-16 23:23:48 +0200 |
---|---|---|
committer | badlop <badlop@gmail.com> | 2022-08-11 12:45:20 +0200 |
commit | d6b72f1c5dba891d6d1bb4a24bb297170b130a73 (patch) | |
tree | 8a7f2f8c097896001016b93480324c2107c3e9f0 /src/ejabberd_c2s.erl | |
parent | mod_roster: Respect MIX <annotate/> setting (diff) |
mod_roster: Change hook type from #roster{} to #roster_item{}
The problem with #roster{} is that every new record entry is also stored
in the mnesia roster table. Adding the mix_participant_id there makes
no sense because the normal roster items are no MIX channels. Using
\#roster_item{} for the hook and #roster{} for storing the normal items
seems to be a better idea.
Diffstat (limited to 'src/ejabberd_c2s.erl')
-rw-r--r-- | src/ejabberd_c2s.erl | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 6f103894..ec5c610e 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -777,9 +777,9 @@ broadcast_presence_unavailable(#{jid := JID, pres_a := PresA} = State, Pres, Roster = ejabberd_hooks:run_fold(roster_get, LServer, [], [{LUser, LServer}]), lists:foldl( - fun(#roster{jid = LJID, subscription = Sub}, Acc) + fun(#roster_item{jid = ItemJID, subscription = Sub}, Acc) when Sub == both; Sub == from -> - maps:put(LJID, 1, Acc); + maps:put(jid:tolower(ItemJID), 1, Acc); (_, Acc) -> Acc end, #{BareJID => 1}, Roster); @@ -813,8 +813,7 @@ broadcast_presence_available(#{jid := JID} = State, [], [{LUser, LServer}]), {FJIDs, TJIDs} = lists:foldl( - fun(#roster{jid = LJID, subscription = Sub}, {F, T}) -> - To = jid:make(LJID), + fun(#roster_item{jid = To, subscription = Sub}, {F, T}) -> F1 = if Sub == both orelse Sub == from -> Pres1 = xmpp:set_to(Pres, To), case privacy_check_packet(State, Pres1, out) of @@ -843,10 +842,9 @@ broadcast_presence_available(#{jid := JID} = State, Items = ejabberd_hooks:run_fold( roster_get, LServer, [], [{LUser, LServer}]), JIDs = lists:foldl( - fun(#roster{jid = LJID, subscription = Sub}, Tos) + fun(#roster_item{jid = To, subscription = Sub}, Tos) when Sub == both orelse Sub == from -> - To = jid:make(LJID), - P = xmpp:set_to(Pres, jid:make(LJID)), + P = xmpp:set_to(Pres, To), case privacy_check_packet(State, P, out) of allow -> [To|Tos]; deny -> Tos |