diff options
author | Badlop <badlop@process-one.net> | 2011-03-01 22:32:50 +0100 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-03-01 22:33:11 +0100 |
commit | 1548a18b5eca70123d1449d9d63cd5e54c683b8b (patch) | |
tree | 2b7552ece3245551945c3c7df3bceb9b46731043 /src | |
parent | ejabberdctl needs space between INET_DIST_INTERFACE (thanks to Dale Chase)(EJ... (diff) |
mod_irc must send presence unavailable to the departing occupant (EJAB-1417)
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_irc/mod_irc_connection.erl | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/src/mod_irc/mod_irc_connection.erl b/src/mod_irc/mod_irc_connection.erl index 55432dd1..c342f287 100644 --- a/src/mod_irc/mod_irc_connection.erl +++ b/src/mod_irc/mod_irc_connection.erl @@ -219,6 +219,7 @@ handle_info({route_chan, Channel, Resource, NewStateData = case xml:get_attr_s("type", Attrs) of "unavailable" -> + send_stanza_unavailable(Channel, StateData), S1 = ?SEND(io_lib:format("PART #~s\r\n", [Channel])), S1#state{channels = dict:erase(Channel, S1#state.channels)}; @@ -656,13 +657,9 @@ terminate(_Reason, _StateName, FullStateData) -> bounce_messages("Server Connect Failed"), lists:foreach( fun(Chan) -> - ejabberd_router:route( - jlib:make_jid( - lists:concat([Chan, "%", StateData#state.server]), - StateData#state.host, StateData#state.nick), - StateData#state.user, - {xmlelement, "presence", [{"type", "error"}], - [Error]}) + Stanza = {xmlelement, "presence", [{"type", "error"}], + [Error]}, + send_stanza(Chan, StateData, Stanza) end, dict:fetch_keys(StateData#state.channels)), case StateData#state.socket of undefined -> @@ -672,6 +669,30 @@ terminate(_Reason, _StateName, FullStateData) -> end, ok. +send_stanza(Chan, StateData, Stanza) -> + ejabberd_router:route( + jlib:make_jid( + lists:concat([Chan, "%", StateData#state.server]), + StateData#state.host, StateData#state.nick), + StateData#state.user, + Stanza). + +send_stanza_unavailable(Chan, StateData) -> + Affiliation = "member", % this is a simplification + Role = "none", + Stanza = + {xmlelement, "presence", [{"type", "unavailable"}], + [{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}], + [{xmlelement, "item", + [{"affiliation", Affiliation}, + {"role", Role}], + []}, + {xmlelement, "status", + [{"code", "110"}], + []} + ]}]}, + send_stanza(Chan, StateData, Stanza). + %%%---------------------------------------------------------------------- %%% Internal functions %%%---------------------------------------------------------------------- |