Software /
code /
prosody-modules
Comparison
mod_carbons_adhoc/mod_carbons_adhoc.lua @ 890:7ac1b8a799be
mod_carbons_adhoc: Initial commit.
This module will add an Adhoc-command by which a user can see if Message
Carbons (XEP-0280) are generated for his clients and also which version
is used for the individual client. Clients which receive copies as per
mod_carbons_copies will be listed as Version 0 carbons.
author | Michael Holzt <kju@fqdn.org> |
---|---|
date | Sun, 23 Dec 2012 19:36:31 +0100 |
child | 1343:7dbde05b48a9 |
comparison
equal
deleted
inserted
replaced
889:9901d267f938 | 890:7ac1b8a799be |
---|---|
1 -- Implement a Adhoc command which will show a user | |
2 -- the status of carbons generation in regard to his clients | |
3 -- | |
4 -- Copyright (C) 2012 Michael Holzt | |
5 -- | |
6 -- This file is MIT/X11 licensed. | |
7 | |
8 local st = require "util.stanza"; | |
9 local jid_bare = require "util.jid".bare; | |
10 local adhoc_new = module:require "adhoc".new; | |
11 local xmlns_carbons_v2 = "urn:xmpp:carbons:2"; | |
12 local xmlns_carbons_v1 = "urn:xmpp:carbons:1"; | |
13 local xmlns_carbons_v0 = "urn:xmpp:carbons:0"; | |
14 | |
15 local bare_sessions = bare_sessions; | |
16 | |
17 local function adhoc_status(self, data, state) | |
18 local result; | |
19 | |
20 local bare_jid = jid_bare(data.from); | |
21 local user_sessions = bare_sessions[bare_jid]; | |
22 | |
23 local result = ""; | |
24 | |
25 user_sessions = user_sessions and user_sessions.sessions; | |
26 for _, session in pairs(user_sessions) do | |
27 if session.full_jid then | |
28 result = result .. session.full_jid .. ": " .. | |
29 ( (session.want_carbons == xmlns_carbons_v2 and "v2" ) or | |
30 (session.want_carbons == xmlns_carbons_v1 and "v1" ) or | |
31 (session.want_carbons == xmlns_carbons_v0 and "v0" ) or | |
32 "none" ) .. "\n"; | |
33 end | |
34 end | |
35 | |
36 return { info = result, status = "completed" }; | |
37 end | |
38 | |
39 local status_desc = adhoc_new("Carbons: Get Status", | |
40 "mod_carbons_adhoc#status", adhoc_status); | |
41 | |
42 module:add_item("adhoc", status_desc); |