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

Update roster_get hook in mod_shared_roster_ldap to use #roster_item{}

This commit is contained in:
Paweł Chmielowski 2022-08-24 11:14:32 +02:00
parent a9e85674b8
commit cfc8746d29

View File

@ -112,29 +112,20 @@ depends(_Host, _Opts) ->
-spec get_user_roster([#roster_item{}], {binary(), binary()}) -> [#roster_item{}].
get_user_roster(Items, US) ->
SRUsers = get_user_to_groups_map(US, true),
{NewItems1, SRUsersRest} = lists:mapfoldl(fun (Item,
SRUsers1) ->
{_, _, {U1, S1, _}} =
Item#roster.usj,
US1 = {U1, S1},
case dict:find(US1,
SRUsers1)
of
{ok, GroupNames} ->
{Item#roster{subscription
=
both,
groups =
Item#roster.groups ++ GroupNames,
ask =
none},
dict:erase(US1,
SRUsers1)};
error ->
{Item, SRUsers1}
end
end,
SRUsers, Items),
{NewItems1, SRUsersRest} = lists:mapfoldl(
fun(Item = #roster_item{jid = #jid{luser = U1, lserver = S1}}, SRUsers1) ->
US1 = {U1, S1},
case dict:find(US1, SRUsers1) of
{ok, GroupNames} ->
{Item#roster_item{subscription = both,
groups = Item#roster_item.groups ++ GroupNames,
ask = none},
dict:erase(US1, SRUsers1)};
error ->
{Item, SRUsers1}
end
end,
SRUsers, Items),
SRItems = [#roster_item{jid = jid:make(U1, S1),
name = get_user_name(U1, S1), subscription = both,
ask = undefined, groups = GroupNames}