Software /
code /
prosody
Comparison
plugins/mod_pep.lua @ 1323:e1bfe7816761
mod_pep: Maintain user nodes for delayed delivery
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sat, 06 Jun 2009 18:22:29 +0500 |
parent | 1136:506012db54e8 |
child | 1324:dc64a841f0c2 |
comparison
equal
deleted
inserted
replaced
1317:f6e56a555c37 | 1323:e1bfe7816761 |
---|---|
5 local hosts = hosts; | 5 local hosts = hosts; |
6 local user_exists = require "core.usermanager".user_exists; | 6 local user_exists = require "core.usermanager".user_exists; |
7 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; | 7 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
8 local pairs, ipairs = pairs, ipairs; | 8 local pairs, ipairs = pairs, ipairs; |
9 | 9 |
10 local data = {}; | |
11 | |
10 local function publish(session, node, item) | 12 local function publish(session, node, item) |
11 local stanza = st.message({from=session.full_jid, type='headline'}) | 13 local stanza = st.message({from=session.full_jid, type='headline'}) |
12 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) | 14 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
13 :tag('items', {node=node}) | 15 :tag('items', {node=node}) |
14 :add_child(item) | 16 :add_child(item) |
15 :up() | 17 :up() |
16 :up(); | 18 :up(); |
17 | 19 |
20 local bare = session.username..'@'..session.host; | |
21 -- store for the future | |
22 local user_data = data[bare]; | |
23 if not user_data then user_data = {}; data[bare] = user_data; end | |
24 user_data[node] = stanza; | |
25 | |
18 -- broadcast to resources | 26 -- broadcast to resources |
19 stanza.attr.to = session.username..'@'..session.host; | 27 stanza.attr.to = bare; |
20 core_route_stanza(session, stanza); | 28 core_route_stanza(session, stanza); |
21 | 29 |
22 -- broadcast to contacts | 30 -- broadcast to contacts |
23 for jid, item in pairs(session.roster) do | 31 for jid, item in pairs(session.roster) do |
24 if jid and jid ~= "pending" and (item.subscription == 'from' or item.subscription == 'both') then | 32 if jid and jid ~= "pending" and (item.subscription == 'from' or item.subscription == 'both') then |