plugins/mod_presence.lua
changeset 8731 41c959c5c84b
parent 8582 801ae5cb1341
child 9675 e50559a42dfe
child 9792 f47b2ab877d0
equal deleted inserted replaced
8730:285075a27f28 8731:41c959c5c84b
   251 	stanza.attr.from, stanza.attr.to = st_from, st_to;
   251 	stanza.attr.from, stanza.attr.to = st_from, st_to;
   252 	return true;
   252 	return true;
   253 end
   253 end
   254 
   254 
   255 local outbound_presence_handler = function(data)
   255 local outbound_presence_handler = function(data)
   256 	-- outbound presence recieved
   256 	-- outbound presence received
   257 	local origin, stanza = data.origin, data.stanza;
   257 	local origin, stanza = data.origin, data.stanza;
   258 
   258 
   259 	local to = stanza.attr.to;
   259 	local to = stanza.attr.to;
   260 	if to then
   260 	if to then
   261 		local t = stanza.attr.type;
   261 		local t = stanza.attr.type;
   279 module:hook("pre-presence/full", outbound_presence_handler);
   279 module:hook("pre-presence/full", outbound_presence_handler);
   280 module:hook("pre-presence/bare", outbound_presence_handler);
   280 module:hook("pre-presence/bare", outbound_presence_handler);
   281 module:hook("pre-presence/host", outbound_presence_handler);
   281 module:hook("pre-presence/host", outbound_presence_handler);
   282 
   282 
   283 module:hook("presence/bare", function(data)
   283 module:hook("presence/bare", function(data)
   284 	-- inbound presence to bare JID recieved
   284 	-- inbound presence to bare JID received
   285 	local origin, stanza = data.origin, data.stanza;
   285 	local origin, stanza = data.origin, data.stanza;
   286 
   286 
   287 	local to = stanza.attr.to;
   287 	local to = stanza.attr.to;
   288 	local t = stanza.attr.type;
   288 	local t = stanza.attr.type;
   289 	if to then
   289 	if to then
   305 		origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type"));
   305 		origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid presence type"));
   306 	end
   306 	end
   307 	return true;
   307 	return true;
   308 end);
   308 end);
   309 module:hook("presence/full", function(data)
   309 module:hook("presence/full", function(data)
   310 	-- inbound presence to full JID recieved
   310 	-- inbound presence to full JID received
   311 	local origin, stanza = data.origin, data.stanza;
   311 	local origin, stanza = data.origin, data.stanza;
   312 
   312 
   313 	local t = stanza.attr.type;
   313 	local t = stanza.attr.type;
   314 	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID
   314 	if t ~= nil and t ~= "unavailable" and t ~= "error" then -- check for subscriptions and probes sent to full JID
   315 		return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));
   315 		return handle_inbound_presence_subscriptions_and_probes(origin, stanza, jid_bare(stanza.attr.from), jid_bare(stanza.attr.to));