Software /
code /
prosody
Comparison
plugins/mod_presence.lua @ 6302:76699a0ae4c4
mod_lastactivity, mod_legacyauth, mod_presence, mod_saslauth, mod_tls: Use the newer stanza:get_child APIs and optimize away some table lookups
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 04 Jul 2014 22:52:34 +0200 |
parent | 6291:7a604381d6fc |
child | 6613:2aae36312eb9 |
comparison
equal
deleted
inserted
replaced
6301:2fdd71b08126 | 6302:76699a0ae4c4 |
---|---|
53 | 53 |
54 local ignore_presence_priority = module:get_option("ignore_presence_priority"); | 54 local ignore_presence_priority = module:get_option("ignore_presence_priority"); |
55 | 55 |
56 function handle_normal_presence(origin, stanza) | 56 function handle_normal_presence(origin, stanza) |
57 if ignore_presence_priority then | 57 if ignore_presence_priority then |
58 local priority = stanza:child_with_name("priority"); | 58 local priority = stanza:get_child("priority"); |
59 if priority and priority[1] ~= "0" then | 59 if priority and priority[1] ~= "0" then |
60 for i=#priority.tags,1,-1 do priority.tags[i] = nil; end | 60 for i=#priority.tags,1,-1 do priority.tags[i] = nil; end |
61 for i=#priority,1,-1 do priority[i] = nil; end | 61 for i=#priority,1,-1 do priority[i] = nil; end |
62 priority[1] = "0"; | 62 priority[1] = "0"; |
63 end | 63 end |
64 end | 64 end |
65 local priority = stanza:child_with_name("priority"); | 65 local priority = stanza:get_child("priority"); |
66 if priority and #priority > 0 then | 66 if priority and #priority > 0 then |
67 priority = t_concat(priority); | 67 priority = t_concat(priority); |
68 if s_find(priority, "^[+-]?[0-9]+$") then | 68 if s_find(priority, "^[+-]?[0-9]+$") then |
69 priority = tonumber(priority); | 69 priority = tonumber(priority); |
70 if priority < -128 then priority = -128 end | 70 if priority < -128 then priority = -128 end |