Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache affiliations key in the accumulator #3761

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/muc_light/mod_muc_light.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
%% for mod_muc_light_codec_legacy
-export([subdomain_pattern/1]).

-export([get_room_affs_from_acc/2, set_room_affs_from_acc/3]).

%% For tests
-export([default_schema/0,
force_clear_from_ct/1]).
Expand Down
7 changes: 3 additions & 4 deletions src/muc_light/mod_muc_light_cache.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
-include("mongoose_config_spec.hrl").

-behaviour(gen_mod).
-define(FRONTEND, mod_muc_light).

%% gen_mod callbacks
-export([start/2, stop/1, config_spec/0, supported_features/0]).
Expand Down Expand Up @@ -55,12 +54,12 @@ hooks(HostType) ->
-spec pre_acc_room_affiliations(mongoose_acc:t(), jid:jid()) ->
mongoose_acc:t() | {stop, mongoose_acc:t()}.
pre_acc_room_affiliations(Acc, RoomJid) ->
case mongoose_acc:get(?FRONTEND, affiliations, {error, not_exists}, Acc) of
case mod_muc_light:get_room_affs_from_acc(Acc, RoomJid) of
{error, _} ->
HostType = mongoose_acc:host_type(Acc),
case mongoose_user_cache:get_entry(HostType, ?MODULE, RoomJid) of
#{affs := Res} ->
mongoose_acc:set(?FRONTEND, affiliations, Res, Acc);
mod_muc_light:set_room_affs_from_acc(Acc, RoomJid, Res);
_ ->
Acc
end;
Expand All @@ -70,7 +69,7 @@ pre_acc_room_affiliations(Acc, RoomJid) ->

-spec post_acc_room_affiliations(mongoose_acc:t(), jid:jid()) -> mongoose_acc:t().
post_acc_room_affiliations(Acc, RoomJid) ->
case mongoose_acc:get(?FRONTEND, affiliations, {error, not_exists}, Acc) of
case mod_muc_light:get_room_affs_from_acc(Acc, RoomJid) of
{error, _} ->
Acc;
Res ->
Expand Down