aboutsummaryrefslogtreecommitdiff
path: root/src/mod_muc.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_muc.erl')
-rw-r--r--src/mod_muc.erl21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/mod_muc.erl b/src/mod_muc.erl
index 1aa48291c..68f031a58 100644
--- a/src/mod_muc.erl
+++ b/src/mod_muc.erl
@@ -39,6 +39,7 @@
reload/3,
room_destroyed/4,
store_room/4,
+ store_room/5,
restore_room/3,
forget_room/3,
create_room/5,
@@ -88,7 +89,7 @@
-type muc_room_opts() :: [{atom(), any()}].
-callback init(binary(), gen_mod:opts()) -> any().
-callback import(binary(), binary(), [binary()]) -> ok.
--callback store_room(binary(), binary(), binary(), list()) -> {atomic, any()}.
+-callback store_room(binary(), binary(), binary(), list(), list()|undefined) -> {atomic, any()}.
-callback restore_room(binary(), binary(), binary()) -> muc_room_opts() | error.
-callback forget_room(binary(), binary(), binary()) -> {atomic, any()}.
-callback can_use_nick(binary(), binary(), jid(), binary()) -> boolean().
@@ -105,6 +106,8 @@
-callback unregister_online_user(binary(), ljid(), binary(), binary()) -> any().
-callback count_online_rooms_by_user(binary(), binary(), binary()) -> non_neg_integer().
-callback get_online_rooms_by_user(binary(), binary(), binary()) -> [{binary(), binary()}].
+-callback get_subscribed_rooms(binary(), binary(), jid()) ->
+ {ok, [{ljid(), binary(), [binary()]}]} | {error, any()}.
%%====================================================================
%% API
@@ -157,9 +160,12 @@ create_room(Host, Name, From, Nick, Opts) ->
gen_server:call(Proc, {create, Name, Host, From, Nick, Opts}).
store_room(ServerHost, Host, Name, Opts) ->
+ store_room(ServerHost, Host, Name, Opts, undefined).
+
+store_room(ServerHost, Host, Name, Opts, ChangesHints) ->
LServer = jid:nameprep(ServerHost),
Mod = gen_mod:db_mod(LServer, ?MODULE),
- Mod:store_room(LServer, Host, Name, Opts).
+ Mod:store_room(LServer, Host, Name, Opts, ChangesHints).
restore_room(ServerHost, Host, Name) ->
LServer = jid:nameprep(ServerHost),
@@ -696,8 +702,12 @@ get_room_disco_item({Name, Host, Pid}, Query) ->
end.
get_subscribed_rooms(ServerHost, Host, From) ->
- Rooms = get_online_rooms(ServerHost, Host),
+ LServer = jid:nameprep(ServerHost),
+ Mod = gen_mod:db_mod(LServer, ?MODULE),
BareFrom = jid:remove_resource(From),
+ case Mod:get_subscribed_rooms(LServer, Host, BareFrom) of
+ not_implmented ->
+ Rooms = get_online_rooms(ServerHost, Host),
lists:flatmap(
fun({Name, _, Pid}) ->
case p1_fsm:sync_send_all_state_event(Pid, {is_subscribed, BareFrom}) of
@@ -706,7 +716,10 @@ get_subscribed_rooms(ServerHost, Host, From) ->
end;
(_) ->
[]
- end, Rooms).
+ end, Rooms);
+ V ->
+ V
+ end.
get_nick(ServerHost, Host, From) ->
LServer = jid:nameprep(ServerHost),