Mercurial > prosody-modules
annotate mod_incidents_handling/incidents_handling/mod_incidents_handling.lua @ 4646:072d078be095
mod_storage_xmlarchive: Advertise capabilities (none atm)
Both 'total' and 'quota' would be prohibitively expensive for the kind
of archives this module targets as it would require counting items
across the entire archive.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 13 Aug 2021 01:18:32 +0200 |
parents | 7dbde05b48a9 |
children |
rev | line source |
---|---|
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
1 -- This plugin implements XEP-268 (Incidents Handling) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
2 -- (C) 2012-2013, Marco Cirillo (LW.Org) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
3 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
4 -- Note: Only part of the IODEF specifications are supported. |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
5 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
6 module:depends("adhoc") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
7 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
8 local datamanager = require "util.datamanager" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
9 local dataforms_new = require "util.dataforms".new |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
10 local st = require "util.stanza" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
11 local id_gen = require "util.uuid".generate |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
12 |
984
c4995b56c358
mod_incidents_handling: import setmetatable.
Marco Cirillo <maranda@lightwitch.org>
parents:
920
diff
changeset
|
13 local pairs, os_time, setmetatable = pairs, os.time, setmetatable |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
14 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
15 local xmlns_inc = "urn:xmpp:incident:2" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
16 local xmlns_iodef = "urn:ietf:params:xml:ns:iodef-1.0" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
17 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
18 local my_host = module:get_host() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
19 local ih_lib = module:require("incidents_handling") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
20 ih_lib.set_my_host(my_host) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
21 incidents = {} |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
22 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
23 local expire_time = module:get_option_number("incidents_expire_time", 0) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
24 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
25 -- Incidents Table Methods |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
26 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
27 local _inc_mt = {} ; _inc_mt.__index = _inc_mt |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
28 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
29 function _inc_mt:init() |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
30 self:clean() ; self:save() |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
31 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
32 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
33 function _inc_mt:clean() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
34 if expire_time > 0 then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
35 for id, incident in pairs(self) do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
36 if ((os_time() - incident.time) > expire_time) and incident.status ~= "open" then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
37 incident = nil |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
38 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
39 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
40 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
41 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
42 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
43 function _inc_mt:save() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
44 if not datamanager.store("incidents", my_host, "incidents_store", incidents) then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
45 module:log("error", "Failed to save the incidents store!") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
46 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
47 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
48 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
49 function _inc_mt:add(stanza, report) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
50 local data = ih_lib.stanza_parser(stanza) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
51 local new_object = { |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
52 time = os_time(), |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
53 status = (not report and "open") or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
54 data = data |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
55 } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
56 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
57 self[data.id.text] = new_object |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
58 self:clean() ; self:save() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
59 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
60 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
61 function _inc_mt:new_object(fields, formtype) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
62 local start_time, end_time, report_time = fields.started, fields.ended, fields.reported |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
63 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
64 local _desc, _contacts, _related, _impact, _sources, _targets = fields.description, fields.contacts, fields.related, fields.impact, fields.sources, fields.targets |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
65 local fail = false |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
66 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
67 local _lang, _dtext = _desc:match("^(%a%a)%s(.*)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
68 if not _lang or not _dtext then return false end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
69 local desc = { text = _dtext, lang = _lang } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
70 |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
71 local contacts = {} |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
72 for contact in _contacts:gmatch("[%w%p]+%s[%w%p]+%s[%w%p]+") do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
73 local address, atype, role = contact:match("^([%w%p]+)%s([%w%p]+)%s([%w%p]+)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
74 if not address or not atype or not role then fail = true ; break end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
75 contacts[#contacts + 1] = { |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
76 role = role, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
77 ext_role = (role ~= "creator" or role ~= "admin" or role ~= "tech" or role ~= "irt" or role ~= "cc" and true) or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
78 type = atype, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
79 ext_type = (atype ~= "person" or atype ~= "organization" and true) or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
80 jid = (atype == "jid" and address) or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
81 email = (atype == "email" and address) or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
82 telephone = (atype == "telephone" and address) or nil, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
83 postaladdr = (atype == "postaladdr" and address) or nil |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
84 } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
85 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
86 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
87 local related = {} |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
88 if _related then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
89 for related in _related:gmatch("[%w%p]+%s[%w%p]+") do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
90 local fqdn, id = related:match("^([%w%p]+)%s([%w%p]+)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
91 if fqdn and id then related[#related + 1] = { text = id, name = fqdn } end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
92 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
93 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
94 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
95 local _severity, _completion, _type = _impact:match("^([%w%p]+)%s([%w%p]+)%s([%w%p]+)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
96 local assessment = { lang = "en", severity = _severity, completion = _completion, type = _type } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
97 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
98 local sources = {} |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
99 for source in _sources:gmatch("[%w%p]+%s[%w%p]+%s[%d]+%s[%w%p]+") do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
100 local address, cat, count, count_type = source:match("^([%w%p]+)%s([%w%p]+)%s(%d+)%s([%w%p]+)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
101 if not address or not cat or not count or not count_type then fail = true ; break end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
102 local cat, cat_ext = ih_lib.get_type(cat, "category") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
103 local count_type, count_ext = ih_lib.get_type(count_type, "counter") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
104 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
105 sources[#sources + 1] = { |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
106 address = { cat = cat, ext = cat_ext, text = address }, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
107 counter = { type = count_type, ext_type = count_ext, value = count } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
108 } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
109 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
110 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
111 local targets, _preprocess = {}, {} |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
112 for target in _targets:gmatch("[%w%p]+%s[%w%p]+%s[%w%p]+") do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
113 local address, cat, noderole, noderole_ext |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
114 local address, cat, noderole = target:match("^([%w%p]+)%s([%w%p]+)%s([%w%p]+)$") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
115 if not address or not cat or not noderole then fail = true ; break end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
116 cat, cat_ext = ih_lib.get_type(cat, "category") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
117 noderole_ext = ih_lib.get_type(cat, "noderole") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
118 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
119 if not _preprocess[noderole] then _preprocess[noderole] = { addresses = {}, ext = noderole_ext } end |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
120 |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
121 _preprocess[noderole].addresses[#_preprocess[noderole].addresses + 1] = { |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
122 text = address, cat = cat, ext = cat_ext |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
123 } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
124 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
125 for noderole, data in pairs(_preprocess) do |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
126 local nr_cat = (data.ext and "ext-category") or noderole |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
127 local nr_ext = (data.ext and noderole) or nil |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
128 targets[#targets + 1] = { addresses = data.addresses, noderole = { cat = nr_cat, ext = nr_ext } } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
129 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
130 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
131 local new_object = {} |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
132 if not fail then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
133 new_object["time"] = os_time() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
134 new_object["status"] = (formtype == "request" and "open") or nil |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
135 new_object["type"] = formtype |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
136 new_object["data"] = { |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
137 id = { text = id_gen(), name = my_host }, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
138 start_time = start_time, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
139 end_time = end_time, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
140 report_time = report_time, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
141 desc = desc, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
142 contacts = contacts, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
143 related = related, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
144 assessment = assessment, |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
145 event_data = { sources = sources, targets = targets } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
146 } |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
147 |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
148 self[new_object.data.id.text] = new_object |
918
dec71c31fb78
mod_incidents_handling: run cleanup and save the store when a new object is added.
Marco Cirillo <maranda@lightwitch.org>
parents:
912
diff
changeset
|
149 self:clean() ; self:save() |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
150 return new_object.data.id.text |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
151 else return false end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
152 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
153 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
154 -- // Handler Functions // |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
155 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
156 local function report_handler(event) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
157 local origin, stanza = event.origin, event.stanza |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
158 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
159 incidents:add(stanza, true) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
160 return origin.send(st.reply(stanza)) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
161 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
162 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
163 local function inquiry_handler(event) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
164 local origin, stanza = event.origin, event.stanza |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
165 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
166 local inc_id = stanza:get_child("inquiry", xmlns_inc):get_child("Incident", xmlns_iodef):get_child("IncidentID"):get_text() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
167 if incidents[inc_id] then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
168 module:log("debug", "Server %s queried for incident %s which we know about, sending it", stanza.attr.from, inc_id) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
169 local report_iq = stanza_construct(incidents[inc_id]) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
170 report_iq.attr.from = stanza.attr.to |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
171 report_iq.attr.to = stanza.attr.from |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
172 report_iq.attr.type = "set" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
173 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
174 origin.send(st.reply(stanza)) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
175 origin.send(report_iq) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
176 return true |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
177 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
178 module:log("error", "Server %s queried for incident %s but we don't know about it", stanza.attr.from, inc_id) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
179 origin.send(st.error_reply(stanza, "cancel", "item-not-found")) ; return true |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
180 end |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
181 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
182 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
183 local function request_handler(event) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
184 local origin, stanza = event.origin, event.stanza |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
185 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
186 local req_id = stanza:get_child("request", xmlns_inc):get_child("Incident", xmlns_iodef):get_child("IncidentID"):get_text() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
187 if not incidents[req_id] then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
188 origin.send(st.error_reply(stanza, "cancel", "item-not-found")) ; return true |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
189 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
190 origin.send(st.reply(stanza)) ; return true |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
191 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
192 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
193 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
194 local function response_handler(event) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
195 local origin, stanza = event.origin, event.stanza |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
196 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
197 local res_id = stanza:get_child("response", xmlns_inc):get_child("Incident", xmlns_iodef):get_child("IncidentID"):get_text() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
198 if incidents[res_id] then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
199 incidents[res_id] = nil |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
200 incidents:add(stanza, true) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
201 origin.send(st.reply(stanza)) ; return true |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
202 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
203 origin.send(st.error_reply(stanza, "cancel", "item-not-found")) ; return true |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
204 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
205 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
206 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
207 local function results_handler(event) return true end -- TODO results handling |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
208 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
209 -- // Adhoc Commands // |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
210 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
211 local function list_incidents_command_handler(self, data, state) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
212 local list_incidents_layout = ih_lib.render_list(incidents) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
213 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
214 if state then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
215 if state.step == 1 then |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
216 if data.action == "cancel" then |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
217 return { status = "canceled" } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
218 elseif data.action == "prev" then |
920
f183de41b7c6
mod_incidents_handling: "cancel" action doesn't need to be specified, suppresses a (harmless) log error.
Marco Cirillo <maranda@lightwitch.org>
parents:
918
diff
changeset
|
219 return { status = "executing", actions = { "next", default = "next" }, form = list_incidents_layout }, {} |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
220 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
221 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
222 local single_incident_layout = state.form_layout |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
223 local fields = single_incident_layout:data(data.form) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
224 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
225 if fields.response then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
226 incidents[state.id].status = "closed" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
227 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
228 local iq_send = ih_lib.stanza_construct(incidents[state.id]) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
229 module:send(iq_send) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
230 return { status = "completed", info = "Response sent." } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
231 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
232 return { status = "completed" } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
233 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
234 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
235 if data.action == "cancel" then return { status = "canceled" } end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
236 local fields = list_incidents_layout:data(data.form) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
237 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
238 if fields.ids then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
239 local single_incident_layout = ih_lib.render_single(incidents[fields.ids]) |
920
f183de41b7c6
mod_incidents_handling: "cancel" action doesn't need to be specified, suppresses a (harmless) log error.
Marco Cirillo <maranda@lightwitch.org>
parents:
918
diff
changeset
|
240 return { status = "executing", actions = { "prev", "complete", default = "complete" }, form = single_incident_layout }, { step = 1, form_layout = single_incident_layout, id = fields.ids } |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
241 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
242 return { status = "completed", error = { message = "You need to select the report ID to continue." } } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
243 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
244 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
245 else |
920
f183de41b7c6
mod_incidents_handling: "cancel" action doesn't need to be specified, suppresses a (harmless) log error.
Marco Cirillo <maranda@lightwitch.org>
parents:
918
diff
changeset
|
246 return { status = "executing", actions = { "next", default = "next" }, form = list_incidents_layout }, {} |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
247 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
248 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
249 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
250 local function send_inquiry_command_handler(self, data, state) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
251 local send_inquiry_layout = dataforms_new{ |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
252 title = "Send an inquiry about an incident report to a host"; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
253 instructions = "Please specify both the server host and the incident ID."; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
254 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
255 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/commands" }; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
256 { name = "server", type = "text-single", label = "Server to inquiry" }; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
257 { name = "hostname", type = "text-single", label = "Involved incident host" }; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
258 { name = "id", type = "text-single", label = "Incident ID" }; |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
259 } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
260 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
261 if state then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
262 if data.action == "cancel" then return { status = "canceled" } end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
263 local fields = send_inquiry_layout:data(data.form) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
264 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
265 if not fields.hostname or not fields.id or not fields.server then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
266 return { status = "completed", error = { message = "You must supply the server to quest, the involved incident host and the incident ID." } } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
267 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
268 local iq_send = st.iq({ from = my_host, to = fields.server, type = "get" }) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
269 :tag("inquiry", { xmlns = xmlns_inc }) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
270 :tag("Incident", { xmlns = xmlns_iodef, purpose = "traceback" }) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
271 :tag("IncidentID", { name = data.hostname }):text(fields.id):up():up():up() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
272 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
273 module:log("debug", "Sending incident inquiry to %s", fields.server) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
274 module:send(iq_send) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
275 return { status = "completed", info = "Inquiry sent, if an answer can be obtained from the remote server it'll be listed between incidents." } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
276 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
277 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
278 return { status = "executing", form = send_inquiry_layout }, "executing" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
279 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
280 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
281 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
282 local function rr_command_handler(self, data, state, formtype) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
283 local send_layout = ih_lib.get_incident_layout(formtype) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
284 local err_no_fields = { status = "completed", error = { message = "You need to fill all fields, except the eventual related incident." } } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
285 local err_proc = { status = "completed", error = { message = "There was an error processing your request, check out the syntax" } } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
286 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
287 if state then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
288 if data.action == "cancel" then return { status = "canceled" } end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
289 local fields = send_layout:data(data.form) |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
290 |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
291 if fields.started and fields.ended and fields.reported and fields.description and fields.contacts and |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
292 fields.impact and fields.sources and fields.targets and fields.entity then |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
293 if formtype == "request" and not fields.expectation then return err_no_fields end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
294 local id = incidents:new_object(fields, formtype) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
295 if not id then return err_proc end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
296 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
297 local stanza = ih_lib.stanza_construct(id) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
298 stanza.attr.from = my_host |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
299 stanza.attr.to = fields.entity |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
300 module:log("debug","Sending incident %s stanza to: %s", formtype, stanza.attr.to) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
301 module:send(stanza) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
302 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
303 return { status = "completed", info = string.format("Incident %s sent to %s.", formtype, fields.entity) } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
304 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
305 return err_no_fields |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
306 end |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
307 else |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
308 return { status = "executing", form = send_layout }, "executing" |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
309 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
310 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
311 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
312 local function send_report_command_handler(self, data, state) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
313 return rr_command_handler(self, data, state, "report") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
314 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
315 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
316 local function send_request_command_handler(self, data, state) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
317 return rr_command_handler(self, data, state, "request") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
318 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
319 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
320 local adhoc_new = module:require "adhoc".new |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
321 local list_incidents_descriptor = adhoc_new("List Incidents", xmlns_inc.."#list", list_incidents_command_handler, "admin") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
322 local send_inquiry_descriptor = adhoc_new("Send Incident Inquiry", xmlns_inc.."#send_inquiry", send_inquiry_command_handler, "admin") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
323 local send_report_descriptor = adhoc_new("Send Incident Report", xmlns_inc.."#send_report", send_report_command_handler, "admin") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
324 local send_request_descriptor = adhoc_new("Send Incident Request", xmlns_inc.."#send_request", send_request_command_handler, "admin") |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
325 module:provides("adhoc", list_incidents_descriptor) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
326 module:provides("adhoc", send_inquiry_descriptor) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
327 module:provides("adhoc", send_report_descriptor) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
328 module:provides("adhoc", send_request_descriptor) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
329 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
330 -- // Hooks // |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
331 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
332 module:hook("iq-set/host/urn:xmpp:incident:2:report", report_handler) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
333 module:hook("iq-get/host/urn:xmpp:incident:2:inquiry", inquiry_handler) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
334 module:hook("iq-get/host/urn:xmpp:incident:2:request", request_handler) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
335 module:hook("iq-set/host/urn:xmpp:incident:2:response", response_handler) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
336 module:hook("iq-result/host/urn:xmpp:incident:2", results_handler) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
337 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
338 -- // Module Methods // |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
339 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
340 module.load = function() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
341 if datamanager.load("incidents", my_host, "incidents_store") then incidents = datamanager.load("incidents", my_host, "incidents_store") end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
342 setmetatable(incidents, _inc_mt) ; incidents:init() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
343 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
344 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
345 module.save = function() |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
346 return { incidents = incidents } |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
347 end |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
348 |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
349 module.restore = function(data) |
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
350 incidents = data.incidents or {} |
1343
7dbde05b48a9
all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
984
diff
changeset
|
351 setmetatable(incidents, _inc_mt) ; incidents:init() |
912
d814cc183c40
mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
352 end |