# HG changeset patch # User Florian Zeitz # Date 1390230420 -3600 # Node ID f78661861e98729c33bbb6a3e5a7e92ff8f6e458 # Parent 42625801d15a58c592718759298dace39fdddbb7 mod_admin_probe: Module allowing server administrators to probe any user diff -r 42625801d15a -r f78661861e98 mod_admin_probe/mod_admin_probe.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_admin_probe/mod_admin_probe.lua Mon Jan 20 16:07:00 2014 +0100 @@ -0,0 +1,30 @@ +-- Prosody IM +-- Copyright (C) 2014 Florian Zeitz +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + +local presence = module:depends("presence"); +local send_presence_of_available_resources = presence.send_presence_of_available_resources; + +local hosts = prosody.hosts; +local core_post_stanza = prosody.core_post_stanza; + +local st = require "util.stanza"; +local is_admin = require "core.usermanager".is_admin; +local jid_split = require "util.jid".split; + +module:hook("presence/bare", function(data) + local origin, stanza = data.origin, data.stanza; + local to, from, type = stanza.attr.to, stanza.attr.from, stanza.attr.type; + local node, host = jid_split(to); + + if type ~= "probe" then return; end + if not is_admin(from, module.host) then return; end + + if 0 == send_presence_of_available_resources(node, host, from, origin) then + core_post_stanza(hosts[host], st.presence({from=to, to=from, type="unavailable"}), true); + end + return true; +end, 10);