Software / code / prosody
Comparison
plugins/mod_pep_simple.lua @ 11120:b2331f3dfeea
Merge 0.11->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 30 Sep 2020 09:50:33 +0100 |
| parent | 10555:f73947a9bd8c |
| child | 12589:39ae08180c81 |
comparison
equal
deleted
inserted
replaced
| 11119:68df52bf08d5 | 11120:b2331f3dfeea |
|---|---|
| 12 local st = require "util.stanza"; | 12 local st = require "util.stanza"; |
| 13 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; | 13 local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed; |
| 14 local pairs = pairs; | 14 local pairs = pairs; |
| 15 local next = next; | 15 local next = next; |
| 16 local type = type; | 16 local type = type; |
| 17 local unpack = table.unpack or unpack; -- luacheck: ignore 113 | |
| 17 local calculate_hash = require "util.caps".calculate_hash; | 18 local calculate_hash = require "util.caps".calculate_hash; |
| 18 local core_post_stanza = prosody.core_post_stanza; | 19 local core_post_stanza = prosody.core_post_stanza; |
| 19 local bare_sessions = prosody.bare_sessions; | 20 local bare_sessions = prosody.bare_sessions; |
| 20 | 21 |
| 21 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | 22 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; |
| 82 local d = data[user]; | 83 local d = data[user]; |
| 83 local notify = recipients[user] and recipients[user][recipient]; | 84 local notify = recipients[user] and recipients[user][recipient]; |
| 84 if d and notify then | 85 if d and notify then |
| 85 for node in pairs(notify) do | 86 for node in pairs(notify) do |
| 86 if d[node] then | 87 if d[node] then |
| 88 -- luacheck: ignore id | |
| 87 local id, item = unpack(d[node]); | 89 local id, item = unpack(d[node]); |
| 88 session.send(st.message({from=user, to=recipient, type='headline'}) | 90 session.send(st.message({from=user, to=recipient, type='headline'}) |
| 89 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) | 91 :tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'}) |
| 90 :tag('items', {node=node}) | 92 :tag('items', {node=node}) |
| 91 :add_child(item) | 93 :add_child(item) |
| 227 session.send(st.error_reply(stanza, 'cancel', 'item-not-found')); | 229 session.send(st.error_reply(stanza, 'cancel', 'item-not-found')); |
| 228 module:log("debug", "Item '%s' not found", node) | 230 module:log("debug", "Item '%s' not found", node) |
| 229 return true; | 231 return true; |
| 230 else --invalid request | 232 else --invalid request |
| 231 session.send(st.error_reply(stanza, 'modify', 'bad-request')); | 233 session.send(st.error_reply(stanza, 'modify', 'bad-request')); |
| 232 module:log("debug", "Invalid request: %s", tostring(payload)); | 234 module:log("debug", "Invalid request: %s", payload); |
| 233 return true; | 235 return true; |
| 234 end | 236 end |
| 235 else --no presence subscription | 237 else --no presence subscription |
| 236 session.send(st.error_reply(stanza, 'auth', 'not-authorized') | 238 session.send(st.error_reply(stanza, 'auth', 'not-authorized') |
| 237 :tag('presence-subscription-required', {xmlns='http://jabber.org/protocol/pubsub#errors'})); | 239 :tag('presence-subscription-required', {xmlns='http://jabber.org/protocol/pubsub#errors'})); |
| 238 module:log("debug", "Unauthorized request: %s", tostring(payload)); | 240 module:log("debug", "Unauthorized request: %s", payload); |
| 239 return true; | 241 return true; |
| 240 end | 242 end |
| 241 end | 243 end |
| 242 end); | 244 end); |
| 243 | 245 |