From 92ad67a814ae60456c9a6a9fc70828507cd46c0a Mon Sep 17 00:00:00 2001 From: Pablo Polvorin Date: Wed, 5 Aug 2009 17:39:47 +0000 Subject: [PATCH] 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 --- src/mod_roster.erl | 27 +++++++++++---------------- src/mod_roster_odbc.erl | 25 +++++++++++-------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 9d18dd071..564291077 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -271,8 +271,7 @@ process_item_set(From, To, #xmlel{} = El) -> Item2 = process_item_els(Item1, El#xmlel.children), case Item2#roster.subscription of remove -> - send_unsubscribing_presence(From, Item), - ok; + mnesia:delete({roster, {LUser, LServer, LJID}}); _ -> mnesia:write(Item2) end, @@ -725,28 +724,24 @@ send_unsubscribing_presence(From, Item) -> from -> true; _ -> false end, - {INode, IDom, IRes} = Item#roster.jid, - SendToJID = exmpp_jid:make(INode, IDom, IRes), + {INode, IDom, IRes} = Item#roster.jid, + SendToJID = exmpp_jid:make(INode, IDom, IRes), if IsTo -> - send_presence_type( - jlib:jid_remove_resource(From), - SendToJID, "unsubscribe"); + ejabberd_router:route( + exmpp_jid:bare(From), + SendToJID, + exmpp_presence:unsubscribe()); true -> ok end, if IsFrom -> - send_presence_type( - jlib:jid_remove_resource(From), - SendToJID, "unsubscribed"); + ejabberd_router:route( + exmpp_jid:bare(From), + SendToJID, + exmpp_presence:unsubscribed()); true -> ok end, ok. -send_presence_type(From, To, Type) -> - ejabberd_router:route( - From, To, - {xmlelement, "presence", - [{"type", Type}], - []}). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl index 64e125e4a..d79604526 100644 --- a/src/mod_roster_odbc.erl +++ b/src/mod_roster_odbc.erl @@ -253,8 +253,7 @@ process_item_set(From, To, #xmlel{} = El) -> Item2 = process_item_els(Item1, El#xmlel.children), case Item2#roster.subscription of remove -> - send_unsubscribing_presence(From, Item), - ok; + odbc_queries:del_roster(LServer, Username, SJID); _ -> ItemVals = record_to_string(Item2), ItemGroups = groups_to_string(Item2), @@ -661,26 +660,24 @@ send_unsubscribing_presence(From, Item) -> from -> true; _ -> false end, + {INode, IDom, IRes} = Item#roster.jid, + SendToJID = exmpp_jid:make(INode, IDom, IRes), if IsTo -> - send_presence_type( - jlib:jid_remove_resource(From), - jlib:make_jid(Item#roster.jid), "unsubscribe"); + ejabberd_router:route( + exmpp_jid:bare(From), + SendToJID, + exmpp_presence:unsubscribe()); true -> ok end, if IsFrom -> - send_presence_type( - jlib:jid_remove_resource(From), - jlib:make_jid(Item#roster.jid), "unsubscribed"); + ejabberd_router:route( + exmpp_jid:bare(From), + SendToJID, + exmpp_presence:unsubscribed()); true -> ok end, ok. -send_presence_type(From, To, Type) -> - ejabberd_router:route( - From, To, - {xmlelement, "presence", - [{"type", Type}], - []}). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%