annotate mod_incidents_handling/incidents_handling/mod_incidents_handling.lua @ 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.
author Marco Cirillo <maranda@lightwitch.org>
date Sun, 17 Feb 2013 19:28:47 +0100
parents
children dec71c31fb78
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
13 local pairs, os_time = pairs, 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
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()
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
30 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
71 local 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
120
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 }
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
147
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
149 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
150 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
151 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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 -- // 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
154
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
156 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
157
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
159 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
160 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
161
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
163 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
164
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
166 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
167 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
168 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
169 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
170 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
171 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
172
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
183 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
184
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
186 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
187 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
188 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
189 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
190 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
194 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
195
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
197 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
198 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
199 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
200 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
201 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
202 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
203 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
207
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 -- // 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
209
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
211 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
212
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
214 if state.step == 1 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 data.action == "cancel" 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
216 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
217 elseif data.action == "prev" 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
218 return { status = "executing", actions = { "next", "cancel", default = "next" }, form = list_incidents_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
219 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
220
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
222 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
223
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
225 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
226
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
238 local single_incident_layout = ih_lib.render_single(incidents[fields.ids])
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 return { status = "executing", actions = { "prev", "cancel", "complete", default = "complete" }, form = single_incident_layout }, { step = 1, form_layout = single_incident_layout, id = fields.ids }
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
240 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
241 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
242 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
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 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
245 return { status = "executing", actions = { "next", "cancel", default = "next" }, form = list_incidents_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
246 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
250 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
251 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
252 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
253
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 { 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
255 { 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
256 { 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
257 { 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
258 }
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
261 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
262 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
263
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
265 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
266 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
267 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
268 :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
269 :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
270 :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
271
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
273 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
274 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
275 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
276 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
277 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
278 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
282 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
283 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
284 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
285
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
287 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
288 local fields = send_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
289
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (upstream prosody's util.dataforms will still strip those). Also moved auxiliary functions to a library.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff changeset
290 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
291 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
292 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
293 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
294 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
295
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
297 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
298 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
299 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
300 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
301
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
303 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
304 return err_no_fields
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
306 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
307 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
308 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
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
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
312 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
313 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
314
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
316 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
317 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
318
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 -- // 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
330
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
332 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
333 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
334 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
335 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
336
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 -- // 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
338
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
340 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
341 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
342 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
343
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
345 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
346 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
347
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
349 incidents = data.incidents or {}
d814cc183c40 mod_incidents_handling: recommit after full test, cleaned it a bit as what I posted was regretfully an unfinished draft, replaced a lot of the fixed type fields used for fields description with desc elements (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 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
351 end