Software / code / prosody-modules
Comparison
mod_push2/mod_push2.lua @ 6273:8ceedc336d0d
Merge update
| author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
|---|---|
| date | Sun, 01 Jun 2025 13:51:38 +0700 |
| parent | 6267:ff7d6ee9db20 |
| child | 6311:27bb0bc3f4b5 |
comparison
equal
deleted
inserted
replaced
| 6263:10a1016d1c3a | 6273:8ceedc336d0d |
|---|---|
| 353 end | 353 end |
| 354 stanza._push_notify2[push_registration_id] = true; | 354 stanza._push_notify2[push_registration_id] = true; |
| 355 end | 355 end |
| 356 | 356 |
| 357 if send_push then | 357 if send_push then |
| 358 local any_match = false; | |
| 358 local push_notification_payload = st.stanza("notification", { xmlns = xmlns_push }) | 359 local push_notification_payload = st.stanza("notification", { xmlns = xmlns_push }) |
| 359 push_notification_payload:text_tag("client", push_info.client) | 360 push_notification_payload:text_tag("client", push_info.client) |
| 360 push_notification_payload:text_tag("priority", is_voip(stanza) and "high" or (is_important(stanza, session) and "normal" or "low")) | 361 push_notification_payload:text_tag("priority", is_voip(stanza) and "high" or (is_important(stanza, session) and "normal" or "low")) |
| 361 if is_voip(stanza) then | 362 if is_voip(stanza) then |
| 362 push_notification_payload:tag("voip"):up() | 363 push_notification_payload:tag("voip"):up() |
| 409 end | 410 end |
| 410 end | 411 end |
| 411 | 412 |
| 412 if does_match and not sends_added[match.send] then | 413 if does_match and not sends_added[match.send] then |
| 413 sends_added[match.send] = true | 414 sends_added[match.send] = true |
| 415 any_match = true | |
| 414 if match.send == "urn:xmpp:push2:send:notify-only" then | 416 if match.send == "urn:xmpp:push2:send:notify-only" then |
| 415 -- Nothing more to add | 417 -- Nothing more to add |
| 416 elseif match.send == "urn:xmpp:push2:send:sce+rfc8291+rfc8292:0" then | 418 elseif match.send == "urn:xmpp:push2:send:sce+rfc8291+rfc8292:0" then |
| 417 add_sce_rfc8291(match, stanza, push_notification_payload) | 419 add_sce_rfc8291(match, stanza, push_notification_payload) |
| 418 add_rfc8292(match, stanza, push_notification_payload) | 420 add_rfc8292(match, stanza, push_notification_payload) |
| 420 module:log("debug", "Unkonwn send profile: " .. push_info.send) | 422 module:log("debug", "Unkonwn send profile: " .. push_info.send) |
| 421 end | 423 end |
| 422 end | 424 end |
| 423 end | 425 end |
| 424 | 426 |
| 425 local push_publish = st.message({ to = push_info.service, from = module.host, id = uuid.generate() }) | 427 if any_match then |
| 426 :add_child(push_notification_payload):up() | 428 local push_publish = st.message({ to = push_info.service, from = module.host, id = uuid.generate() }) |
| 427 | 429 :add_child(push_notification_payload):up() |
| 428 -- TODO: watch for message error replies and count or something | 430 |
| 429 module:send(push_publish) | 431 -- TODO: watch for message error replies and count or something |
| 430 pushes = pushes + 1 | 432 module:send(push_publish) |
| 433 pushes = pushes + 1 | |
| 434 end | |
| 431 end | 435 end |
| 432 end | 436 end |
| 433 | 437 |
| 434 return pushes | 438 return pushes |
| 435 end | 439 end |