diff options
author | Alexey Shchepin <alexey@process-one.net> | 2004-01-18 20:42:09 +0000 |
---|---|---|
committer | Alexey Shchepin <alexey@process-one.net> | 2004-01-18 20:42:09 +0000 |
commit | 273886701bd8d033330037ff7997b7bfe6e3f501 (patch) | |
tree | f727c495c2151325034594ebcb7ae8606478f064 /src/mod_roster.erl | |
parent | * src/mod_muc/mod_muc_room.erl: Bugfix, updated error codes (diff) |
* src/ejabberd_ctl.erl: Added commands for backup processing
* src/ejabberd_c2s.erl: Added processing of xml:lang according to
latest XMPP-IM draft
* src/xml.erl: Added replace_tag_attr/3 function
* src/mod_roster.erl: Added auto-reply on incoming subscription
request according to latest XMPP-IM draft
* src/mod_offline.erl: Added pop_offline_messages/1 function
* src/ejabberd_c2s.erl: Updated sending of offline messages
SVN Revision: 200
Diffstat (limited to '')
-rw-r--r-- | src/mod_roster.erl | 48 |
1 files changed, 41 insertions, 7 deletions
diff --git a/src/mod_roster.erl b/src/mod_roster.erl index cbb6085a..836dbdba 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -375,22 +375,45 @@ process_subscription(Direction, User, JID1, Type) -> Item#roster.ask, Type) end, + AutoReply = case Direction of + out -> + none; + in -> + in_auto_reply(Item#roster.subscription, + Item#roster.ask, + Type) + end, case NewState of none -> - none; + {none, AutoReply}; {Subscription, Pending} -> NewItem = Item#roster{subscription = Subscription, ask = Pending}, mnesia:write(NewItem), - {push, NewItem} + {{push, NewItem}, AutoReply} end end, case mnesia:transaction(F) of - {atomic, ok} -> - false; - {atomic, {push, Item}} -> - push_item(User, {"", ?MYNAME, ""}, Item), - true; + {atomic, {Push, AutoReply}} -> + case AutoReply of + none -> + ok; + _ -> + T = case AutoReply of + subscribed -> "subscribed"; + unsubscribed -> "unsubscribed" + end, + ejabberd_router:route( + {User, ?MYNAME, ""}, JID1, + {xmlelement, "presence", [{"type", T}], []}) + end, + case Push of + {push, Item} -> + push_item(User, {"", ?MYNAME, ""}, Item), + true; + none -> + false + end; _ -> false end. @@ -474,6 +497,17 @@ out_state_change(both, none, subscribed) -> none; out_state_change(both, none, unsubscribe) -> {from, none}; out_state_change(both, none, unsubscribed) -> {to, none}. +in_auto_reply(from, none, subscribe) -> subscribed; +in_auto_reply(from, out, subscribe) -> subscribed; +in_auto_reply(both, none, subscribe) -> subscribed; +in_auto_reply(none, in, unsubscribe) -> unsubscribed; +in_auto_reply(none, both, unsubscribe) -> unsubscribed; +in_auto_reply(to, in, unsubscribe) -> unsubscribed; +in_auto_reply(from, none, unsubscribe) -> unsubscribed; +in_auto_reply(from, out, unsubscribe) -> unsubscribed; +in_auto_reply(both, none, unsubscribe) -> unsubscribed; +in_auto_reply(_, _, _) -> none. + remove_user(User) -> LUser = jlib:nodeprep(User), |