Parcourir la source

Adds initial status param when creating poltergeist.

j8
damencho il y a 7 ans
Parent
révision
284b5f94b5
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8
    2
      resources/prosody-plugins/mod_muc_poltergeist.lua

+ 8
- 2
resources/prosody-plugins/mod_muc_poltergeist.lua Voir le fichier

@@ -134,7 +134,8 @@ end);
134 134
 -- @param nick the nick to use for the new occupant
135 135
 -- @param name the display name fot the occupant (optional)
136 136
 -- @param avatar the avatar to use for the new occupant (optional)
137
-function create_poltergeist_occupant(room, nick, name, avatar)
137
+-- @param status the initial status to use for the new occupant (optional)
138
+function create_poltergeist_occupant(room, nick, name, avatar, status)
138 139
     log("debug", "create_poltergeist_occupant %s:", nick);
139 140
     -- Join poltergeist occupant to room, with the invited JID as their nick
140 141
     local join_presence = st.presence({
@@ -150,6 +151,9 @@ function create_poltergeist_occupant(room, nick, name, avatar)
150 151
     if (avatar) then
151 152
         join_presence:tag("avatar-url"):text(avatar):up();
152 153
     end
154
+    if (status) then
155
+        join_presence:tag("status"):text(status):up();
156
+    end
153 157
 
154 158
     room:handle_first_presence(
155 159
         prosody.hosts[poltergeist_component], join_presence);
@@ -247,6 +251,7 @@ function handle_create_poltergeist (event)
247 251
     local group = params["group"];
248 252
     local name = params["name"];
249 253
     local avatar = params["avatar"];
254
+    local status = params["status"];
250 255
 
251 256
     local room = get_room(room_name, group);
252 257
     if (not room) then
@@ -257,7 +262,8 @@ function handle_create_poltergeist (event)
257 262
     local username = generate_uuid();
258 263
     store_username(room, user_id, username)
259 264
 
260
-    create_poltergeist_occupant(room, string.sub(username,0,8), name, avatar);
265
+    create_poltergeist_occupant(
266
+        room, string.sub(username,0,8), name, avatar, status);
261 267
 
262 268
     return 200;
263 269
 end

Chargement…
Annuler
Enregistrer