Introduce isMessageBeforeReceipt
This commit is contained in:
parent
3d81466788
commit
d2bcea8c86
3 changed files with 18 additions and 5 deletions
13
state.js
13
state.js
|
@ -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") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue