Browse Source

Added module for filtering transcription requests from presence stanz… (#6404)

* Added module for filtering transcription requests from presence stanzas when the users making the requests do not have access to the transcription feature

* Add comments explaining the functionality and configuration for the transcription filtering module.

Co-authored-by: drimovecz <daniel.rimovecz@8x8.com>
j8
drimovecz 5 years ago
parent
commit
3ab6b97b8b
No account linked to committer's email address
1 changed files with 31 additions and 0 deletions
  1. 31
    0
      resources/prosody-plugins/mod_muc_transcription_filter.lua

+ 31
- 0
resources/prosody-plugins/mod_muc_transcription_filter.lua View File

@@ -0,0 +1,31 @@
1
+--This module performs features checking when a transcription is requested.
2
+--If the transcription feature is not allowed, the tag indicating that a
3
+--transcription is being requested will be stripped from the presence stanza.
4
+--The module must be enabled under the muc component.
5
+local is_feature_allowed = module:require "util".is_feature_allowed;
6
+
7
+module:log("info", "Loading mod_muc_transcription_filter!");
8
+local filtered_tag_name = "jitsi_participant_requestingTranscription";
9
+
10
+function filter_transcription_tag(event)
11
+    local stanza = event.stanza;
12
+    local session = event.origin;
13
+    if stanza and stanza.name == "presence" then
14
+        if not is_feature_allowed(session,'transcription') then
15
+            stanza:maptags(function(tag)
16
+                if tag and tag.name == filtered_tag_name then
17
+                    module:log("info", "Removing %s tag from presence stanza!", filtered_tag_name);
18
+                    return nil;
19
+                else
20
+                    return tag;
21
+                end
22
+            end)
23
+        end
24
+    end
25
+end
26
+
27
+module:hook("presence/bare", filter_transcription_tag);
28
+module:hook("presence/full", filter_transcription_tag);
29
+module:hook("presence/host", filter_transcription_tag);
30
+
31
+module:log("info", "Loaded mod_muc_transcription_filter!");

Loading…
Cancel
Save