From 43da45cf67c7646144541b179978df090b2d1c6d Mon Sep 17 00:00:00 2001 From: Evgeny Khramtsov Date: Tue, 9 Jul 2019 15:21:17 +0300 Subject: [PATCH] Improve type specs of mod_muc_room --- src/mod_muc_room.erl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 718038470..a082a7867 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -92,6 +92,7 @@ -type fsm_next() :: {next_state, normal_state, state()}. -type fsm_transition() :: fsm_stop() | fsm_next(). -type disco_item_filter() :: only_non_empty | all | non_neg_integer(). +-type admin_action() :: {jid(), affiliation | role, affiliation() | role(), binary()}. -export_type([state/0, disco_item_filter/0]). -callback set_affiliation(binary(), binary(), binary(), jid(), affiliation(), @@ -1827,6 +1828,7 @@ update_online_user(JID, #user{nick = Nick} = User, StateData) -> end, NewStateData. +-spec set_subscriber(jid(), binary(), [binary()], state()) -> state(). set_subscriber(JID, Nick, Nodes, #state{room = Room, host = Host, server_host = ServerHost} = StateData) -> BareJID = jid:remove_resource(JID), @@ -2856,7 +2858,8 @@ process_admin_items_set(UJID, Items, Lang, StateData) -> {error, Err} -> {error, Err} end. --spec process_item_change(jid()) -> function(). +-spec process_item_change(jid()) -> fun((admin_action(), state() | {error, stanza_error()}) -> + state() | {error, stanza_error()}). process_item_change(UJID) -> fun(_, {error, _} = Err) -> Err; @@ -2864,9 +2867,6 @@ process_item_change(UJID) -> process_item_change(Item, SD, UJID) end. --type admin_action() :: {jid(), affiliation | role, - affiliation() | role(), binary()}. - -spec process_item_change(admin_action(), state(), undefined | jid()) -> state() | {error, stanza_error()}. process_item_change(Item, SD, UJID) -> try case Item of @@ -3955,6 +3955,7 @@ destroy_room(DEl, StateData) -> maybe_forget_room(StateData), {result, undefined, stop}. +-spec maybe_forget_room(state()) -> state(). maybe_forget_room(StateData) -> Forget = case (StateData#state.config)#config.persistent of true -> @@ -4263,6 +4264,7 @@ process_iq_mucsub(_From, #iq{type = get, lang = Lang}, _StateData) -> Txt = ?T("Value 'get' of 'type' attribute is not allowed"), {error, xmpp:err_bad_request(Txt, Lang)}. +-spec remove_subscriptions(state()) -> state(). remove_subscriptions(StateData) -> if not (StateData#state.config)#config.allow_subscription -> StateData#state{subscribers = #{}, -- 2.40.0