mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 17:59:31 +02:00
Merge pull request #3578 from tappytaps/srg-cache-fix
Fixed srg_create params and shared roster groups cache issues
This commit is contained in:
commit
2d38d48a55
2 changed files with 7 additions and 6 deletions
|
@ -664,7 +664,8 @@ get_commands_spec() ->
|
||||||
"name desc \\\"group1\\\\ngroup2\\\"",
|
"name desc \\\"group1\\\\ngroup2\\\"",
|
||||||
module = ?MODULE, function = srg_create,
|
module = ?MODULE, function = srg_create,
|
||||||
args = [{group, binary}, {host, binary},
|
args = [{group, binary}, {host, binary},
|
||||||
{name, binary}, {description, binary}, {display, binary}],
|
{label, binary}, {description, binary}, {display, binary}],
|
||||||
|
args_rename = [{name, label}],
|
||||||
args_example = [<<"group3">>, <<"myserver.com">>, <<"Group3">>,
|
args_example = [<<"group3">>, <<"myserver.com">>, <<"Group3">>,
|
||||||
<<"Third group">>, <<"group1\\\\ngroup2">>],
|
<<"Third group">>, <<"group1\\\\ngroup2">>],
|
||||||
args_desc = ["Group identifier", "Group server name", "Group name",
|
args_desc = ["Group identifier", "Group server name", "Group name",
|
||||||
|
@ -1456,12 +1457,12 @@ private_set2(Username, Host, Xml) ->
|
||||||
%%% Shared Roster Groups
|
%%% Shared Roster Groups
|
||||||
%%%
|
%%%
|
||||||
|
|
||||||
srg_create(Group, Host, Name, Description, Display) ->
|
srg_create(Group, Host, Label, Description, Display) ->
|
||||||
DisplayList = case Display of
|
DisplayList = case Display of
|
||||||
<<>> -> [];
|
<<>> -> [];
|
||||||
_ -> ejabberd_regexp:split(Display, <<"\\\\n">>)
|
_ -> ejabberd_regexp:split(Display, <<"\\\\n">>)
|
||||||
end,
|
end,
|
||||||
Opts = [{name, Name},
|
Opts = [{label, Label},
|
||||||
{displayed_groups, DisplayList},
|
{displayed_groups, DisplayList},
|
||||||
{description, Description}],
|
{description, Description}],
|
||||||
{atomic, _} = mod_shared_roster:create_group(Host, Group, Opts),
|
{atomic, _} = mod_shared_roster:create_group(Host, Group, Opts),
|
||||||
|
|
|
@ -713,14 +713,14 @@ add_user_to_group2(Host, US, Group) ->
|
||||||
push_user_to_displayed(LUser, LServer, Group, Host, both, DisplayedToGroups),
|
push_user_to_displayed(LUser, LServer, Group, Host, both, DisplayedToGroups),
|
||||||
push_displayed_to_user(LUser, LServer, Host, both, DisplayedGroups),
|
push_displayed_to_user(LUser, LServer, Host, both, DisplayedGroups),
|
||||||
Mod = gen_mod:db_mod(Host, ?MODULE),
|
Mod = gen_mod:db_mod(Host, ?MODULE),
|
||||||
|
Mod:add_user_to_group(Host, US, Group),
|
||||||
case use_cache(Mod, Host) of
|
case use_cache(Mod, Host) of
|
||||||
true ->
|
true ->
|
||||||
ets_cache:delete(?USER_GROUPS_CACHE, {Host, US}, cache_nodes(Mod, Host)),
|
ets_cache:delete(?USER_GROUPS_CACHE, {Host, US}, cache_nodes(Mod, Host)),
|
||||||
ets_cache:delete(?GROUP_EXPLICIT_USERS_CACHE, {Host, Group}, cache_nodes(Mod, Host));
|
ets_cache:delete(?GROUP_EXPLICIT_USERS_CACHE, {Host, Group}, cache_nodes(Mod, Host));
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end
|
||||||
Mod:add_user_to_group(Host, US, Group)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_displayed_groups(Group, LServer) ->
|
get_displayed_groups(Group, LServer) ->
|
||||||
|
@ -749,6 +749,7 @@ remove_user_from_group(Host, US, Group) ->
|
||||||
set_group_opts(Host, Group, NewGroupOpts);
|
set_group_opts(Host, Group, NewGroupOpts);
|
||||||
nomatch ->
|
nomatch ->
|
||||||
Mod = gen_mod:db_mod(Host, ?MODULE),
|
Mod = gen_mod:db_mod(Host, ?MODULE),
|
||||||
|
Result = Mod:remove_user_from_group(Host, US, Group),
|
||||||
case use_cache(Mod, Host) of
|
case use_cache(Mod, Host) of
|
||||||
true ->
|
true ->
|
||||||
ets_cache:delete(?USER_GROUPS_CACHE, {Host, US}, cache_nodes(Mod, Host)),
|
ets_cache:delete(?USER_GROUPS_CACHE, {Host, US}, cache_nodes(Mod, Host)),
|
||||||
|
@ -756,7 +757,6 @@ remove_user_from_group(Host, US, Group) ->
|
||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
Result = Mod:remove_user_from_group(Host, US, Group),
|
|
||||||
DisplayedToGroups = displayed_to_groups(Group, Host),
|
DisplayedToGroups = displayed_to_groups(Group, Host),
|
||||||
DisplayedGroups = get_displayed_groups(Group, LServer),
|
DisplayedGroups = get_displayed_groups(Group, LServer),
|
||||||
push_user_to_displayed(LUser, LServer, Group, Host, remove, DisplayedToGroups),
|
push_user_to_displayed(LUser, LServer, Group, Host, remove, DisplayedToGroups),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue