Mercurial > prosody-modules
comparison mod_cloud_notify/mod_cloud_notify.lua @ 3010:7ee59f417c16
mod_cloud_notify: remove useless counter (hardcode it to 1)
author | tmolitor <thilo@eightysoft.de> |
---|---|
date | Mon, 14 May 2018 20:17:49 +0200 |
parents | df86ce6bb0b4 |
children | 6abee021d9db |
comparison
equal
deleted
inserted
replaced
3009:a6fa44eeb818 | 3010:7ee59f417c16 |
---|---|
157 local push_identifier = push_jid .. "<" .. (push_node or ""); | 157 local push_identifier = push_jid .. "<" .. (push_node or ""); |
158 local push_service = { | 158 local push_service = { |
159 jid = push_jid; | 159 jid = push_jid; |
160 node = push_node; | 160 node = push_node; |
161 include_payload = include_payload; | 161 include_payload = include_payload; |
162 count = 0; | |
163 options = publish_options and st.preserialize(publish_options); | 162 options = publish_options and st.preserialize(publish_options); |
164 }; | 163 }; |
165 local ok = push_store:set_identifier(origin.username, push_identifier, push_service); | 164 local ok = push_store:set_identifier(origin.username, push_identifier, push_service); |
166 if not ok then | 165 if not ok then |
167 origin.send(st.error_reply(stanza, "wait", "internal-server-error")); | 166 origin.send(st.error_reply(stanza, "wait", "internal-server-error")); |
305 end | 304 end |
306 stanza._push_notify[push_identifier] = true; | 305 stanza._push_notify[push_identifier] = true; |
307 end | 306 end |
308 | 307 |
309 if send_push then | 308 if send_push then |
310 -- increment count and save it | |
311 push_info.count = push_info.count + 1; | |
312 push_store:set_identifier(node, push_identifier, push_info); | |
313 -- construct push stanza | 309 -- construct push stanza |
314 local stanza_id = hashes.sha256(push_identifier, true); | 310 local stanza_id = hashes.sha256(push_identifier, true); |
315 local push_publish = st.iq({ to = push_info.jid, from = module.host, type = "set", id = stanza_id }) | 311 local push_publish = st.iq({ to = push_info.jid, from = module.host, type = "set", id = stanza_id }) |
316 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) | 312 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) |
317 :tag("publish", { node = push_info.node }) | 313 :tag("publish", { node = push_info.node }) |
318 :tag("item") | 314 :tag("item") |
319 :tag("notification", { xmlns = xmlns_push }); | 315 :tag("notification", { xmlns = xmlns_push }); |
320 local form_data = { | 316 local form_data = { |
321 ["message-count"] = tostring(push_info.count); | 317 -- hardcode to 1 because other numbers are just meaningless (the XEP does not specify *what exactly* to count) |
318 ["message-count"] = "1"; | |
322 }; | 319 }; |
323 if stanza and include_sender then | 320 if stanza and include_sender then |
324 form_data["last-message-sender"] = stanza.attr.from; | 321 form_data["last-message-sender"] = stanza.attr.from; |
325 end | 322 end |
326 if stanza and include_body then | 323 if stanza and include_body then |
405 -- smacks hibernation is ended | 402 -- smacks hibernation is ended |
406 local function restore_session(event) | 403 local function restore_session(event) |
407 local session = event.resumed; | 404 local session = event.resumed; |
408 if session then -- older smacks module versions send only the "intermediate" session in event.session and no session.resumed one | 405 if session then -- older smacks module versions send only the "intermediate" session in event.session and no session.resumed one |
409 filters.remove_filter(session, "stanzas/out", process_smacks_stanza); | 406 filters.remove_filter(session, "stanzas/out", process_smacks_stanza); |
410 -- this means the counter of outstanding push messages can be reset as well | |
411 if session.push_settings then | |
412 session.push_settings.count = 0; | |
413 push_store:set_identifier(session.username, session.push_identifier, session.push_settings); | |
414 end | |
415 end | 407 end |
416 end | 408 end |
417 | 409 |
418 -- smacks ack is delayed | 410 -- smacks ack is delayed |
419 local function ack_delayed(event) | 411 local function ack_delayed(event) |