plugins/mod_pep.lua
branch0.11
changeset 12092 e5028f6eb599
parent 12091 19f67d44ec37
child 12093 76b4e3f12b53
equal deleted inserted replaced
12091:19f67d44ec37 12092:e5028f6eb599
     7 local calculate_hash = require "util.caps".calculate_hash;
     7 local calculate_hash = require "util.caps".calculate_hash;
     8 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
     8 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
     9 local cache = require "util.cache";
     9 local cache = require "util.cache";
    10 local set = require "util.set";
    10 local set = require "util.set";
    11 local storagemanager = require "core.storagemanager";
    11 local storagemanager = require "core.storagemanager";
       
    12 local usermanager = require "core.usermanager";
    12 
    13 
    13 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
    14 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
    14 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
    15 local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
    15 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
    16 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
    16 
    17 
   172 		end
   173 		end
   173 		return broadcast_to;
   174 		return broadcast_to;
   174 	end
   175 	end
   175 end
   176 end
   176 
   177 
       
   178 local nobody_service = pubsub.new({
       
   179 	service = pubsub.new({
       
   180 		node_defaults = {
       
   181 			["max_items"] = 1;
       
   182 			["persist_items"] = false;
       
   183 			["access_model"] = "presence";
       
   184 			["send_last_published_item"] = "on_sub_and_presence";
       
   185 		};
       
   186 	});
       
   187 });
       
   188 
   177 function get_pep_service(username)
   189 function get_pep_service(username)
   178 	module:log("debug", "get_pep_service(%q)", username);
   190 	module:log("debug", "get_pep_service(%q)", username);
   179 	local user_bare = jid_join(username, host);
   191 	local user_bare = jid_join(username, host);
   180 	local service = services[username];
   192 	local service = services[username];
   181 	if service then
   193 	if service then
   182 		return service;
   194 		return service;
       
   195 	end
       
   196 	if not usermanager.user_exists(username, host) then
       
   197 		return nobody_service;
   183 	end
   198 	end
   184 	service = pubsub.new({
   199 	service = pubsub.new({
   185 		pep_username = username;
   200 		pep_username = username;
   186 		node_defaults = {
   201 		node_defaults = {
   187 			["max_items"] = 1;
   202 			["max_items"] = 1;