Software /
code /
prosody
Comparison
plugins/mod_roster.lua @ 8644:3b28c7728e3f
mod_roster: Iterate over roster group items in more modern manner
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 21 Mar 2018 23:15:30 +0100 |
parent | 7783:f54c960240da |
child | 8646:a267dfa9d81d |
comparison
equal
deleted
inserted
replaced
8643:11b6aa30b3e0 | 8644:3b28c7728e3f |
---|---|
9 | 9 |
10 local st = require "util.stanza" | 10 local st = require "util.stanza" |
11 | 11 |
12 local jid_split = require "util.jid".split; | 12 local jid_split = require "util.jid".split; |
13 local jid_prep = require "util.jid".prep; | 13 local jid_prep = require "util.jid".prep; |
14 local t_concat = table.concat; | |
15 local tonumber = tonumber; | 14 local tonumber = tonumber; |
16 local pairs, ipairs = pairs, ipairs; | 15 local pairs = pairs; |
17 | 16 |
18 local rm_load_roster = require "core.rostermanager".load_roster; | 17 local rm_load_roster = require "core.rostermanager".load_roster; |
19 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; | 18 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; |
20 local rm_add_to_roster = require "core.rostermanager".add_to_roster; | 19 local rm_add_to_roster = require "core.rostermanager".add_to_roster; |
21 local rm_roster_push = require "core.rostermanager".roster_push; | 20 local rm_roster_push = require "core.rostermanager".roster_push; |
94 r_item.subscription = session.roster[jid].subscription; | 93 r_item.subscription = session.roster[jid].subscription; |
95 r_item.ask = session.roster[jid].ask; | 94 r_item.ask = session.roster[jid].ask; |
96 else | 95 else |
97 r_item.subscription = "none"; | 96 r_item.subscription = "none"; |
98 end | 97 end |
99 for _, child in ipairs(item) do | 98 for group in item:childtags("group") do |
100 if child.name == "group" then | 99 local text = group:get_text(); |
101 local text = t_concat(child); | 100 if text then |
102 if text and text ~= "" then | 101 r_item.groups[text] = true; |
103 r_item.groups[text] = true; | |
104 end | |
105 end | 102 end |
106 end | 103 end |
107 local success, err_type, err_cond, err_msg = rm_add_to_roster(session, jid, r_item); | 104 local success, err_type, err_cond, err_msg = rm_add_to_roster(session, jid, r_item); |
108 if success then | 105 if success then |
109 -- Ok, send success | 106 -- Ok, send success |