From 0874b93e7ca589b51d0250cd7ec511c4b394beb6 Mon Sep 17 00:00:00 2001 From: Badlop Date: Thu, 10 Jun 2010 12:01:15 +0200 Subject: [PATCH] Support anonymous accounts in Shared Roster @all@ directive (EJAB-1264) With this change, logged anonymous accounts are considered to be registered. --- src/ejabberd_auth_anonymous.erl | 5 +++-- src/mod_shared_roster.erl | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index b0e53ca6b..787d96b46 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -143,6 +143,7 @@ register_connection(SID, #jid{luser = LUser, lserver = LServer}, Info) -> AuthModule = xml:get_attr_s(auth_module, Info), case AuthModule == ?MODULE of true -> + ejabberd_hooks:run(register_user, LServer, [LUser, LServer]), US = {LUser, LServer}, mnesia:sync_dirty( fun() -> mnesia:write(#anonymous{us = US, sid=SID}) @@ -215,8 +216,8 @@ try_register(_User, _Server, _Password) -> dirty_get_registered_users() -> []. -get_vh_registered_users(_Server) -> - []. +get_vh_registered_users(Server) -> + [{U, S} || {U, S, _R} <- ejabberd_sm:get_vh_session_list(Server)]. %% Return password of permanent user or false for anonymous users diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 14879cce0..8faf3528d 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -93,6 +93,8 @@ start(Host, _Opts) -> ?MODULE, unset_presence, 50), ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 50), + ejabberd_hooks:add(anonymous_purge_hook, Host, + ?MODULE, remove_user, 50), ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50). %%ejabberd_hooks:add(remove_user, Host, @@ -121,6 +123,8 @@ stop(Host) -> ?MODULE, unset_presence, 50), ejabberd_hooks:delete(register_user, Host, ?MODULE, register_user, 50), + ejabberd_hooks:delete(anonymous_purge_hook, Host, + ?MODULE, remove_user, 50), ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50). %%ejabberd_hooks:delete(remove_user, Host,