| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-04 16:14:04 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-04 16:14:04 UTC |
| parent | c81c44cf06f5f6ff0836c82e196b7ea2bba6496d |
| snikket/ChatMessage.hx | +4 | -1 |
diff --git a/snikket/ChatMessage.hx b/snikket/ChatMessage.hx index a011837..6e16313 100644 --- a/snikket/ChatMessage.hx +++ b/snikket/ChatMessage.hx @@ -280,7 +280,10 @@ class ChatMessage { final codepoints = StringUtil.codepointArray(text ?? ""); // TODO: not every app will implement every feature. How should the app tell us what fallbacks to handle? final fallbacks: Array<{start: Int, end: Int}> = cast payloads.filter( - (p) -> p.attr.get("xmlns") == "urn:xmpp:fallback:0" && (p.attr.get("for") == "jabber:x:oob" || p.attr.get("for") == "urn:xmpp:sims:1" || (replyToMessage != null && p.attr.get("for") == "urn:xmpp:reply:0") || p.attr.get("for") == "http://jabber.org/protocol/address") + (p) -> p.attr.get("xmlns") == "urn:xmpp:fallback:0" && + (((p.attr.get("for") == "jabber:x:oob" || p.attr.get("for") == "urn:xmpp:sims:1") && attachments.length > 0) || + (replyToMessage != null && p.attr.get("for") == "urn:xmpp:reply:0") || + p.attr.get("for") == "http://jabber.org/protocol/address") ).map((p) -> p.getChild("body")).map((b) -> b == null ? null : { start: Std.parseInt(b.attr.get("start") ?? "0") ?? 0, end: Std.parseInt(b.attr.get("end") ?? Std.string(codepoints.length)) ?? codepoints.length }).filter((b) -> b != null); fallbacks.sort((x, y) -> y.start - x.start); for (fallback in fallbacks) {