Software / code / prosody
Annotate
plugins/muc/request.lib.lua @ 13801:a5d5fefb8b68 13.0
mod_tls: Enable Prosody's certificate checking for incoming s2s connections (fixes #1916) (thanks Damian, Zash)
Various options in Prosody allow control over the behaviour of the certificate
verification process For example, some deployments choose to allow falling
back to traditional "dialback" authentication (XEP-0220), while others verify
via DANE, hard-coded fingerprints, or other custom plugins.
Implementing this flexibility requires us to override OpenSSL's default
certificate verification, to allow Prosody to verify the certificate itself,
apply custom policies and make decisions based on the outcome.
To enable our custom logic, we have to suppress OpenSSL's default behaviour of
aborting the connection with a TLS alert message. With LuaSec, this can be
achieved by using the verifyext "lsec_continue" flag.
We also need to use the lsec_ignore_purpose flag, because XMPP s2s uses server
certificates as "client" certificates (for mutual TLS verification in outgoing
s2s connections).
Commit 99d2100d2918 moved these settings out of the defaults and into mod_s2s,
because we only really need these changes for s2s, and they should be opt-in,
rather than automatically applied to all TLS services we offer.
That commit was incomplete, because it only added the flags for incoming
direct TLS connections. StartTLS connections are handled by mod_tls, which was
not applying the lsec_* flags. It previously worked because they were already
in the defaults.
This resulted in incoming s2s connections with "invalid" certificates being
aborted early by OpenSSL, even if settings such as `s2s_secure_auth = false`
or DANE were present in the config.
Outgoing s2s connections inherit verify "none" from the defaults, which means
OpenSSL will receive the cert but will not terminate the connection when it is
deemed invalid. This means we don't need lsec_continue there, and we also
don't need lsec_ignore_purpose (because the remote peer is a "server").
Wondering why we can't just use verify "none" for incoming s2s? It's because
in that mode, OpenSSL won't request a certificate from the peer for incoming
connections. Setting verify "peer" is how you ask OpenSSL to request a
certificate from the client, but also what triggers its built-in verification.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 01 Apr 2025 17:26:56 +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 }; |