diff util/pubsub.lua @ 13535:88cab98aa28c

mod_pubsub: Move precondition error wrangling out of util.pubsub Removes dependency on util.error from util.pubsub which was only used for this one special case. Line count reduction! Would be even nicer if templating could be done by util.error itself.
author Kim Alvefur <zash@zash.se>
date Tue, 29 Oct 2024 14:56:02 +0100
parents fdd1438d9ef7
children 3b357ab6b6eb
line wrap: on
line diff
--- a/util/pubsub.lua	Tue Oct 29 14:10:02 2024 +0100
+++ b/util/pubsub.lua	Tue Oct 29 14:56:02 2024 +0100
@@ -1,6 +1,5 @@
 local events = require "prosody.util.events";
 local cache = require "prosody.util.cache";
-local errors = require "prosody.util.error";
 
 local service_mt = {};
 
@@ -562,11 +561,7 @@
 		-- Check that node has the requested config before we publish
 		local ok, field = check_preconditions(node_obj.config, requested_config);
 		if not ok then
-			local err = errors.new({
-				type = "cancel", condition = "conflict", text = "Field does not match: "..field;
-			});
-			err.pubsub_condition = "precondition-not-met";
-			return false, err;
+			return false, "precondition-not-met", { field = field };
 		end
 	end
 	if not self.config.itemcheck(item) then