end
elseif t == "unavailable" then
if recipients[user] then recipients[user][stanza.attr.from] = nil; end
+ elseif not self and t == "unsubscribe" then
+ local from = jid_bare(stanza.attr.from);
+ local subscriptions = recipients[user];
+ if subscriptions then
+ for subscriber in pairs(subscriptions) do
+ if jid_bare(subscriber) == from then
+ recipients[user][subscriber] = nil;
+ end
+ end
+ end
end
end, 10);
end
hash_map[ver] = notify; -- update hash map
if self then
- for jid, item in pairs(origin.roster) do -- for all interested contacts
+ for jid, item in pairs(session.roster) do -- for all interested contacts
if item.subscription == "both" or item.subscription == "from" then
if not recipients[jid] then recipients[jid] = {}; end
recipients[jid][contact] = notify;
+ publish_all(jid, contact, session);
end
end
- else
- recipients[user][contact] = notify; -- set recipient's data to calculated data
end
+ recipients[user][contact] = notify; -- set recipient's data to calculated data
-- send messages to recipient
publish_all(user, contact, session);
end