Software /
code /
prosody
Annotate
plugins/muc/request.lib.lua @ 13014:06453c564141
util.startup: Add prosody.started promise to easily execute code after startup
To avoid a race where server-started fires before the promise function body is
run (on next tick), I moved server-started to fire on the next tick, which
seems sensible anyway.
Errors are logged, I'm not sure if we ought to be doing something more here.
I'm sure we'll find out.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 01 Apr 2023 11:56:38 +0100 |
parent | 12977:74b9e05af71e |
rev | line source |
---|---|
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
1 -- Prosody IM |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
4 -- Copyright (C) 2014 Daurnimator |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
5 -- |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
6 -- This project is MIT/X11 licensed. Please see the |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
7 -- COPYING file in the source package for more information. |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
8 -- |
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
9 |
12977
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
9703
diff
changeset
|
10 local st = require "prosody.util.stanza"; |
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
9703
diff
changeset
|
11 local jid_resource = require "prosody.util.jid".resource; |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
12 |
8871
b67a861e883e
MUC: Advertise support for voice requests
Kim Alvefur <zash@zash.se>
parents:
8865
diff
changeset
|
13 module:hook("muc-disco#info", function(event) |
b67a861e883e
MUC: Advertise support for voice requests
Kim Alvefur <zash@zash.se>
parents:
8865
diff
changeset
|
14 event.reply:tag("feature", {var = "http://jabber.org/protocol/muc#request"}):up(); |
b67a861e883e
MUC: Advertise support for voice requests
Kim Alvefur <zash@zash.se>
parents:
8865
diff
changeset
|
15 end); |
b67a861e883e
MUC: Advertise support for voice requests
Kim Alvefur <zash@zash.se>
parents:
8865
diff
changeset
|
16 |
12977
74b9e05af71e
plugins: Prefix module imports with prosody namespace
Kim Alvefur <zash@zash.se>
parents:
9703
diff
changeset
|
17 local voice_request_form = require "prosody.util.dataforms".new({ |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
18 title = "Voice Request"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
19 { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
20 name = "FORM_TYPE"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
21 type = "hidden"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
22 value = "http://jabber.org/protocol/muc#request"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
23 }, |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
24 { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
25 name = "muc#jid"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
26 type = "jid-single"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
27 label = "User ID"; |
9034
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
8871
diff
changeset
|
28 desc = "The user's JID (address)"; |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
29 }, |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
30 { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
31 name = "muc#roomnick"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
32 type = "text-single"; |
9034
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
8871
diff
changeset
|
33 label = "Room nickname"; |
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
8871
diff
changeset
|
34 desc = "The user's nickname within the room"; |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
35 }, |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
36 { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
37 name = "muc#role"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
38 type = "list-single"; |
9034
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
8871
diff
changeset
|
39 label = "Requested role"; |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
40 value = "participant"; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
41 options = { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
42 "none", |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
43 "visitor", |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
44 "participant", |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
45 "moderator", |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
46 }; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
47 }, |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
48 { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
49 name = "muc#request_allow"; |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
50 type = "boolean"; |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
51 label = "Grant voice to this person?"; |
9034
1c709e3d2e5e
MUC: Improve labels of all config form items
Matthew Wild <mwild1@gmail.com>
parents:
8871
diff
changeset
|
52 desc = "Specify whether this person is able to speak in a moderated room"; |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
53 value = false; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
54 } |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
55 }); |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
56 |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
57 local function handle_request(room, origin, stanza, form) |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
58 local occupant = room:get_occupant_by_real_jid(stanza.attr.from); |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
59 local fields = voice_request_form:data(form); |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
60 local event = { |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
61 room = room; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
62 origin = origin; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
63 stanza = stanza; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
64 fields = fields; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
65 occupant = occupant; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
66 }; |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
67 if occupant.role == "moderator" then |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
68 module:log("debug", "%s responded to a voice request in %s", jid_resource(occupant.nick), room.jid); |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
69 module:fire_event("muc-voice-response", event); |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
70 else |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
71 module:log("debug", "%s requested voice in %s", jid_resource(occupant.nick), room.jid); |
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
72 module:fire_event("muc-voice-request", event); |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
73 end |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
74 end |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
75 |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
76 module:hook("muc-voice-request", function(event) |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
77 if event.occupant.role == "visitor" then |
8854
5cd7813d4e94
MUC: Split out the nickname from the full room JID in voice request from
Kim Alvefur <zash@zash.se>
parents:
8853
diff
changeset
|
78 local nick = jid_resource(event.occupant.nick); |
8853
f84f566dea58
MUC: Reuse the same dataform for voice requests
Kim Alvefur <zash@zash.se>
parents:
8852
diff
changeset
|
79 local formdata = { |
f84f566dea58
MUC: Reuse the same dataform for voice requests
Kim Alvefur <zash@zash.se>
parents:
8852
diff
changeset
|
80 ["muc#jid"] = event.stanza.attr.from; |
8854
5cd7813d4e94
MUC: Split out the nickname from the full room JID in voice request from
Kim Alvefur <zash@zash.se>
parents:
8853
diff
changeset
|
81 ["muc#roomnick"] = nick; |
8853
f84f566dea58
MUC: Reuse the same dataform for voice requests
Kim Alvefur <zash@zash.se>
parents:
8852
diff
changeset
|
82 }; |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
83 |
9081
ce57c69a20e2
MUC: Split long lines [luacheck strict]
Kim Alvefur <zash@zash.se>
parents:
9034
diff
changeset
|
84 local message = st.message({ type = "normal"; from = event.room.jid }) |
9703
0cfb7b3593eb
MUC: Fix traceback when requesting voice (fixes #1269) (thanks jonas’)
Kim Alvefur <zash@zash.se>
parents:
9081
diff
changeset
|
85 :add_child(voice_request_form:form(formdata)); |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
86 |
8852
5e98d62f3f9b
MUC: Ignore unused argumens [luacheck]
Kim Alvefur <zash@zash.se>
parents:
8851
diff
changeset
|
87 event.room:broadcast(message, function (_, occupant) |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
88 return occupant.role == "moderator"; |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
89 end); |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
90 end |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
91 end); |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
92 |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
93 module:hook("muc-voice-response", function(event) |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
94 local actor = event.stanza.attr.from; |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
95 local affected_occupant = event.room:get_occupant_by_real_jid(event.fields["muc#jid"]); |
8857
f4cc818db995
MUC: Get acting occupant into a local variable for easier access
Kim Alvefur <zash@zash.se>
parents:
8854
diff
changeset
|
96 local occupant = event.occupant; |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
97 |
8857
f4cc818db995
MUC: Get acting occupant into a local variable for easier access
Kim Alvefur <zash@zash.se>
parents:
8854
diff
changeset
|
98 if occupant.role ~= "moderator" then |
8859
11176f47a03a
MUC: Add some debug logging for voice requests
Kim Alvefur <zash@zash.se>
parents:
8858
diff
changeset
|
99 module:log("debug", "%s tried to grant voice but wasn't a moderator", jid_resource(occupant.nick)); |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
100 return; |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
101 end |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
102 |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
103 if not event.fields["muc#request_allow"] then |
8859
11176f47a03a
MUC: Add some debug logging for voice requests
Kim Alvefur <zash@zash.se>
parents:
8858
diff
changeset
|
104 module:log("debug", "%s did not grant voice", jid_resource(occupant.nick)); |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
105 return; |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
106 end |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
107 |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
108 if not affected_occupant then |
9081
ce57c69a20e2
MUC: Split long lines [luacheck strict]
Kim Alvefur <zash@zash.se>
parents:
9034
diff
changeset
|
109 module:log("debug", "%s tried to grant voice to unknown occupant %s", |
ce57c69a20e2
MUC: Split long lines [luacheck strict]
Kim Alvefur <zash@zash.se>
parents:
9034
diff
changeset
|
110 jid_resource(occupant.nick), event.fields["muc#jid"]); |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
111 return; |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
112 end |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
113 |
8858
2096742859c1
MUC: Invert final conditional to be consistent with the other if statements
Kim Alvefur <zash@zash.se>
parents:
8857
diff
changeset
|
114 if affected_occupant.role ~= "visitor" then |
9081
ce57c69a20e2
MUC: Split long lines [luacheck strict]
Kim Alvefur <zash@zash.se>
parents:
9034
diff
changeset
|
115 module:log("debug", "%s tried to grant voice to %s but they already have it", |
ce57c69a20e2
MUC: Split long lines [luacheck strict]
Kim Alvefur <zash@zash.se>
parents:
9034
diff
changeset
|
116 jid_resource(occupant.nick), jid_resource(occupant.jid)); |
8858
2096742859c1
MUC: Invert final conditional to be consistent with the other if statements
Kim Alvefur <zash@zash.se>
parents:
8857
diff
changeset
|
117 return; |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
118 end |
8858
2096742859c1
MUC: Invert final conditional to be consistent with the other if statements
Kim Alvefur <zash@zash.se>
parents:
8857
diff
changeset
|
119 |
8860
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
120 module:log("debug", "%s granted voice to %s", jid_resource(event.occupant.nick), jid_resource(occupant.jid)); |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
121 local ok, errtype, err = event.room:set_role(actor, affected_occupant.nick, "participant", "Voice granted"); |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
122 |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
123 if not ok then |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
124 module:log("debug", "Error granting voice: %s", err or errtype); |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
125 event.origin.send(st.error_reply(event.stanza, errtype, err)); |
0bb46a1bb398
MUC: Handle and return error in role change when granting voice
Kim Alvefur <zash@zash.se>
parents:
8859
diff
changeset
|
126 end |
8851
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
127 end); |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
128 |
ab5f678f1376
MUC: Support MUC voice requests and approvals in moderated rooms (closes #655) (thanks to Lance Stout)
Kim Alvefur <zash@zash.se>
parents:
7401
diff
changeset
|
129 |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
130 return { |
8865
2a8bbfcb6868
MUC: Move voice request into its own lib
Kim Alvefur <zash@zash.se>
parents:
8860
diff
changeset
|
131 handle_request = handle_request; |
6226
7582deb85812
plugins/muc: Move 'moderated' code to seperate file; changes default "muc-get-default-role" behaviour
daurnimator <quae@daurnimator.com>
parents:
diff
changeset
|
132 }; |