diff options
-rw-r--r-- | plugins/mod_pubsub/pubsub.lib.lua | 1 | ||||
-rw-r--r-- | spec/util_pubsub_spec.lua | 4 | ||||
-rw-r--r-- | util/pubsub.lua | 7 |
3 files changed, 7 insertions, 5 deletions
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua index c750ecb8..3c38218a 100644 --- a/plugins/mod_pubsub/pubsub.lib.lua +++ b/plugins/mod_pubsub/pubsub.lib.lua @@ -32,6 +32,7 @@ local pubsub_errors = { ["internal-server-error"] = { "wait", "internal-server-error" }; ["precondition-not-met"] = { "cancel", "conflict", nil, "precondition-not-met" }; ["invalid-item"] = { "modify", "bad-request", "invalid item" }; + ["persistent-items-unsupported"] = { "cancel", "feature-not-implemented", nil, "persistent-items" }; }; local function pubsub_error_reply(stanza, error) local e = pubsub_errors[error]; diff --git a/spec/util_pubsub_spec.lua b/spec/util_pubsub_spec.lua index 5140a411..8476cb50 100644 --- a/spec/util_pubsub_spec.lua +++ b/spec/util_pubsub_spec.lua @@ -523,8 +523,8 @@ describe("util.pubsub", function () assert.spy(broadcaster).was_called(); local ok, items = service:get_items("node", true); - assert.truthy(ok); - assert.same(items, {}); + assert.not_truthy(ok); + assert.equal(items, "persistent-items-unsupported"); end); end) diff --git a/util/pubsub.lua b/util/pubsub.lua index 4b16dcfc..ae1d6353 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -652,13 +652,14 @@ function service:get_items(node, actor, ids) --> (true, { id, [id] = node }) or if not node_obj then return false, "item-not-found"; end + if not self.data[node] then + -- Disabled rather than unsupported, but close enough. + return false, "persistent-items-unsupported"; + end if type(ids) == "string" then -- COMPAT see #1305 ids = { ids }; end local data = {}; - if not self.data[node] then - return true, data; - end if ids then for _, key in ipairs(ids) do local value = self.data[node]:get(key); |