aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-12 01:37:35 +0200
committerKim Alvefur <zash@zash.se>2017-10-12 01:37:35 +0200
commit08d26443e55ea9eb6b22d6fbba46973dc71b8822 (patch)
tree2d165ff8fab8a0bc6bfc9be07e48eb457653ac9b
parentee39ade3051eadc332effc211ba56277acab2b66 (diff)
downloadprosody-08d26443e55ea9eb6b22d6fbba46973dc71b8822.tar.gz
prosody-08d26443e55ea9eb6b22d6fbba46973dc71b8822.zip
mod_pep_plus: Make node persistence configurable via pubsub#persist_items
-rw-r--r--plugins/mod_pep_plus.lua16
-rw-r--r--plugins/mod_pubsub/pubsub.lib.lua5
2 files changed, 17 insertions, 4 deletions
diff --git a/plugins/mod_pep_plus.lua b/plugins/mod_pep_plus.lua
index ce5fa231..db42fbc9 100644
--- a/plugins/mod_pep_plus.lua
+++ b/plugins/mod_pep_plus.lua
@@ -6,6 +6,7 @@ local set_new = require "util.set".new;
local st = require "util.stanza";
local calculate_hash = require "util.caps".calculate_hash;
local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
+local cache = require "util.cache";
local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event";
@@ -42,10 +43,16 @@ end
local function simple_itemstore(username)
return function (config, node)
- module:log("debug", "new simple_itemstore(%q, %q)", username, node);
- known_nodes_map:set(username, node, true);
- local archive = module:open_store("pep_"..node, "archive");
- return lib_pubsub.archive_itemstore(archive, config, username, node, false);
+ if config["pubsub#persist_items"] then
+ module:log("debug", "Creating new persistent item store for user %s, node %q", username, node);
+ known_nodes_map:set(username, node, true);
+ local archive = module:open_store("pep_"..node, "archive");
+ return lib_pubsub.archive_itemstore(archive, config, username, node, false);
+ else
+ module:log("debug", "Creating new ephemeral item store for user %s, node %q", username, node);
+ known_nodes_map:set(username, node, nil);
+ return cache.new(tonumber(config["pubsub#max_items"]));
+ end
end
end
@@ -173,6 +180,7 @@ function get_pep_service(username)
node_defaults = {
["pubsub#max_items"] = "1";
+ ["pubsub#persist_items"] = true;
};
autocreate_on_publish = true;
diff --git a/plugins/mod_pubsub/pubsub.lib.lua b/plugins/mod_pubsub/pubsub.lib.lua
index 56b0cb42..77bc958e 100644
--- a/plugins/mod_pubsub/pubsub.lib.lua
+++ b/plugins/mod_pubsub/pubsub.lib.lua
@@ -45,6 +45,11 @@ local node_config_form = dataform {
name = "pubsub#max_items";
label = "Max # of items to persist";
};
+ {
+ type = "boolean";
+ name = "pubsub#persist_items";
+ label = "Persist items to storage";
+ };
};
function handlers.get_items(origin, stanza, items, service)