Software /
code /
prosody
Comparison
plugins/mod_pep.lua @ 3130:80e630e60f06
mod_pep: Use is_contact_subscribed (which uses the new rostermanager fix to avoid unnecessary roster loads)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 01 Jun 2010 20:10:17 +0100 |
parent | 2925:692b3c6c5bd2 |
child | 3132:4d2251242ac1 |
comparison
equal
deleted
inserted
replaced
3129:125f03db0b1a | 3130:80e630e60f06 |
---|---|
14 local user_exists = require "core.usermanager".user_exists; | 14 local user_exists = require "core.usermanager".user_exists; |
15 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; | 15 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
16 local pairs, ipairs = pairs, ipairs; | 16 local pairs, ipairs = pairs, ipairs; |
17 local next = next; | 17 local next = next; |
18 local type = type; | 18 local type = type; |
19 local load_roster = require "core.rostermanager".load_roster; | |
20 local sha1 = require "util.hashes".sha1; | 19 local sha1 = require "util.hashes".sha1; |
21 local base64 = require "util.encodings".base64.encode; | 20 local base64 = require "util.encodings".base64.encode; |
22 | 21 |
23 local NULL = {}; | 22 local NULL = {}; |
24 local data = {}; | 23 local data = {}; |
38 module:add_feature("http://jabber.org/protocol/pubsub#publish"); | 37 module:add_feature("http://jabber.org/protocol/pubsub#publish"); |
39 | 38 |
40 local function subscription_presence(user_bare, recipient) | 39 local function subscription_presence(user_bare, recipient) |
41 local recipient_bare = jid_bare(recipient); | 40 local recipient_bare = jid_bare(recipient); |
42 if (recipient_bare == user_bare) then return true end | 41 if (recipient_bare == user_bare) then return true end |
43 local item = load_roster(jid_split(user_bare))[recipient_bare]; | 42 local username, host = jid_split(user_bare); |
44 return item and (item.subscription == 'from' or item.subscription == 'both'); | 43 return is_contact_subscribed(username, host, recipient_bare); |
45 end | 44 end |
46 | 45 |
47 local function publish(session, node, id, item) | 46 local function publish(session, node, id, item) |
48 item.attr.xmlns = nil; | 47 item.attr.xmlns = nil; |
49 local disable = #item.tags ~= 1 or #item.tags[1] == 0; | 48 local disable = #item.tags ~= 1 or #item.tags[1] == 0; |