Software /
code /
verse
Comparison
libs/adhoc.lib.lua @ 457:73d4eb93657b
Update to use util.id for random ids instead of counters (thanks Zash)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 16 Mar 2023 11:41:52 +0000 |
parent | 383:72be3c2cf602 |
child | 490:6b2f31da9610 |
comparison
equal
deleted
inserted
replaced
456:6a65142052c8 | 457:73d4eb93657b |
---|---|
2 -- | 2 -- |
3 -- This file is MIT/X11 licensed. Please see the | 3 -- This file is MIT/X11 licensed. Please see the |
4 -- COPYING file in the source package for more information. | 4 -- COPYING file in the source package for more information. |
5 -- | 5 -- |
6 | 6 |
7 local st, uuid = require "util.stanza", require "util.uuid"; | 7 local st, new_id = require "util.stanza", require "util.id".short; |
8 | 8 |
9 local xmlns_cmd = "http://jabber.org/protocol/commands"; | 9 local xmlns_cmd = "http://jabber.org/protocol/commands"; |
10 | 10 |
11 local states = {} | 11 local states = {} |
12 | 12 |
23 function _M.new(name, node, handler, permission) | 23 function _M.new(name, node, handler, permission) |
24 return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = (permission or "user") }; | 24 return { name = name, node = node, handler = handler, cmdtag = _cmdtag, permission = (permission or "user") }; |
25 end | 25 end |
26 | 26 |
27 function _M.handle_cmd(command, origin, stanza) | 27 function _M.handle_cmd(command, origin, stanza) |
28 local sessionid = stanza.tags[1].attr.sessionid or uuid.generate(); | 28 local sessionid = stanza.tags[1].attr.sessionid or new_id(); |
29 local dataIn = {}; | 29 local dataIn = {}; |
30 dataIn.to = stanza.attr.to; | 30 dataIn.to = stanza.attr.to; |
31 dataIn.from = stanza.attr.from; | 31 dataIn.from = stanza.attr.from; |
32 dataIn.action = stanza.tags[1].attr.action or "execute"; | 32 dataIn.action = stanza.tags[1].attr.action or "execute"; |
33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); | 33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); |