mod_privilege: added permissions notification on initial presence for entities which are not components
authorGoffi <goffi@goffi.org>
Thu, 02 Apr 2015 21:47:05 +0200
changeset 1663 495a093798eb
parent 1662 1146cb4493a9
child 1664 d1072db4db44
mod_privilege: added permissions notification on initial presence for entities which are not components
mod_privilege/mod_privilege.lua
--- a/mod_privilege/mod_privilege.lua	Tue Mar 31 17:27:13 2015 +0200
+++ b/mod_privilege/mod_privilege.lua	Thu Apr 02 21:47:05 2015 +0200
@@ -73,8 +73,18 @@
 	session.privileges = ent_priv
 end
 
+function on_presence(event)
+	-- Permission are already checked at this point,
+	-- we only advertise them to the entity
+	local session, stanza = event.origin, event.stanza;
+	if session.privileges then
+		advertise_perm(session.full_jid, session.privileges)
+	end
+end
+
 module:hook('authentication-success', on_auth)
 module:hook('component-authenticated', on_auth)
+module:hook('presence/initial', on_presence)
 
 
 --> roster permission <--