From 2d2ea29a20d2a782c60efcdc878dc2e4f5d5c202 Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Tue, 6 Jun 2023 08:49:19 +0100 Subject: [PATCH] Applied deadlop patch --- mod_default_rooms/src/mod_default_rooms.erl | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mod_default_rooms/src/mod_default_rooms.erl b/mod_default_rooms/src/mod_default_rooms.erl index 0ba4fa7..a58e71c 100644 --- a/mod_default_rooms/src/mod_default_rooms.erl +++ b/mod_default_rooms/src/mod_default_rooms.erl @@ -32,7 +32,7 @@ mod_doc/0]). %% ejabberd_hooks callbacks. --export([register_user/2]). +-export([register_user/2, set_presence/4]). -include("logger.hrl"). -include_lib("xmpp/include/xmpp.hrl"). @@ -42,10 +42,12 @@ %%-------------------------------------------------------------------- -spec start(binary(), gen_mod:opts()) -> ok. start(Host, _Opts) -> + ejabberd_hooks:add(set_presence_hook, Host, ?MODULE, set_presence, 50), ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 50). -spec stop(binary()) -> ok. stop(Host) -> + ejabberd_hooks:delete(set_presence_hook, Host, ?MODULE, set_presence_hook, 50), ejabberd_hooks:delete(register_user, Host, ?MODULE, register_user, 50). -spec reload(binary(), gen_mod:opts(), gen_mod:opts()) -> ok. @@ -73,6 +75,17 @@ mod_doc() -> %%-------------------------------------------------------------------- %% ejabberd_hooks callbacks. %%-------------------------------------------------------------------- +-spec set_presence(binary(), binary(), binary(), binary()) -> ok | {error, _}. +set_presence(LUser, LServer, _Resource, _Presence) -> + case ejabberd_auth:store_type(LServer) of + external -> + case mod_private:get_data(LUser, LServer) of + [] -> register_user(LUser, LServer); + _ -> ok + end; + _ -> ok + end. + -spec register_user(binary(), binary()) -> ok | {error, _}. register_user(LUser, LServer) -> JID = jid:make(LUser, LServer),