Changeset

5152:342baedbd1c8

mod_unified_push: Fix storage backend error behaviours and return values
author Matthew Wild <mwild1@gmail.com>
date Sat, 14 Jan 2023 16:15:35 +0000
parents 5151:514c8a0e9aa1
children 5153:d69cc9a23fad
files mod_unified_push/mod_unified_push.lua
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mod_unified_push/mod_unified_push.lua	Sat Jan 14 16:14:50 2023 +0000
+++ b/mod_unified_push/mod_unified_push.lua	Sat Jan 14 16:15:35 2023 +0000
@@ -61,11 +61,10 @@
 	storage = {
 		sign = function (data)
 			local reg_id = id.long();
-			local user, host = jid.split(data.sub);
-			if host ~= module.host or not user then
-				return;
+			local ok, err = push_store:set(reg_id, data);
+			if not ok then
+				return nil, err;
 			end
-			push_store:set(reg_id, data);
 			return reg_id;
 		end;
 		verify = function (token)
@@ -77,7 +76,7 @@
 				push_store:set(token, nil);
 				return nil, "token-expired";
 			end
-			return data;
+			return true, data;
 		end;
 	};
 };