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/mod_shared_roster.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/mod_shared_roster.erl')
-rw-r--r-- | src/mod_shared_roster.erl | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 333a64a4..067d4504 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -185,8 +185,8 @@ cache_nodes(Mod, Host) -> false -> ejabberd_cluster:get_nodes() end. --spec get_user_roster([#roster{}], {binary(), binary()}) -> [#roster{}]. -get_user_roster(Items, {U, S} = US) -> +-spec get_user_roster([#roster_item{}], {binary(), binary()}) -> [#roster_item{}]. +get_user_roster(Items, {_, S} = US) -> {DisplayedGroups, Cache} = get_user_displayed_groups(US), SRUsers = lists:foldl( fun(Group, Acc1) -> @@ -216,10 +216,10 @@ get_user_roster(Items, {U, S} = US) -> end end, SRUsers, Items), - SRItems = [#roster{usj = {U, S, {U1, S1, <<"">>}}, - us = US, jid = {U1, S1, <<"">>}, - name = get_rosteritem_name(U1, S1), - subscription = both, ask = none, groups = GroupLabels} + SRItems = [#roster_item{jid = jid:make(U1, S1), + name = get_rosteritem_name(U1, S1), + subscription = both, ask = undefined, + groups = GroupLabels} || {{U1, S1}, GroupLabels} <- dict:to_list(SRUsersRest)], SRItems ++ NewItems1. @@ -855,16 +855,14 @@ displayed_to_groups(GroupName, LServer) -> push_item(User, Server, Item) -> mod_roster:push_item(jid:make(User, Server), - Item#roster{subscription = none}, + Item#roster_item{subscription = none}, Item). push_roster_item(User, Server, ContactU, ContactS, ContactN, GroupLabel, Subscription) -> - Item = #roster{usj = - {User, Server, {ContactU, ContactS, <<"">>}}, - us = {User, Server}, jid = {ContactU, ContactS, <<"">>}, - name = ContactN, subscription = Subscription, ask = none, - groups = [GroupLabel]}, + Item = #roster_item{jid = jid:make(ContactU, ContactS), + name = ContactN, subscription = Subscription, ask = undefined, + groups = [GroupLabel]}, push_item(User, Server, Item). -spec c2s_self_presence({presence(), ejabberd_c2s:state()}) |