make caps store only required user_caps_default

SVN Revision: 1747
This commit is contained in:
Christophe Romain 2008-12-23 10:51:44 +00:00
parent 5adfcfad7a
commit 4d20367a0c
1 changed files with 9 additions and 3 deletions

View File

@ -234,11 +234,17 @@ handle_cast({note_caps, From,
#state{host = Host, disco_requests = Requests} = State) ->
%% XXX: this leads to race conditions where ejabberd will send
%% lots of caps disco requests.
{_, _, R} = jlib:jid_tolower(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_default{uid = BUID, resource = R}),
case ejabberd_sm:get_user_resources(LUser, LServer) of
[] ->
ok;
_ ->
% only store default resource of external contacts
{_, _, R} = jlib:jid_tolower(From),
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],
%% Now, find which of these are not already in the database.
Fun = fun() ->