mod_unified_push: Fix storage backend error behaviours and return values
authorMatthew Wild <mwild1@gmail.com>
Sat, 14 Jan 2023 16:15:35 +0000
changeset 5156 342baedbd1c8
parent 5155 514c8a0e9aa1
child 5157 d69cc9a23fad
mod_unified_push: Fix storage backend error behaviours and return values
mod_unified_push/mod_unified_push.lua
--- 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;
 	};
 };