Mercurial > prosody-hg
comparison plugins/mod_pubsub/pubsub.lib.lua @ 8327:0b561f8bc790
mod_pubsub: Remove expose_publisher argument since it is handled in broadcaster
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 17 Oct 2017 00:07:34 +0200 |
| parents | 9a845e9e9cbf |
| children | 2abbb01cd756 |
comparison
equal
deleted
inserted
replaced
| 8326:12408867bc86 | 8327:0b561f8bc790 |
|---|---|
| 326 :add_child(node_config_form:form(service.node_defaults)); | 326 :add_child(node_config_form:form(service.node_defaults)); |
| 327 origin.send(reply); | 327 origin.send(reply); |
| 328 return true; | 328 return true; |
| 329 end | 329 end |
| 330 | 330 |
| 331 local function create_encapsulating_item(id, payload, publisher, expose_publisher) | 331 local function create_encapsulating_item(id, payload) |
| 332 local item = st.stanza("item", { id = id, xmlns = xmlns_pubsub }); | 332 local item = st.stanza("item", { id = id, xmlns = xmlns_pubsub }); |
| 333 item:add_child(payload); | 333 item:add_child(payload); |
| 334 if expose_publisher then | |
| 335 item.attr.publisher = publisher; | |
| 336 end | |
| 337 return item; | 334 return item; |
| 338 end | 335 end |
| 339 | 336 |
| 340 local function archive_itemstore(archive, config, user, node, expose_publisher) | 337 local function archive_itemstore(archive, config, user, node) |
| 341 module:log("debug", "Creation of itemstore for node %s with config %s", node, config); | 338 module:log("debug", "Creation of itemstore for node %s with config %s", node, config); |
| 342 local get_set = {}; | 339 local get_set = {}; |
| 343 function get_set:items() -- luacheck: ignore 212/self | 340 function get_set:items() -- luacheck: ignore 212/self |
| 344 local data, err = archive:find(user, { | 341 local data, err = archive:find(user, { |
| 345 limit = tonumber(config["pubsub#max_items"]); | 342 limit = tonumber(config["pubsub#max_items"]); |
| 353 return it.reverse(function() | 350 return it.reverse(function() |
| 354 local id, payload, when, publisher = data(); | 351 local id, payload, when, publisher = data(); |
| 355 if id == nil then | 352 if id == nil then |
| 356 return; | 353 return; |
| 357 end | 354 end |
| 358 local item = create_encapsulating_item(id, payload, publisher, expose_publisher); | 355 local item = create_encapsulating_item(id, payload, publisher); |
| 359 return id, item; | 356 return id, item; |
| 360 end); | 357 end); |
| 361 end | 358 end |
| 362 function get_set:get(key) -- luacheck: ignore 212/self | 359 function get_set:get(key) -- luacheck: ignore 212/self |
| 363 local data, err = archive:find(user, { | 360 local data, err = archive:find(user, { |
| 373 local id, payload, when, publisher = data(); | 370 local id, payload, when, publisher = data(); |
| 374 module:log("debug", "Get item %s (published at %s by %s)", id, when, publisher); | 371 module:log("debug", "Get item %s (published at %s by %s)", id, when, publisher); |
| 375 if id == nil then | 372 if id == nil then |
| 376 return nil; | 373 return nil; |
| 377 end | 374 end |
| 378 return create_encapsulating_item(id, payload, publisher, expose_publisher); | 375 return create_encapsulating_item(id, payload, publisher); |
| 379 end | 376 end |
| 380 function get_set:set(key, value) -- luacheck: ignore 212/self | 377 function get_set:set(key, value) -- luacheck: ignore 212/self |
| 381 local data, err; | 378 local data, err; |
| 382 if value ~= nil then | 379 if value ~= nil then |
| 383 local publisher = value.attr.publisher; | 380 local publisher = value.attr.publisher; |
