diff options
author | Kim Alvefur <zash@zash.se> | 2017-10-20 05:45:40 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2017-10-20 05:45:40 +0200 |
commit | e8da4ca6d9798aa7058dc617dae0ef4f13cff656 (patch) | |
tree | 06ea200ca9ee28b35653af9c6b913477b282e558 /plugins/muc | |
parent | 417ba80c531904888fc06af63aa374aea737ea0f (diff) | |
download | prosody-e8da4ca6d9798aa7058dc617dae0ef4f13cff656.tar.gz prosody-e8da4ca6d9798aa7058dc617dae0ef4f13cff656.zip |
MUC: Reuse the same dataform for voice requests
Diffstat (limited to 'plugins/muc')
-rw-r--r-- | plugins/muc/moderated.lib.lua | 43 | ||||
-rw-r--r-- | plugins/muc/muc.lib.lua | 7 |
2 files changed, 14 insertions, 36 deletions
diff --git a/plugins/muc/moderated.lib.lua b/plugins/muc/moderated.lib.lua index 4d060a9d..c6ccc771 100644 --- a/plugins/muc/moderated.lib.lua +++ b/plugins/muc/moderated.lib.lua @@ -8,8 +8,6 @@ -- local st = require "util.stanza"; -local dataform = require "util.dataforms"; - local function get_moderated(room) return room._data.moderated; @@ -51,40 +49,13 @@ end, 1); module:hook("muc-voice-request", function(event) if event.occupant.role == "visitor" then - local form = dataform.new({ - title = "Voice Request"; - { - name = "FORM_TYPE"; - type = "hidden"; - value = "http://jabber.org/protocol/muc#request"; - }, - { - name = "muc#role"; - type = "text-single"; - label = "Requested Role"; - value = "participant"; - }, - { - name = "muc#jid"; - type = "jid-single"; - label = "User ID"; - value = event.stanza.attr.from; - }, - { - name = "muc#roomnick"; - type = "text-single"; - label = "Room Nickname"; - value = event.occupant.nick; - }, - { - name = "muc#request_allow"; - type = "boolean"; - label = "Grant voice to this person?"; - value = false; - } - }); - - local message = st.message({ type = "normal"; from = event.room.jid }):add_child(form:form()):up(); + local form = event.room:get_voice_form_layout() + local formdata = { + ["muc#jid"] = event.stanza.attr.from; + ["muc#roomnick"] = event.occupant.nick; + }; + + local message = st.message({ type = "normal"; from = event.room.jid }):add_child(form:form(formdata)):up(); event.room:broadcast(message, function (_, occupant) return occupant.role == "moderator"; diff --git a/plugins/muc/muc.lib.lua b/plugins/muc/muc.lib.lua index 882d9734..f23e0ee7 100644 --- a/plugins/muc/muc.lib.lua +++ b/plugins/muc/muc.lib.lua @@ -780,6 +780,7 @@ end function room_mt:get_voice_form_layout() -- luacheck: ignore 212/self local form = dataform.new({ + title = "Voice Request"; { name = "FORM_TYPE"; type = "hidden"; @@ -788,18 +789,24 @@ function room_mt:get_voice_form_layout() -- luacheck: ignore 212/self { name = "muc#jid"; type = "jid-single"; + label = "User ID"; }, { name = "muc#roomnick"; type = "text-single"; + label = "Room Nickname"; }, { name = "muc#role"; type = "text-single"; + label = "Requested Role"; + value = "participant"; }, { name = "muc#request_allow"; type = "boolean"; + label = "Grant voice to this person?"; + value = false; } }); |