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

mod_irc must send presence unavailable to the departing occupant (EJAB-1417)

This commit is contained in:
Badlop 2011-03-01 22:32:50 +01:00
parent 339fa6e41b
commit 1548a18b5e

View File

@ -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
%%%----------------------------------------------------------------------