Software /
code /
prosody
Annotate
plugins/mod_admin_adhoc.lua @ 4864:b98154bbe0e0
stanza_router: Close stream for unhandled stanzas from unauthenticated connections (we can't reply)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 12 May 2012 01:47:53 +0100 |
parent | 4780:4b8f2b91826c |
child | 4926:58714123f600 |
rev | line source |
---|---|
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
1 -- Copyright (C) 2009-2011 Florian Zeitz |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
2 -- |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
3 -- This file is MIT/X11 licensed. Please see the |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
4 -- COPYING file in the source package for more information. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
5 -- |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
6 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
7 local _G = _G; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
8 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
9 local prosody = _G.prosody; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
10 local hosts = prosody.hosts; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
11 local t_concat = table.concat; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
12 |
4594
565ea0c1a7ea
mod_admin_adhoc: Import util.iterators properly
Kim Alvefur <zash@zash.se>
parents:
4296
diff
changeset
|
13 local iterators = require "util.iterators"; |
565ea0c1a7ea
mod_admin_adhoc: Import util.iterators properly
Kim Alvefur <zash@zash.se>
parents:
4296
diff
changeset
|
14 local keys, values = iterators.keys, iterators.values; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
15 local usermanager_user_exists = require "core.usermanager".user_exists; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
16 local usermanager_create_user = require "core.usermanager".create_user; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
17 local usermanager_get_password = require "core.usermanager".get_password; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
18 local usermanager_set_password = require "core.usermanager".set_password; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
19 local is_admin = require "core.usermanager".is_admin; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
20 local rm_load_roster = require "core.rostermanager".load_roster; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
21 local st, jid, uuid = require "util.stanza", require "util.jid", require "util.uuid"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
22 local timer_add_task = require "util.timer".add_task; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
23 local dataforms_new = require "util.dataforms".new; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
24 local array = require "util.array"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
25 local modulemanager = require "modulemanager"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
26 |
4780
4b8f2b91826c
mod_admin_adhoc: Small style fix
Matthew Wild <mwild1@gmail.com>
parents:
4595
diff
changeset
|
27 module:depends("adhoc"); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
28 local adhoc_new = module:require "adhoc".new; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
29 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
30 function add_user_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
31 local add_user_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
32 title = "Adding a User"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
33 instructions = "Fill out this form to add a user."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
34 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
35 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
36 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for the account to be added" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
37 { name = "password", type = "text-private", label = "The password for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
38 { name = "password-verify", type = "text-private", label = "Retype password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
39 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
40 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
41 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
42 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
43 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
44 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
45 local fields = add_user_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
46 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
47 return { status = "completed", error = { message = "You need to specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
48 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
49 local username, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
50 if data.to ~= host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
51 return { status = "completed", error = { message = "Trying to add a user on " .. host .. " but command was sent to " .. data.to}}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
52 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
53 if (fields["password"] == fields["password-verify"]) and username and host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
54 if usermanager_user_exists(username, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
55 return { status = "completed", error = { message = "Account already exists" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
56 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
57 if usermanager_create_user(username, fields.password, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
58 module:log("info", "Created new account " .. username.."@"..host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
59 return { status = "completed", info = "Account successfully created" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
60 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
61 return { status = "completed", error = { message = "Failed to write data to disk" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
62 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
63 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
64 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
65 module:log("debug", (fields.accountjid or "<nil>") .. " " .. (fields.password or "<nil>") .. " " |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
66 .. (fields["password-verify"] or "<nil>")); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
67 return { status = "completed", error = { message = "Invalid data.\nPassword mismatch, or empty username" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
68 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
69 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
70 return { status = "executing", form = add_user_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
71 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
72 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
73 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
74 function change_user_password_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
75 local change_user_password_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
76 title = "Changing a User Password"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
77 instructions = "Fill out this form to change a user's password."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
78 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
79 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
80 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
81 { name = "password", type = "text-private", required = true, label = "The password for this account" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
82 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
83 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
84 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
85 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
86 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
87 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
88 local fields = change_user_password_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
89 if not fields.accountjid or fields.accountjid == "" or not fields.password then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
90 return { status = "completed", error = { message = "Please specify username and password" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
91 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
92 local username, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
93 if data.to ~= host then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
94 return { status = "completed", error = { message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. data.to}}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
95 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
96 if usermanager_user_exists(username, host) and usermanager_set_password(username, fields.password, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
97 return { status = "completed", info = "Password successfully changed" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
98 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
99 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
100 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
101 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
102 return { status = "executing", form = change_user_password_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
103 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
104 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
105 |
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
106 function config_reload_handler(self, data, state) |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
107 local ok, err = prosody.reload_config(); |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
108 if ok then |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
109 return { status = "completed", info = "Configuration reloaded (modules may need to be reloaded for this to have an effect)" }; |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
110 else |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
111 return { status = "completed", error = { message = "Failed to reload config: " .. tostring(err) } }; |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
112 end |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
113 end |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
114 |
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
115 |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
116 function delete_user_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
117 local delete_user_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
118 title = "Deleting a User"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
119 instructions = "Fill out this form to delete a user."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
120 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
121 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
122 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) to delete" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
123 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
124 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
125 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
126 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
127 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
128 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
129 local fields = delete_user_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
130 local failed = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
131 local succeeded = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
132 for _, aJID in ipairs(fields.accountjids) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
133 local username, host, resource = jid.split(aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
134 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) and usermanager_create_user(username, nil, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
135 module:log("debug", "User " .. aJID .. " has been deleted"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
136 succeeded[#succeeded+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
137 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
138 module:log("debug", "Tried to delete non-existant user "..aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
139 failed[#failed+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
140 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
141 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
142 return {status = "completed", info = (#succeeded ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
143 "The following accounts were successfully deleted:\n"..t_concat(succeeded, "\n").."\n" or "").. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
144 (#failed ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
145 "The following accounts could not be deleted:\n"..t_concat(failed, "\n") or "") }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
146 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
147 return { status = "executing", form = delete_user_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
148 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
149 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
150 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
151 function disconnect_user(match_jid) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
152 local node, hostname, givenResource = jid.split(match_jid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
153 local host = hosts[hostname]; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
154 local sessions = host.sessions[node] and host.sessions[node].sessions; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
155 for resource, session in pairs(sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
156 if not givenResource or (resource == givenResource) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
157 module:log("debug", "Disconnecting "..node.."@"..hostname.."/"..resource); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
158 session:close(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
159 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
160 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
161 return true; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
162 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
163 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
164 function end_user_session_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
165 local end_user_session_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
166 title = "Ending a User Session"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
167 instructions = "Fill out this form to end a user's session."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
168 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
169 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
170 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to end sessions" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
171 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
172 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
173 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
174 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
175 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
176 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
177 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
178 local fields = end_user_session_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
179 local failed = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
180 local succeeded = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
181 for _, aJID in ipairs(fields.accountjids) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
182 local username, host, resource = jid.split(aJID); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
183 if (host == data.to) and usermanager_user_exists(username, host) and disconnect_user(aJID) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
184 succeeded[#succeeded+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
185 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
186 failed[#failed+1] = aJID; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
187 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
188 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
189 return {status = "completed", info = (#succeeded ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
190 "The following accounts were successfully disconnected:\n"..t_concat(succeeded, "\n").."\n" or "").. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
191 (#failed ~= 0 and |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
192 "The following accounts could not be disconnected:\n"..t_concat(failed, "\n") or "") }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
193 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
194 return { status = "executing", form = end_user_session_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
195 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
196 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
197 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
198 local end_user_session_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
199 title = "Ending a User Session"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
200 instructions = "Fill out this form to end a user's session."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
201 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
202 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
203 { name = "accountjids", type = "jid-multi", label = "The Jabber ID(s) for which to end sessions" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
204 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
205 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
206 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
207 function get_user_password_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
208 local get_user_password_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
209 title = "Getting User's Password"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
210 instructions = "Fill out this form to get a user's password."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
211 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
212 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
213 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
214 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
215 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
216 local get_user_password_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
217 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
218 { name = "accountjid", type = "jid-single", label = "JID" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
219 { name = "password", type = "text-single", label = "Password" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
220 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
221 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
222 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
223 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
224 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
225 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
226 local fields = get_user_password_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
227 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
228 return { status = "completed", error = { message = "Please specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
229 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
230 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
231 local accountjid = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
232 local password = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
233 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
234 return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
235 elseif usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
236 accountjid = fields.accountjid; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
237 password = usermanager_get_password(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
238 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
239 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
240 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
241 return { status = "completed", result = { layout = get_user_password_result_layout, values = {accountjid = accountjid, password = password} } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
242 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
243 return { status = "executing", form = get_user_password_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
244 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
245 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
246 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
247 function get_user_roster_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
248 local get_user_roster_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
249 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
250 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for which to retrieve the roster" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
251 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
252 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
253 local get_user_roster_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
254 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
255 { name = "accountjid", type = "jid-single", label = "This is the roster for" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
256 { name = "roster", type = "text-multi", label = "Roster XML" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
257 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
258 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
259 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
260 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
261 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
262 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
263 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
264 local fields = get_user_roster_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
265 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
266 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
267 return { status = "completed", error = { message = "Please specify a JID" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
268 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
269 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
270 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
271 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
272 return { status = "completed", error = { message = "Tried to get roster for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
273 elseif not usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
274 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
275 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
276 local roster = rm_load_roster(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
277 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
278 local query = st.stanza("query", { xmlns = "jabber:iq:roster" }); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
279 for jid in pairs(roster) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
280 if jid ~= "pending" and jid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
281 query:tag("item", { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
282 jid = jid, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
283 subscription = roster[jid].subscription, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
284 ask = roster[jid].ask, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
285 name = roster[jid].name, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
286 }); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
287 for group in pairs(roster[jid].groups) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
288 query:tag("group"):text(group):up(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
289 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
290 query:up(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
291 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
292 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
293 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
294 local query_text = query:__tostring(); -- TODO: Use upcoming pretty_print() function |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
295 query_text = query_text:gsub("><", ">\n<"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
296 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
297 local result = get_user_roster_result_layout:form({ accountjid = user.."@"..host, roster = query_text }, "result"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
298 result:add_child(query); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
299 return { status = "completed", other = result }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
300 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
301 return { status = "executing", form = get_user_roster_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
302 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
303 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
304 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
305 function get_user_stats_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
306 local get_user_stats_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
307 title = "Get User Statistics"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
308 instructions = "Fill out this form to gather user statistics."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
309 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
310 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
311 { name = "accountjid", type = "jid-single", required = true, label = "The Jabber ID for statistics" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
312 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
313 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
314 local get_user_stats_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
315 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
316 { name = "ipaddresses", type = "text-multi", label = "IP Addresses" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
317 { name = "rostersize", type = "text-single", label = "Roster size" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
318 { name = "onlineresources", type = "text-multi", label = "Online Resources" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
319 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
320 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
321 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
322 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
323 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
324 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
325 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
326 local fields = get_user_stats_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
327 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
328 if not fields.accountjid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
329 return { status = "completed", error = { message = "Please specify a JID." } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
330 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
331 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
332 local user, host, resource = jid.split(fields.accountjid); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
333 if host ~= data.to then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
334 return { status = "completed", error = { message = "Tried to get stats for a user on " .. host .. " but command was sent to " .. data.to } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
335 elseif not usermanager_user_exists(user, host) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
336 return { status = "completed", error = { message = "User does not exist" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
337 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
338 local roster = rm_load_roster(user, host); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
339 local rostersize = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
340 local IPs = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
341 local resources = ""; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
342 for jid in pairs(roster) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
343 if jid ~= "pending" and jid then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
344 rostersize = rostersize + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
345 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
346 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
347 for resource, session in pairs((hosts[host].sessions[user] and hosts[host].sessions[user].sessions) or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
348 resources = resources .. "\n" .. resource; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
349 IPs = IPs .. "\n" .. session.ip; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
350 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
351 return { status = "completed", result = {layout = get_user_stats_result_layout, values = {ipaddresses = IPs, rostersize = tostring(rostersize), |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
352 onlineresources = resources}} }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
353 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
354 return { status = "executing", form = get_user_stats_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
355 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
356 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
357 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
358 function get_online_users_command_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
359 local get_online_users_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
360 title = "Getting List of Online Users"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
361 instructions = "How many users should be returned at most?"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
362 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
363 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
364 { name = "max_items", type = "list-single", label = "Maximum number of users", |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
365 value = { "25", "50", "75", "100", "150", "200", "all" } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
366 { name = "details", type = "boolean", label = "Show details" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
367 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
368 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
369 local get_online_users_result_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
370 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
371 { name = "onlineuserjids", type = "text-multi", label = "The list of all online users" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
372 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
373 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
374 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
375 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
376 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
377 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
378 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
379 local fields = get_online_users_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
380 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
381 local max_items = nil |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
382 if fields.max_items ~= "all" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
383 max_items = tonumber(fields.max_items); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
384 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
385 local count = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
386 local users = {}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
387 for username, user in pairs(hosts[data.to].sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
388 if (max_items ~= nil) and (count >= max_items) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
389 break; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
390 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
391 users[#users+1] = username.."@"..data.to; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
392 count = count + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
393 if fields.details then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
394 for resource, session in pairs(user.sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
395 local status, priority = "unavailable", tostring(session.priority or "-"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
396 if session.presence then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
397 status = session.presence:child_with_name("show"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
398 if status then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
399 status = status:get_text() or "[invalid!]"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
400 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
401 status = "available"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
402 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
403 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
404 users[#users+1] = " - "..resource..": "..status.."("..priority..")"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
405 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
406 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
407 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
408 return { status = "completed", result = {layout = get_online_users_result_layout, values = {onlineuserjids=t_concat(users, "\n")}} }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
409 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
410 return { status = "executing", form = get_online_users_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
411 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
412 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
413 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
414 function list_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
415 local result = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
416 title = "List of loaded modules"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
417 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
418 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#list" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
419 { name = "modules", type = "text-multi", label = "The following modules are loaded:" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
420 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
421 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
422 local modules = array.collect(keys(hosts[data.to].modules)):sort():concat("\n"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
423 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
424 return { status = "completed", result = { layout = result; values = { modules = modules } } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
425 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
426 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
427 function load_module_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
428 local layout = dataforms_new { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
429 title = "Load module"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
430 instructions = "Specify the module to be loaded"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
431 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
432 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#load" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
433 { name = "module", type = "text-single", required = true, label = "Module to be loaded:"}; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
434 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
435 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
436 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
437 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
438 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
439 local fields = layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
440 if (not fields.module) or (fields.module == "") then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
441 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
442 message = "Please specify a module." |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
443 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
444 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
445 if modulemanager.is_loaded(data.to, fields.module) then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
446 return { status = "completed", info = "Module already loaded" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
447 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
448 local ok, err = modulemanager.load(data.to, fields.module); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
449 if ok then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
450 return { status = "completed", info = 'Module "'..fields.module..'" successfully loaded on host "'..data.to..'".' }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
451 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
452 return { status = "completed", error = { message = 'Failed to load module "'..fields.module..'" on host "'..data.to.. |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
453 '". Error was: "'..tostring(err or "<unspecified>")..'"' } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
454 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
455 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
456 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
457 return { status = "executing", form = layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
458 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
459 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
460 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
461 function reload_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
462 local layout = dataforms_new { |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
463 title = "Reload modules"; |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
464 instructions = "Select the modules to be reloaded"; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
465 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
466 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#reload" }; |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
467 { name = "modules", type = "list-multi", required = true, label = "Modules to be reloaded:"}; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
468 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
469 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
470 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
471 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
472 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
473 local fields = layout:data(data.form); |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
474 if #fields.modules == 0 then |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
475 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
476 message = "Please specify a module. (This means your client misbehaved, as this field is required)" |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
477 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
478 end |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
479 local ok_list, err_list = {}, {}; |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
480 for _, module in ipairs(fields.modules) do |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
481 local ok, err = modulemanager.reload(data.to, module); |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
482 if ok then |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
483 ok_list[#ok_list + 1] = module; |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
484 else |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
485 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
486 end |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
487 end |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
488 local info = (#ok_list > 0 and ("The following modules were successfully reloaded on host "..data.to..":\n"..t_concat(ok_list, "\n")) or "").. |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
489 (#err_list > 0 and ("Failed to reload the following modules on host "..data.to..":\n"..t_concat(err_list, "\n")) or ""); |
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
490 return { status = "completed", info = info }; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
491 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
492 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
493 return { status = "executing", form = { layout = layout; values = { modules = modules } } }, "executing"; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
494 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
495 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
496 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
497 function send_to_online(message, server) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
498 if server then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
499 sessions = { [server] = hosts[server] }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
500 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
501 sessions = hosts; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
502 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
503 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
504 local c = 0; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
505 for domain, session in pairs(sessions) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
506 for user in pairs(session.sessions or {}) do |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
507 c = c + 1; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
508 message.attr.from = domain; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
509 message.attr.to = user.."@"..domain; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
510 core_post_stanza(session, message); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
511 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
512 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
513 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
514 return c; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
515 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
516 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
517 function shut_down_service_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
518 local shut_down_service_layout = dataforms_new{ |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
519 title = "Shutting Down the Service"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
520 instructions = "Fill out this form to shut down the service."; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
521 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
522 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
523 { name = "delay", type = "list-single", label = "Time delay before shutting down", |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
524 value = { {label = "30 seconds", value = "30"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
525 {label = "60 seconds", value = "60"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
526 {label = "90 seconds", value = "90"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
527 {label = "2 minutes", value = "120"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
528 {label = "3 minutes", value = "180"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
529 {label = "4 minutes", value = "240"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
530 {label = "5 minutes", value = "300"}, |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
531 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
532 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
533 { name = "announcement", type = "text-multi", label = "Announcement" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
534 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
535 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
536 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
537 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
538 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
539 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
540 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
541 local fields = shut_down_service_layout:data(data.form); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
542 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
543 if fields.announcement and #fields.announcement > 0 then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
544 local message = st.message({type = "headline"}, fields.announcement):up() |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
545 :tag("subject"):text("Server is shutting down"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
546 send_to_online(message); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
547 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
548 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
549 timer_add_task(tonumber(fields.delay or "5"), prosody.shutdown); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
550 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
551 return { status = "completed", info = "Server is about to shut down" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
552 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
553 return { status = "executing", form = shut_down_service_layout }, "executing"; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
554 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
555 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
556 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
557 function unload_modules_handler(self, data, state) |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
558 local layout = dataforms_new { |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
559 title = "Unload modules"; |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
560 instructions = "Select the modules to be unloaded"; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
561 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
562 { name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/modules#unload" }; |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
563 { name = "modules", type = "list-multi", required = true, label = "Modules to be unloaded:"}; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
564 }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
565 if state then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
566 if data.action == "cancel" then |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
567 return { status = "canceled" }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
568 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
569 local fields = layout:data(data.form); |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
570 if #fields.modules == 0 then |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
571 return { status = "completed", error = { |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
572 message = "Please specify a module. (This means your client misbehaved, as this field is required)" |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
573 } }; |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
574 end |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
575 local ok_list, err_list = {}, {}; |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
576 for _, module in ipairs(fields.modules) do |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
577 local ok, err = modulemanager.unload(data.to, module); |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
578 if ok then |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
579 ok_list[#ok_list + 1] = module; |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
580 else |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
581 err_list[#err_list + 1] = module .. "(Error: " .. tostring(err) .. ")"; |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
582 end |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
583 end |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
584 local info = (#ok_list > 0 and ("The following modules were successfully unloaded on host "..data.to..":\n"..t_concat(ok_list, "\n")) or "").. |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
585 (#err_list > 0 and ("Failed to unload the following modules on host "..data.to..":\n"..t_concat(err_list, "\n")) or ""); |
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
586 return { status = "completed", info = info }; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
587 else |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
588 local modules = array.collect(keys(hosts[data.to].modules)):sort(); |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
589 return { status = "executing", form = { layout = layout; values = { modules = modules } } }, "executing"; |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
590 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
591 end |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
592 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
593 local add_user_desc = adhoc_new("Add User", "http://jabber.org/protocol/admin#add-user", add_user_command_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
594 local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin"); |
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
595 local config_reload_desc = adhoc_new("Reload configuration", "http://prosody.im/protocol/config#reload", config_reload_handler, "global_admin"); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
596 local delete_user_desc = adhoc_new("Delete User", "http://jabber.org/protocol/admin#delete-user", delete_user_command_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
597 local end_user_session_desc = adhoc_new("End User Session", "http://jabber.org/protocol/admin#end-user-session", end_user_session_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
598 local get_user_password_desc = adhoc_new("Get User Password", "http://jabber.org/protocol/admin#get-user-password", get_user_password_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
599 local get_user_roster_desc = adhoc_new("Get User Roster","http://jabber.org/protocol/admin#get-user-roster", get_user_roster_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
600 local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin"); |
3540
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
3487
diff
changeset
|
601 local get_online_users_desc = adhoc_new("Get List of Online Users", "http://jabber.org/protocol/admin#get-online-users", get_online_users_command_handler, "admin"); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
602 local list_modules_desc = adhoc_new("List loaded modules", "http://prosody.im/protocol/modules#list", list_modules_handler, "admin"); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
603 local load_module_desc = adhoc_new("Load module", "http://prosody.im/protocol/modules#load", load_module_handler, "admin"); |
3777
5ecbcef42ffb
mod_admin_adhoc: Support for reloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3540
diff
changeset
|
604 local reload_modules_desc = adhoc_new("Reload modules", "http://prosody.im/protocol/modules#reload", reload_modules_handler, "admin"); |
4296
b991ffa0f2c5
mod_admin_adhoc: Only allow global admins to shut the server down
Florian Zeitz <florob@babelmonkeys.de>
parents:
4292
diff
changeset
|
605 local shut_down_service_desc = adhoc_new("Shut Down Service", "http://jabber.org/protocol/admin#shutdown", shut_down_service_handler, "global_admin"); |
3778
bd1845f9d5a4
mod_admin_adhoc: Support unloading multiple modules
Florian Zeitz <florob@babelmonkeys.de>
parents:
3777
diff
changeset
|
606 local unload_modules_desc = adhoc_new("Unload modules", "http://prosody.im/protocol/modules#unload", unload_modules_handler, "admin"); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
607 |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
608 module:add_item("adhoc", add_user_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
609 module:add_item("adhoc", change_user_password_desc); |
4292
894ffea639e9
mod_admin_adhoc: Add "Reload configuration" command
Florian Zeitz <florob@babelmonkeys.de>
parents:
3778
diff
changeset
|
610 module:add_item("adhoc", config_reload_desc); |
3487
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
611 module:add_item("adhoc", delete_user_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
612 module:add_item("adhoc", end_user_session_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
613 module:add_item("adhoc", get_user_password_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
614 module:add_item("adhoc", get_user_roster_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
615 module:add_item("adhoc", get_user_stats_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
616 module:add_item("adhoc", get_online_users_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
617 module:add_item("adhoc", list_modules_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
618 module:add_item("adhoc", load_module_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
619 module:add_item("adhoc", reload_modules_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
620 module:add_item("adhoc", shut_down_service_desc); |
b5c92275910b
mod_admin_adhoc: New module with merged functonality of mod_adhoc_cmd_admin and mod_adhoc_cmd_modules (of prosody-modules fame)
Florian Zeitz <florob@babelmonkeys.de>
parents:
diff
changeset
|
621 module:add_item("adhoc", unload_modules_desc); |