mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-07-20 10:04:08 +00:00
Desktop notifications
This commit is contained in:
parent
530f55c234
commit
aa79fe2861
5 changed files with 101 additions and 42 deletions
|
@ -32,13 +32,16 @@ class Connection {
|
|||
console.log(`[Connection, ${this.shortUrl}] Message received from server: ${event.data}`);
|
||||
try {
|
||||
const data = JSON.parse(event.data);
|
||||
if (data.event === 'open') {
|
||||
return;
|
||||
}
|
||||
const relevantAndValid =
|
||||
data.event === 'message' &&
|
||||
'id' in data &&
|
||||
'time' in data &&
|
||||
'message' in data;
|
||||
if (!relevantAndValid) {
|
||||
console.log(`[Connection, ${this.shortUrl}] Message irrelevant or invalid. Ignoring.`);
|
||||
console.log(`[Connection, ${this.shortUrl}] Unexpected message. Ignoring.`);
|
||||
return;
|
||||
}
|
||||
this.since = data.time + 1; // Sigh. This works because on reconnect, we wait 5+ seconds anyway.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue