equal
deleted
inserted
replaced
65 local ret, err = dm.store(username, host, "accounts", {password = password}); |
65 local ret, err = dm.store(username, host, "accounts", {password = password}); |
66 print("["..(err or "success").."] stored account: "..username.."@"..host.." = "..password); |
66 print("["..(err or "success").."] stored account: "..username.."@"..host.." = "..password); |
67 end |
67 end |
68 |
68 |
69 function store_roster(username, host, roster_items) |
69 function store_roster(username, host, roster_items) |
70 -- fetch current roster-table for username@host if he already has one |
70 -- fetch current roster-table for username@host if they already have one |
71 local roster = dm.load(username, host, "roster") or {}; |
71 local roster = dm.load(username, host, "roster") or {}; |
72 -- merge imported roster-items with loaded roster |
72 -- merge imported roster-items with loaded roster |
73 for item_tag in roster_items:childtags("item") do |
73 for item_tag in roster_items:childtags("item") do |
74 -- jid for this roster-item |
74 -- jid for this roster-item |
75 local item_jid = item_tag.attr.jid |
75 local item_jid = item_tag.attr.jid |
127 |
127 |
128 |
128 |
129 function store_subscription_request(username, host, presence_stanza) |
129 function store_subscription_request(username, host, presence_stanza) |
130 local from_bare = presence_stanza.attr.from; |
130 local from_bare = presence_stanza.attr.from; |
131 |
131 |
132 -- fetch current roster-table for username@host if he already has one |
132 -- fetch current roster-table for username@host if they already have one |
133 local roster = dm.load(username, host, "roster") or {}; |
133 local roster = dm.load(username, host, "roster") or {}; |
134 |
134 |
135 local item = roster[from_bare]; |
135 local item = roster[from_bare]; |
136 if item and (item.subscription == "from" or item.subscription == "both") then |
136 if item and (item.subscription == "from" or item.subscription == "both") then |
137 return; -- already subscribed, do nothing |
137 return; -- already subscribed, do nothing |