How can I set an user with none affiliation directly to be a member when the user joins the room - Ejabberd

StackOverflow https://stackoverflow.com/questions/21353105

Question

I am customising the module mod_muc_room to automatically set the affiliation of an user to member when the user joins for the first time.

I am working on the method process_pressence, i manage to add the user in the configuration room of the mysql table mod_muc but the StateData does not contain this change.... how can I properly make this change available to the StateData.

I would like to know some pointers. I have tried many many method hacks but I just seem to get lost...thanks in advance

Was it helpful?

Solution

http://www.process-one.net/docs/ejabberd/guide_en.html#modmuc

How about setting members_by_default to true in default_room_options ?


edit:

I was confused about role and affiliation, and try following patch:

--- a/src/mod_muc_room.erl
+++ b/src/mod_muc_room.erl
@@ -1611,7 +1611,11 @@ add_online_user(JID, Nick, Role, StateData) ->
                           end,
                           [LJID], StateData#state.nicks),
     tab_add_online_user(JID, StateData),
-    StateData#state{users = Users, nicks = Nicks}.
+    StateData1 = case get_affiliation(JID, StateData) of
+        owner -> StateData;
+        _ -> set_affiliation(JID, member, StateData)
+    end,
+    StateData1#state{users = Users, nicks = Nicks}.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top