Software /
code /
prosody
Comparison
plugins/muc/moderated.lib.lua @ 8854:5cd7813d4e94
MUC: Split out the nickname from the full room JID in voice request from
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Oct 2017 21:24:07 +0200 |
parent | 8853:f84f566dea58 |
child | 8857:f4cc818db995 |
comparison
equal
deleted
inserted
replaced
8853:f84f566dea58 | 8854:5cd7813d4e94 |
---|---|
6 -- This project is MIT/X11 licensed. Please see the | 6 -- This project is MIT/X11 licensed. Please see the |
7 -- COPYING file in the source package for more information. | 7 -- COPYING file in the source package for more information. |
8 -- | 8 -- |
9 | 9 |
10 local st = require "util.stanza"; | 10 local st = require "util.stanza"; |
11 local jid_resource = require "util.jid".resource; | |
11 | 12 |
12 local function get_moderated(room) | 13 local function get_moderated(room) |
13 return room._data.moderated; | 14 return room._data.moderated; |
14 end | 15 end |
15 | 16 |
48 end, 1); | 49 end, 1); |
49 | 50 |
50 module:hook("muc-voice-request", function(event) | 51 module:hook("muc-voice-request", function(event) |
51 if event.occupant.role == "visitor" then | 52 if event.occupant.role == "visitor" then |
52 local form = event.room:get_voice_form_layout() | 53 local form = event.room:get_voice_form_layout() |
54 local nick = jid_resource(event.occupant.nick); | |
53 local formdata = { | 55 local formdata = { |
54 ["muc#jid"] = event.stanza.attr.from; | 56 ["muc#jid"] = event.stanza.attr.from; |
55 ["muc#roomnick"] = event.occupant.nick; | 57 ["muc#roomnick"] = nick; |
56 }; | 58 }; |
57 | 59 |
58 local message = st.message({ type = "normal"; from = event.room.jid }):add_child(form:form(formdata)):up(); | 60 local message = st.message({ type = "normal"; from = event.room.jid }):add_child(form:form(formdata)):up(); |
59 | 61 |
60 event.room:broadcast(message, function (_, occupant) | 62 event.room:broadcast(message, function (_, occupant) |