25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Fix problems when deleting a roster item.

The deleted item was left on the user roster, and unsubscribe presence stanza wasn't sent to the unsubscribed user.

SVN Revision: 2420
This commit is contained in:
Pablo Polvorin 2009-08-05 17:39:47 +00:00
parent 14399e3d57
commit 92ad67a814
2 changed files with 22 additions and 30 deletions

View File

@ -271,8 +271,7 @@ process_item_set(From, To, #xmlel{} = El) ->
Item2 = process_item_els(Item1, El#xmlel.children), Item2 = process_item_els(Item1, El#xmlel.children),
case Item2#roster.subscription of case Item2#roster.subscription of
remove -> remove ->
send_unsubscribing_presence(From, Item), mnesia:delete({roster, {LUser, LServer, LJID}});
ok;
_ -> _ ->
mnesia:write(Item2) mnesia:write(Item2)
end, end,
@ -725,28 +724,24 @@ send_unsubscribing_presence(From, Item) ->
from -> true; from -> true;
_ -> false _ -> false
end, end,
{INode, IDom, IRes} = Item#roster.jid, {INode, IDom, IRes} = Item#roster.jid,
SendToJID = exmpp_jid:make(INode, IDom, IRes), SendToJID = exmpp_jid:make(INode, IDom, IRes),
if IsTo -> if IsTo ->
send_presence_type( ejabberd_router:route(
jlib:jid_remove_resource(From), exmpp_jid:bare(From),
SendToJID, "unsubscribe"); SendToJID,
exmpp_presence:unsubscribe());
true -> ok true -> ok
end, end,
if IsFrom -> if IsFrom ->
send_presence_type( ejabberd_router:route(
jlib:jid_remove_resource(From), exmpp_jid:bare(From),
SendToJID, "unsubscribed"); SendToJID,
exmpp_presence:unsubscribed());
true -> ok true -> ok
end, end,
ok. ok.
send_presence_type(From, To, Type) ->
ejabberd_router:route(
From, To,
{xmlelement, "presence",
[{"type", Type}],
[]}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

View File

@ -253,8 +253,7 @@ process_item_set(From, To, #xmlel{} = El) ->
Item2 = process_item_els(Item1, El#xmlel.children), Item2 = process_item_els(Item1, El#xmlel.children),
case Item2#roster.subscription of case Item2#roster.subscription of
remove -> remove ->
send_unsubscribing_presence(From, Item), odbc_queries:del_roster(LServer, Username, SJID);
ok;
_ -> _ ->
ItemVals = record_to_string(Item2), ItemVals = record_to_string(Item2),
ItemGroups = groups_to_string(Item2), ItemGroups = groups_to_string(Item2),
@ -661,26 +660,24 @@ send_unsubscribing_presence(From, Item) ->
from -> true; from -> true;
_ -> false _ -> false
end, end,
{INode, IDom, IRes} = Item#roster.jid,
SendToJID = exmpp_jid:make(INode, IDom, IRes),
if IsTo -> if IsTo ->
send_presence_type( ejabberd_router:route(
jlib:jid_remove_resource(From), exmpp_jid:bare(From),
jlib:make_jid(Item#roster.jid), "unsubscribe"); SendToJID,
exmpp_presence:unsubscribe());
true -> ok true -> ok
end, end,
if IsFrom -> if IsFrom ->
send_presence_type( ejabberd_router:route(
jlib:jid_remove_resource(From), exmpp_jid:bare(From),
jlib:make_jid(Item#roster.jid), "unsubscribed"); SendToJID,
exmpp_presence:unsubscribed());
true -> ok true -> ok
end, end,
ok. ok.
send_presence_type(From, To, Type) ->
ejabberd_router:route(
From, To,
{xmlelement, "presence",
[{"type", Type}],
[]}).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%