]> granicus.if.org Git - ejabberd/commitdiff
Rely on core routine for handling affiliation changes (thanks to Ben Langfeld)
authorBadlop <badlop@process-one.net>
Mon, 27 Apr 2015 15:00:22 +0000 (17:00 +0200)
committerBadlop <badlop@process-one.net>
Mon, 27 Apr 2015 15:00:22 +0000 (17:00 +0200)
This ensures that all of the usual stanzas and such go out

src/mod_muc_admin.erl

index 9c69628bec13dcbcb3490fde4afe388ce21657d3..dee50650cc8687d6efa1fb3c3c4f2c5b4971e627 100644 (file)
@@ -825,23 +825,13 @@ set_room_affiliation(Name, Service, JID, AffiliationString) ->
        [R] ->
            %% Get the PID for the online room so we can get the state of the room
            Pid = R#muc_online_room.pid,
-           {ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, get_state),
-           SJID = jlib:string_to_jid(JID),
-           LJID = jlib:jid_remove_resource(jlib:jid_tolower(SJID)),
-           Affiliations = change_affiliation(Affiliation, LJID, StateData#state.affiliations),
-           Res = StateData#state{affiliations = Affiliations},
-           {ok, _State} = gen_fsm:sync_send_all_state_event(Pid, {change_state, Res}),
-           mod_muc:store_room(Res#state.server_host, Res#state.host, Res#state.room, make_opts(Res)),
+           {ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jlib:string_to_jid(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
+           mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)),
            ok;
        [] ->
            error
     end.
 
-change_affiliation(none, LJID, Affiliations) ->
-    ?DICT:erase(LJID, Affiliations);
-change_affiliation(Affiliation, LJID, Affiliations) ->
-    ?DICT:store(LJID, Affiliation, Affiliations).
-
 -define(MAKE_CONFIG_OPT(Opt), {Opt, Config#config.Opt}).
 
 make_opts(StateData) ->