Skip to content

Commit

Permalink
XEP-0352: Pass chat states of other resources
Browse files Browse the repository at this point in the history
Don't hold back (carbon copies of) chat states from other resources, as
they might be used to sync the state of conversations across clients.
E.g., if one client becomes active, another one might want to remove a
notification (immediately).
  • Loading branch information
weiss committed Jun 3, 2015
1 parent 6e83a02 commit e7f87a7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/mod_client_state.erl
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,21 @@ filter_presence(Acc, _Host, _Stanza) -> Acc.

filter_chat_states({C2SState, _OutStanzas} = Acc, Host,
#xmlel{name = <<"message">>} = Stanza) ->
case jlib:is_standalone_chat_state(jlib:unwrap_carbon(Stanza)) of
Payload = jlib:unwrap_carbon(Stanza),
case jlib:is_standalone_chat_state(Payload) of
true ->
?DEBUG("Got standalone chat state notification", []),
queue_add(chatstate, Stanza, Host, C2SState);
From = fxml:get_tag_attr_s(<<"from">>, Payload),
To = fxml:get_tag_attr_s(<<"to">>, Payload),
case {jid:from_string(From), jid:from_string(To)} of
{#jid{luser = U, lserver = S}, #jid{luser = U, lserver = S}} ->
%% Don't queue (carbon copies of) chat states from other
%% resources, as they might be used to sync the state of
%% conversations across clients.
Acc;
_ ->
?DEBUG("Got standalone chat state notification", []),
queue_add(chatstate, Stanza, Host, C2SState)
end;
false ->
Acc
end;
Expand Down

0 comments on commit e7f87a7

Please sign in to comment.