| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-06-03 00:30:15 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-06-03 00:30:15 UTC |
| parent | 8698ea35f232d97b992bde05a48223fdac97175d |
| borogove/Notification.hx | +19 | -1 |
| borogove/Push.hx | +23 | -22 |
diff --git a/borogove/Notification.hx b/borogove/Notification.hx index 36d2527..ec88e23 100644 --- a/borogove/Notification.hx +++ b/borogove/Notification.hx @@ -102,6 +102,24 @@ class Notification { ); } + @:allow(borogove) + private static function fromReactionUpdate(m: ReactionUpdate, stanza: Stanza) { + return new Notification( + "Reacted", + m.reactions.map(r -> r.render((s) -> s, (name, uri) -> ":" + name + ":")).join(" "), + JID.parse(stanza.attr.get("to")).asBare().asString(), + m.chatId, + m.senderId, + m.serverId, + stanza.attr.get("type") == "groupchat" ? MessageChannel : MessageChat, + null, + null, + null, + null, + m.timestamp + ); + } + // Sometimes a stanza has not much in it, so make something generic // Assume it is an incoming message of some kind @:allow(borogove) @@ -113,7 +131,7 @@ class Notification { JID.parse(stanza.attr.get("from")).asBare().asString(), JID.parse(stanza.attr.get("from")).asString(), stanza.getChildText("stanza-id", "urn:xmpp:sid:0"), - MessageChat, + stanza.attr.get("type") == "groupchat" ? MessageChannel : MessageChat, null, null, null, diff --git a/borogove/Push.hx b/borogove/Push.hx index e814a71..18dd87a 100644 --- a/borogove/Push.hx +++ b/borogove/Push.hx @@ -35,28 +35,29 @@ class Push { stanza = stanza.getChild("message", "jabber:client"); } if (stanza.attr.get("to") == null) return null; - // Assume incoming message - final message = ChatMessage.fromStanza(stanza, JID.parse(stanza.attr.get("to")).asBare()); - if (message != null) { - // TODO: this puts every push at the same sortId until the next sync - (message.type == MessageChannel ? - persistence.syncPoint(message.account(), message.chatId()).then(point -> point?.sortId ?? "a ") : - persistence.getStreamManagement(message.account()).then(data -> data.sortId) - ).then(sortId -> { - final sortId = FractionalIndexing.between(sortId, null, FractionalIndexing.BASE_95_DIGITS); - final toStore = ChatMessage.fromStanza( - stanza, - JID.parse(stanza.attr.get("to")).asBare(), - (builder, stanza) -> { - builder.sortId = sortId; - return builder; - } - ); - persistence.storeMessages(message.account(), [toStore]); - }); - return Notification.fromChatMessage(message); - } else { - return Notification.fromThinStanza(stanza); + switch (Message.fromStanza(stanza, JID.parse(stanza.attr.get("to")).asBare()).parsed) { + case ChatMessageStanza(message): + // TODO: this puts every push at the same sortId until the next sync + (message.type == MessageChannel ? + persistence.syncPoint(message.account(), message.chatId()).then(point -> point?.sortId ?? "a ") : + persistence.getStreamManagement(message.account()).then(data -> data.sortId) + ).then(sortId -> { + final sortId = FractionalIndexing.between(sortId, null, FractionalIndexing.BASE_95_DIGITS); + final toStore = ChatMessage.fromStanza( + stanza, + JID.parse(stanza.attr.get("to")).asBare(), + (builder, stanza) -> { + builder.sortId = sortId; + return builder; + } + ); + persistence.storeMessages(message.account(), [toStore]); + }); + return Notification.fromChatMessage(message); + case ReactionUpdateStanza(update): + return Notification.fromReactionUpdate(update, stanza); + default: + return Notification.fromThinStanza(stanza); } } }