Skip to content

Commit

Permalink
Stop ringing if another resource picks up
Browse files Browse the repository at this point in the history
  • Loading branch information
singpolyma committed Jul 3, 2024
1 parent 9d5716b commit 40a29b5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions snikket/Client.hx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ class Client extends EventEmitter {
final stanza:Stanza = event.stanza;
final from = stanza.attr.get("from") == null ? null : JID.parse(stanza.attr.get("from"));

var fwd = null;
if (from != null && from.asBare().asString() == accountId()) {
var carbon = stanza.getChild("received", "urn:xmpp:carbons:2");
if (carbon == null) carbon = stanza.getChild("sent", "urn:xmpp:carbons:2");
if (carbon != null) {
fwd = carbon.getChild("forwarded", "urn:xmpp:forward:0")?.getFirstChild();
}
}

final jmiP = stanza.getChild("propose", "urn:xmpp:jingle-message:0");
if (jmiP != null && jmiP.attr.get("id") != null) {
final session = new IncomingProposedSession(this, from, jmiP.attr.get("id"));
Expand All @@ -140,6 +149,17 @@ class Client extends EventEmitter {
}
}

// Another resource picked this up
final jmiProFwd = fwd?.getChild("proceed", "urn:xmpp:jingle-message:0");
if (jmiProFwd != null && jmiProFwd.attr.get("id") != null) {
final chat = getDirectChat(JID.parse(fwd.attr.get("to")).asBare().asString());
final session = chat.jingleSessions.get(jmiProFwd.attr.get("id"));
if (session != null) {
session.retract();
chat.jingleSessions.remove(session.sid);
}
}

final jmiPro = stanza.getChild("proceed", "urn:xmpp:jingle-message:0");
if (jmiPro != null && jmiPro.attr.get("id") != null) {
final chat = getDirectChat(from.asBare().asString());
Expand Down

0 comments on commit 40a29b5

Please sign in to comment.