# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1610471215 -3600
# Node ID c3907f05bed4b93b0be1a1db25bf841e7e78f843
# Parent  1256f32f21b68bd7cc746b4877cab91c7eee8029
mod_storage_internal: Support query for set of IDs

Based on implementation in mod_storage_memory

diff -r 1256f32f21b6 -r c3907f05bed4 plugins/mod_storage_internal.lua
--- a/plugins/mod_storage_internal.lua	Tue Jan 12 18:06:33 2021 +0100
+++ b/plugins/mod_storage_internal.lua	Tue Jan 12 18:06:55 2021 +0100
@@ -6,6 +6,7 @@
 local now = require "util.time".now;
 local id = require "util.id".medium;
 local jid_join = require "util.jid".join;
+local set = require "util.set";
 
 local host = module.host;
 
@@ -53,6 +54,7 @@
 	quota = archive_item_limit;
 	truncate = true;
 	full_id_range = true;
+	ids = true;
 };
 
 function archive:append(username, key, value, when, with)
@@ -144,6 +146,12 @@
 				return item.key == query.key;
 			end);
 		end
+		if query.ids then
+			local ids = set.new(query.ids);
+			items:filter(function (item)
+				return ids:contains(item.key);
+			end);
+		end
 		if query.with then
 			items:filter(function (item)
 				return item.with == query.with;