Changeset

1664:6bdcb1418029

mod_privilege: implemented "managed_entity" presence
author Goffi <goffi@goffi.org>
date Tue, 07 Apr 2015 12:47:47 +0200
parents 1663:ca07a6ada631
children 1665:746d94f37a4c
files mod_privilege/mod_privilege.lua
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_privilege/mod_privilege.lua	Tue Apr 07 12:46:34 2015 +0200
+++ b/mod_privilege/mod_privilege.lua	Tue Apr 07 12:47:47 2015 +0200
@@ -287,3 +287,22 @@
 
 	return true
 end);
+
+
+--> presence permission <--
+
+module:hook("presence/bare", function(event)
+	if presence_man_ent:empty() then return; end
+	local session, stanza = event.origin, event.stanza;
+	if stanza.attr.to then return; end
+	if stanza.attr.type == nil or stanza.attr.type == "unavailable" then
+		for entity in presence_man_ent:items() do
+			if stanza.attr.from ~= entity then
+				presence_fwd = st.clone(stanza)
+				presence_fwd.attr.to = entity
+				module:log("debug", "presence forwarded to "..entity..": "..tostring(presence_fwd))
+				prosody.core_route_stanza(nil, presence_fwd)
+			end
+		end
+	end
+end, 150);