ソースを参照

fix(system_chat_message): Fixes delivering system messages to visitors.

factor2
damencho 1年前
コミット
205f88ec5a
1個のファイルの変更12行の追加0行の削除
  1. 12
    0
      resources/prosody-plugins/mod_fmuc.lua

+ 12
- 0
resources/prosody-plugins/mod_fmuc.lua ファイルの表示

16
 local filters = require 'util.filters';
16
 local filters = require 'util.filters';
17
 
17
 
18
 local util = module:require 'util';
18
 local util = module:require 'util';
19
+local ends_with = util.ends_with;
19
 local is_vpaas = util.is_vpaas;
20
 local is_vpaas = util.is_vpaas;
20
 local room_jid_match_rewrite = util.room_jid_match_rewrite;
21
 local room_jid_match_rewrite = util.room_jid_match_rewrite;
21
 local get_room_from_jid = util.get_room_from_jid;
22
 local get_room_from_jid = util.get_room_from_jid;
359
         process_host(name);
360
         process_host(name);
360
     end
361
     end
361
 end
362
 end
363
+-- if the message received ends with the main domain, these are system messages
364
+-- for visitors, let's correct the room name there
365
+local function message_handler(event)
366
+    local origin, stanza = event.origin, event.stanza;
367
+
368
+    if ends_with(stanza.attr.from, main_domain) then
369
+        stanza.attr.from = stanza.attr.from:sub(1, -(main_domain:len() + 1))..local_domain;
370
+    end
371
+end
372
+
362
 process_host_module(local_domain, function(host_module, host)
373
 process_host_module(local_domain, function(host_module, host)
363
     host_module:hook('iq/host', stanza_handler, 10);
374
     host_module:hook('iq/host', stanza_handler, 10);
375
+    host_module:hook('message/full', message_handler);
364
 end);
376
 end);
365
 
377
 
366
 -- only live chat is supported for visitors
378
 -- only live chat is supported for visitors

読み込み中…
キャンセル
保存