Mercurial > prosody-hg
comparison plugins/mod_pubsub/pubsub.lib.lua @ 8308:ab189d3f55d1
mod_pubsub: Remove use of non-existent fields
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 09 Oct 2017 00:58:45 +0200 |
| parents | 4852def7dc49 |
| children | ff57b3cc5a8e |
comparison
equal
deleted
inserted
replaced
| 8307:94860b5733d3 | 8308:ab189d3f55d1 |
|---|---|
| 327 end | 327 end |
| 328 | 328 |
| 329 local function simple_itemstore(archive, config, user, node, expose_publisher) | 329 local function simple_itemstore(archive, config, user, node, expose_publisher) |
| 330 module:log("debug", "Creation of itemstore for node %s with config %s", node, config); | 330 module:log("debug", "Creation of itemstore for node %s with config %s", node, config); |
| 331 local get_set = {}; | 331 local get_set = {}; |
| 332 function get_set:items() | 332 function get_set:items() -- luacheck: ignore 212/self |
| 333 local store = self.store; | |
| 334 local data, err = archive:find(user); | 333 local data, err = archive:find(user); |
| 335 if not data then | 334 if not data then |
| 336 module:log("error", "Unable to get items: %s", err); | 335 module:log("error", "Unable to get items: %s", err); |
| 337 return true; | 336 return true; |
| 338 end | 337 end |
| 339 module:log("debug", "Listed items %s from store %s", data, store); | 338 module:log("debug", "Listed items %s", data); |
| 340 return function() | 339 return function() |
| 341 local id, payload, when, publisher = data(); | 340 local id, payload, when, publisher = data(); |
| 342 if id == nil then | 341 if id == nil then |
| 343 return; | 342 return; |
| 344 end | 343 end |
| 345 local item = create_encapsulating_item(id, payload, publisher, expose_publisher); | 344 local item = create_encapsulating_item(id, payload, publisher, expose_publisher); |
| 346 return id, item; | 345 return id, item; |
| 347 end; | 346 end; |
| 348 end | 347 end |
| 349 function get_set:get(key) | 348 function get_set:get(key) -- luacheck: ignore 212/self |
| 350 local store = self.store; | |
| 351 local data, err = archive:find(user, { | 349 local data, err = archive:find(user, { |
| 352 key = key; | 350 key = key; |
| 353 -- Get the last item with that key, if the archive doesn't deduplicate | 351 -- Get the last item with that key, if the archive doesn't deduplicate |
| 354 reverse = true, | 352 reverse = true, |
| 355 limit = 1; | 353 limit = 1; |
| 357 if not data then | 355 if not data then |
| 358 module:log("error", "Unable to get item: %s", err); | 356 module:log("error", "Unable to get item: %s", err); |
| 359 return nil, err; | 357 return nil, err; |
| 360 end | 358 end |
| 361 local id, payload, when, publisher = data(); | 359 local id, payload, when, publisher = data(); |
| 362 module:log("debug", "Get item %s (published at %s by %s) from store %s", id, when, publisher, store); | 360 module:log("debug", "Get item %s (published at %s by %s)", id, when, publisher); |
| 363 if id == nil then | 361 if id == nil then |
| 364 return nil; | 362 return nil; |
| 365 end | 363 end |
| 366 return create_encapsulating_item(id, payload, publisher, expose_publisher); | 364 return create_encapsulating_item(id, payload, publisher, expose_publisher); |
| 367 end | 365 end |
| 368 function get_set:set(key, value) | 366 function get_set:set(key, value) -- luacheck: ignore 212/self |
| 369 local store = self.store; | 367 module:log("debug", "Set item %s to %s for %s", key, value, node); |
| 370 module:log("debug", "Set item %s to %s for %s in store %s", key, value, node, store); | |
| 371 local data, err; | 368 local data, err; |
| 372 if value ~= nil then | 369 if value ~= nil then |
| 373 local publisher = value.attr.publisher; | 370 local publisher = value.attr.publisher; |
| 374 local payload = value.tags[1]; | 371 local payload = value.tags[1]; |
| 375 data, err = archive:append(user, key, payload, time_now(), publisher); | 372 data, err = archive:append(user, key, payload, time_now(), publisher); |
