Przeglądaj źródła

feat(prosody): Updates checks in presence_identity avoids setting missing user.

factor2
damencho 4 miesięcy temu
rodzic
commit
dc908512f9

+ 5
- 8
resources/prosody-plugins/mod_presence_identity.lua Wyświetl plik

@@ -5,16 +5,13 @@ local update_presence_identity = module:require "util".update_presence_identity;
5 5
 -- values are set in the session, then insert them into the presence messages
6 6
 -- for that session.
7 7
 function on_message(event)
8
-    if event and event["stanza"] then
9
-      if event.origin and event.origin.jitsi_meet_context_user then
10
-
8
+    local stanza, session = event.stanza, event.origin;
9
+    if stanza and session then
11 10
           update_presence_identity(
12
-              event.stanza,
13
-              event.origin.jitsi_meet_context_user,
14
-              event.origin.jitsi_meet_context_group
11
+              stanza,
12
+              session.jitsi_meet_context_user,
13
+              session.jitsi_meet_context_group
15 14
           );
16
-
17
-      end
18 15
     end
19 16
 end
20 17
 

+ 6
- 3
resources/prosody-plugins/util.lib.lua Wyświetl plik

@@ -208,8 +208,7 @@ end
208 208
 -- @param creator_group the group of the user who created the user which
209 209
 -- presence we are updating (this is the poltergeist case, where a user creates
210 210
 -- a poltergeist), optional.
211
-function update_presence_identity(
212
-    stanza, user, group, creator_user, creator_group)
211
+function update_presence_identity(stanza, user, group, creator_user, creator_group)
213 212
 
214 213
     -- First remove any 'identity' element if it already
215 214
     -- exists, so it cannot be spoofed by a client
@@ -222,7 +221,11 @@ function update_presence_identity(
222 221
             end
223 222
             return tag
224 223
         end
225
-    )
224
+    );
225
+
226
+    if not user then
227
+        return;
228
+    end
226 229
 
227 230
     stanza:tag("identity"):tag("user");
228 231
     for k, v in pairs(user) do

Ładowanie…
Anuluj
Zapisz