|  | @@ -1,55 +0,0 @@
 | 
	
		
			
			| 1 |  | ---
 | 
	
		
			
			| 2 |  | ---
 | 
	
		
			
			| 3 |  | -
 | 
	
		
			
			| 4 |  | -local jid_bare = require "util.jid".bare;
 | 
	
		
			
			| 5 |  | -local st = require "util.stanza"
 | 
	
		
			
			| 6 |  | -local white_listed_namespace = "eu.siacs.conversations.axolotl."
 | 
	
		
			
			| 7 |  | -local disco_feature_namespace = white_listed_namespace .. "whitelisted"
 | 
	
		
			
			| 8 |  | -
 | 
	
		
			
			| 9 |  | -local mod_pep = module:depends"pep";
 | 
	
		
			
			| 10 |  | -local pep_data = mod_pep.module.save().data;
 | 
	
		
			
			| 11 |  | -
 | 
	
		
			
			| 12 |  | -local function on_account_disco_info(event)
 | 
	
		
			
			| 13 |  | -	(event.reply or event.stanza):tag("feature", {var=disco_feature_namespace}):up();
 | 
	
		
			
			| 14 |  | -end
 | 
	
		
			
			| 15 |  | -
 | 
	
		
			
			| 16 |  | -local function on_pep_request(event)
 | 
	
		
			
			| 17 |  | -	local session, stanza = event.origin, event.stanza
 | 
	
		
			
			| 18 |  | -	local payload = stanza.tags[1];
 | 
	
		
			
			| 19 |  | -	if stanza.attr.type == 'get' then
 | 
	
		
			
			| 20 |  | -		local node, requested_id;
 | 
	
		
			
			| 21 |  | -		payload = payload.tags[1]
 | 
	
		
			
			| 22 |  | -		if payload and payload.name == 'items' then
 | 
	
		
			
			| 23 |  | -			node = payload.attr.node
 | 
	
		
			
			| 24 |  | -			local item = payload.tags[1];
 | 
	
		
			
			| 25 |  | -			if item and item.name == 'item' then
 | 
	
		
			
			| 26 |  | -				requested_id = item.attr.id;
 | 
	
		
			
			| 27 |  | -			end 
 | 
	
		
			
			| 28 |  | -		end
 | 
	
		
			
			| 29 |  | -		if node and string.sub(node,1,string.len(white_listed_namespace)) == white_listed_namespace then
 | 
	
		
			
			| 30 |  | -			local user = stanza.attr.to and jid_bare(stanza.attr.to) or session.username..'@'..session.host;
 | 
	
		
			
			| 31 |  | -			local user_data = pep_data[user];
 | 
	
		
			
			| 32 |  | -			if user_data and user_data[node] then
 | 
	
		
			
			| 33 |  | -				local id, item = unpack(user_data[node]);
 | 
	
		
			
			| 34 |  | -				if not requested_id or id == requested_id then
 | 
	
		
			
			| 35 |  | -					local stanza = st.reply(stanza)
 | 
	
		
			
			| 36 |  | -						:tag('pubsub', {xmlns='http://jabber.org/protocol/pubsub'})
 | 
	
		
			
			| 37 |  | -							:tag('items', {node=node})
 | 
	
		
			
			| 38 |  | -								:add_child(item)
 | 
	
		
			
			| 39 |  | -							:up()
 | 
	
		
			
			| 40 |  | -						:up();
 | 
	
		
			
			| 41 |  | -					session.send(stanza);
 | 
	
		
			
			| 42 |  | -					module:log("debug","provided access to omemo node",node)
 | 
	
		
			
			| 43 |  | -					return true;
 | 
	
		
			
			| 44 |  | -				end
 | 
	
		
			
			| 45 |  | -			end
 | 
	
		
			
			| 46 |  | -			module:log("debug","requested node was white listed", node)
 | 
	
		
			
			| 47 |  | -		end
 | 
	
		
			
			| 48 |  | -	end
 | 
	
		
			
			| 49 |  | -end
 | 
	
		
			
			| 50 |  | -
 | 
	
		
			
			| 51 |  | -module:hook("iq/bare/http://jabber.org/protocol/pubsub:pubsub", on_pep_request, 10);
 | 
	
		
			
			| 52 |  | -module:hook("account-disco-info", on_account_disco_info);
 |