8 |
8 |
9 local log = module._log; |
9 local log = module._log; |
10 |
10 |
11 local require = require; |
11 local require = require; |
12 local pairs, ipairs = pairs, ipairs; |
12 local pairs, ipairs = pairs, ipairs; |
13 local t_concat, t_insert = table.concat, table.insert; |
13 local t_insert = table.insert; |
14 local s_find = string.find; |
14 local s_find = string.find; |
15 local tonumber = tonumber; |
15 local tonumber = tonumber; |
16 |
16 |
17 local st = require "util.stanza"; |
17 local st = require "util.stanza"; |
18 local jid_split = require "util.jid".split; |
18 local jid_split = require "util.jid".split; |
58 priority[1] = "0"; |
58 priority[1] = "0"; |
59 end |
59 end |
60 end |
60 end |
61 local priority = stanza:child_with_name("priority"); |
61 local priority = stanza:child_with_name("priority"); |
62 if priority and #priority > 0 then |
62 if priority and #priority > 0 then |
63 priority = t_concat(priority); |
63 priority = priority:get_text(); |
64 if s_find(priority, "^[+-]?[0-9]+$") then |
64 if s_find(priority, "^[+-]?[0-9]+$") then |
65 priority = tonumber(priority); |
65 priority = tonumber(priority); |
66 if priority < -128 then priority = -128 end |
66 if priority < -128 then priority = -128 end |
67 if priority > 127 then priority = 127 end |
67 if priority > 127 then priority = 127 end |
68 else priority = 0; end |
68 else priority = 0; end |