25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-10 16:58:46 +01:00

make caps store only required user_caps_default

SVN Revision: 1749
This commit is contained in:
Christophe Romain 2008-12-23 10:54:25 +00:00
parent 252a08e037
commit d153b773a3

View File

@ -234,11 +234,17 @@ handle_cast({note_caps, From,
#state{host = Host, disco_requests = Requests} = State) -> #state{host = Host, disco_requests = Requests} = State) ->
%% XXX: this leads to race conditions where ejabberd will send %% XXX: this leads to race conditions where ejabberd will send
%% lots of caps disco requests. %% lots of caps disco requests.
{_, _, R} = jlib:jid_tolower(From), {U, S, R} = jlib:jid_tolower(From),
BJID = list_to_binary(jlib:jid_to_string(From)), BJID = list_to_binary(jlib:jid_to_string(From)),
BUID = list_to_binary(jlib:jid_to_string(jlib:jid_remove_resource(From))),
mnesia:dirty_write(#user_caps{jid = BJID, caps = Caps}), mnesia:dirty_write(#user_caps{jid = BJID, caps = Caps}),
mnesia:dirty_write(#user_caps_default{uid = BUID, resource = R}), case ejabberd_sm:get_user_resources(U, S) of
[] ->
ok;
_ ->
% only store default resource of external contacts
BUID = list_to_binary(jlib:jid_to_string(jlib:jid_remove_resource(From))),
mnesia:dirty_write(#user_caps_default{uid = BUID, resource = R})
end,
SubNodes = [Version | Exts], SubNodes = [Version | Exts],
%% Now, find which of these are not already in the database. %% Now, find which of these are not already in the database.
Fun = fun() -> Fun = fun() ->