Software /
code /
prosody
Comparison
plugins/mod_disco.lua @ 12015:b4db17aeff01
mod_disco: Advertise admin accounts as such via disco identity
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 04 Jul 2020 20:09:18 +0200 |
parent | 11737:59cf555b4698 |
child | 12016:b7e15abde27f |
comparison
equal
deleted
inserted
replaced
12014:efbf288b529e | 12015:b4db17aeff01 |
---|---|
6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
7 -- | 7 -- |
8 | 8 |
9 local get_children = require "core.hostmanager".get_children; | 9 local get_children = require "core.hostmanager".get_children; |
10 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; | 10 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
11 local um_is_admin = require "core.usermanager".is_admin; | |
11 local jid_split = require "util.jid".split; | 12 local jid_split = require "util.jid".split; |
12 local jid_bare = require "util.jid".bare; | 13 local jid_bare = require "util.jid".bare; |
13 local st = require "util.stanza" | 14 local st = require "util.stanza" |
14 local calculate_hash = require "util.caps".calculate_hash; | 15 local calculate_hash = require "util.caps".calculate_hash; |
15 | 16 |
179 end | 180 end |
180 return true; | 181 return true; |
181 end | 182 end |
182 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info'}); | 183 local reply = st.reply(stanza):tag('query', {xmlns='http://jabber.org/protocol/disco#info'}); |
183 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account | 184 if not reply.attr.from then reply.attr.from = origin.username.."@"..origin.host; end -- COMPAT To satisfy Psi when querying own account |
184 reply:tag('identity', {category='account', type='registered'}):up(); | 185 if um_is_admin(stanza.attr.to or origin.full_jid, module.host) then |
186 reply:tag('identity', {category='account', type='admin'}):up(); | |
187 else | |
188 reply:tag('identity', {category='account', type='registered'}):up(); | |
189 end | |
185 module:fire_event("account-disco-info", { origin = origin, reply = reply }); | 190 module:fire_event("account-disco-info", { origin = origin, reply = reply }); |
186 origin.send(reply); | 191 origin.send(reply); |
187 return true; | 192 return true; |
188 end | 193 end |
189 end); | 194 end); |