]> granicus.if.org Git - ejabberd/commitdiff
make caps store only required user_caps_default
authorChristophe Romain <christophe.romain@process-one.net>
Tue, 23 Dec 2008 10:51:44 +0000 (10:51 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Tue, 23 Dec 2008 10:51:44 +0000 (10:51 +0000)
SVN Revision: 1747

src/mod_caps.erl

index 408415bbb40b47173d91298ac4bab664c703604f..d39deb0f88b13521b09e2e1e969ba3d41db38362 100644 (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() ->