Software / code / prosody
Comparison
plugins/mod_roster.lua @ 306:db4ef011512c
Merge with myself (!)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 15 Nov 2008 23:22:27 +0000 |
| parent | 299:300b5a201ad3 |
| child | 326:99a8317d1235 |
comparison
equal
deleted
inserted
replaced
| 305:4ccffcd6e720 | 306:db4ef011512c |
|---|---|
| 1 | 1 |
| 2 local st = require "util.stanza" | 2 local st = require "util.stanza" |
| 3 local send = require "core.sessionmanager".send_to_session | |
| 4 | 3 |
| 5 local jid_split = require "util.jid".split; | 4 local jid_split = require "util.jid".split; |
| 6 local t_concat = table.concat; | 5 local t_concat = table.concat; |
| 7 | 6 |
| 8 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; | 7 local rm_remove_from_roster = require "core.rostermanager".remove_from_roster; |
| 27 roster:tag("group"):text(group):up(); | 26 roster:tag("group"):text(group):up(); |
| 28 end | 27 end |
| 29 roster:up(); -- move out from item | 28 roster:up(); -- move out from item |
| 30 end | 29 end |
| 31 end | 30 end |
| 32 send(session, roster); | 31 session.send(roster); |
| 33 session.interested = true; -- resource is interested in roster updates | 32 session.interested = true; -- resource is interested in roster updates |
| 34 return true; | 33 return true; |
| 35 elseif stanza.attr.type == "set" then | 34 elseif stanza.attr.type == "set" then |
| 36 local query = stanza.tags[1]; | 35 local query = stanza.tags[1]; |
| 37 if #query.tags == 1 and query.tags[1].name == "item" | 36 if #query.tags == 1 and query.tags[1].name == "item" |
| 44 if item.attr.jid ~= from_node.."@"..from_host then | 43 if item.attr.jid ~= from_node.."@"..from_host then |
| 45 if item.attr.subscription == "remove" then | 44 if item.attr.subscription == "remove" then |
| 46 if session.roster[item.attr.jid] then | 45 if session.roster[item.attr.jid] then |
| 47 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, item.attr.jid); | 46 local success, err_type, err_cond, err_msg = rm_remove_from_roster(session, item.attr.jid); |
| 48 if success then | 47 if success then |
| 49 send(session, st.reply(stanza)); | 48 session.send(st.reply(stanza)); |
| 50 rm_roster_push(from_node, from_host, item.attr.jid); | 49 rm_roster_push(from_node, from_host, item.attr.jid); |
| 51 else | 50 else |
| 52 send(session, st.error_reply(stanza, err_type, err_cond, err_msg)); | 51 session.send(st.error_reply(stanza, err_type, err_cond, err_msg)); |
| 53 end | 52 end |
| 54 else | 53 else |
| 55 send(session, st.error_reply(stanza, "modify", "item-not-found")); | 54 session.send(st.error_reply(stanza, "modify", "item-not-found")); |
| 56 end | 55 end |
| 57 else | 56 else |
| 58 local r_item = {name = item.attr.name, groups = {}}; | 57 local r_item = {name = item.attr.name, groups = {}}; |
| 59 if r_item.name == "" then r_item.name = nil; end | 58 if r_item.name == "" then r_item.name = nil; end |
| 60 if session.roster[item.attr.jid] then | 59 if session.roster[item.attr.jid] then |
| 71 end | 70 end |
| 72 end | 71 end |
| 73 end | 72 end |
| 74 local success, err_type, err_cond, err_msg = rm_add_to_roster(session, item.attr.jid, r_item); | 73 local success, err_type, err_cond, err_msg = rm_add_to_roster(session, item.attr.jid, r_item); |
| 75 if success then | 74 if success then |
| 76 send(session, st.reply(stanza)); | 75 session.send(st.reply(stanza)); |
| 77 rm_roster_push(from_node, from_host, item.attr.jid); | 76 rm_roster_push(from_node, from_host, item.attr.jid); |
| 78 else | 77 else |
| 79 send(session, st.error_reply(stanza, err_type, err_cond, err_msg)); | 78 session.send(st.error_reply(stanza, err_type, err_cond, err_msg)); |
| 80 end | 79 end |
| 81 end | 80 end |
| 82 else | 81 else |
| 83 send(session, st.error_reply(stanza, "cancel", "not-allowed")); | 82 session.send(st.error_reply(stanza, "cancel", "not-allowed")); |
| 84 end | 83 end |
| 85 else | 84 else |
| 86 send(session, st.error_reply(stanza, "modify", "bad-request")); -- FIXME what's the correct error? | 85 session.send(st.error_reply(stanza, "modify", "bad-request")); -- FIXME what's the correct error? |
| 87 end | 86 end |
| 88 else | 87 else |
| 89 send(session, st.error_reply(stanza, "modify", "bad-request")); | 88 session.send(st.error_reply(stanza, "modify", "bad-request")); |
| 90 end | 89 end |
| 91 return true; | 90 return true; |
| 92 end | 91 end |
| 93 end | 92 end |
| 94 end); | 93 end); |