Introduce isMessageBeforeReceipt

This commit is contained in:
Simon Ser 2022-02-11 16:37:58 +01:00
parent 3d81466788
commit d2bcea8c86
3 changed files with 18 additions and 5 deletions

View file

@ -85,6 +85,19 @@ export function getServerName(server, bouncerNetwork) {
}
}
export function isMessageBeforeReceipt(msg, receipt) {
if (!receipt) {
return false;
}
if (!msg.tags.time) {
throw new Error("Missing time message tag");
}
if (!receipt.time) {
throw new Error("Missing receipt time");
}
return msg.tags.time <= receipt.time;
}
function updateState(state, updater) {
let updated;
if (typeof updater === "function") {