Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2021-08-22 13:44:50 +0300
committerHolger Weiss <holger@zedat.fu-berlin.de>2021-08-22 13:44:50 +0300
commit8d5025076f53abc0474c86a0f879ff1736714844 (patch)
tree06b8c8d9c4c4275d42e208628ad47aafdaf5e468 /src/nodetree_tree.erl
parent29751a6174d181f80bbcde7c92f8cc958eee85a1 (diff)
PubSub: Add delete_old_pubsub_items command
Add a command for keeping only the specified number of items on each node and removing all older items. This might be especially useful if nodes may be configured to have no 'max_items' limit. Thanks to Ammonit Measurement GmbH for sponsoring this work.
Diffstat (limited to 'src/nodetree_tree.erl')
-rw-r--r--src/nodetree_tree.erl11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nodetree_tree.erl b/src/nodetree_tree.erl
index fe15f3323..853c1fb93 100644
--- a/src/nodetree_tree.erl
+++ b/src/nodetree_tree.erl
@@ -46,7 +46,8 @@
-export([init/3, terminate/2, options/0, set_node/1,
get_node/3, get_node/2, get_node/1, get_nodes/2,
- get_nodes/1, get_parentnodes/3, get_parentnodes_tree/3,
+ get_nodes/1, get_all_nodes/1,
+ get_parentnodes/3, get_parentnodes_tree/3,
get_subnodes/3, get_subnodes_tree/3, create_node/6,
delete_node/2]).
@@ -98,6 +99,14 @@ get_nodes(Host, Limit) ->
{Nodes, _} -> Nodes
end.
+get_all_nodes({_U, _S, _R} = Owner) ->
+ Host = jid:tolower(jid:remove_resource(Owner)),
+ mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, _ = '_'});
+get_all_nodes(Host) ->
+ mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, _ = '_'})
+ ++ mnesia:match_object(#pubsub_node{nodeid = {{'_', Host, '_'}, '_'},
+ _ = '_'}).
+
get_parentnodes(Host, Node, _From) ->
case catch mnesia:read({pubsub_node, {Host, Node}}) of
[Record] when is_record(Record, pubsub_node) ->