| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-24 16:21:56 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-03-24 16:21:56 UTC |
| parent | 8c9a2b818063f4a42171d53cb74489b49c922070 |
| snikket/Client.hx | +3 | -1 |
| snikket/queries/Push2Enable.hx | +7 | -1 |
diff --git a/snikket/Client.hx b/snikket/Client.hx index 8152c2e..0a50cd8 100644 --- a/snikket/Client.hx +++ b/snikket/Client.hx @@ -962,6 +962,7 @@ class Client extends EventEmitter { } public function enablePush(push_service: String, vapid_private_key: js.html.CryptoKey, endpoint: String, p256dh: BytesData, auth: BytesData) { + final chatSettings = []; // TODO js.Browser.window.crypto.subtle.exportKey("pkcs8", vapid_private_key).then((vapid_private_pkcs8) -> { sendQuery(new Push2Enable( jid.asBare().asString(), @@ -971,7 +972,8 @@ class Client extends EventEmitter { Bytes.ofData(auth), "ES256", Bytes.ofData(vapid_private_pkcs8), - [ "aud" => new js.html.URL(endpoint).origin ] + [ "aud" => new js.html.URL(endpoint).origin ], + chatSettings )); }); } diff --git a/snikket/queries/Push2Enable.hx b/snikket/queries/Push2Enable.hx index 5b4df2c..cdcd9ae 100644 --- a/snikket/queries/Push2Enable.hx +++ b/snikket/queries/Push2Enable.hx @@ -13,7 +13,7 @@ class Push2Enable extends GenericQuery { public var ver:String = null; private var responseStanza:Stanza; - public function new(to: String, service: String, client: String, ua_public: Bytes, auth_secret: Bytes, jwt_alg: Null<String>, jwt_key: Bytes, jwt_claims: Map<String, String>) { + public function new(to: String, service: String, client: String, ua_public: Bytes, auth_secret: Bytes, jwt_alg: Null<String>, jwt_key: Bytes, jwt_claims: Map<String, String>, chats: Array<{ jid: String, mention: Bool, reply: Bool }>) { queryId = ID.short(); queryStanza = new Stanza( "iq", @@ -23,6 +23,12 @@ class Push2Enable extends GenericQuery { enable.textTag("service", service); enable.textTag("client", client); final match = enable.tag("match", { profile: "urn:xmpp:push2:match:important" }); + for (chat in chats) { + final chatel = match.tag("chat", { jid: chat.jid }); + if (chat.mention) chatel.tag("mention").up(); + if (chat.reply) chatel.tag("reply").up(); + chatel.up(); + } final send = match.tag("send", { xmlns: "urn:xmpp:push2:send:sce+rfc8291+rfc8292:0" }); send.textTag("ua-public", Base64.encode(ua_public)); send.textTag("auth-secret", Base64.encode(auth_secret));