1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-05 12:34:34 +02:00

Start work on ephemeral topics

This commit is contained in:
Philipp Heckel 2022-03-08 15:19:15 -05:00
parent 0aefcf29ef
commit d3462d2905
4 changed files with 31 additions and 14 deletions

View file

@ -1,8 +1,9 @@
import db from "./db";
import {topicUrl} from "./utils";
class SubscriptionManager {
/** All subscriptions, including "new count"; this is a JOIN, see https://dexie.org/docs/API-Reference#joining */
async all() {
// All subscriptions, including "new count"; this is a JOIN, see https://dexie.org/docs/API-Reference#joining
const subscriptions = await db.subscriptions.toArray();
await Promise.all(subscriptions.map(async s => {
s.new = await db.notifications
@ -16,8 +17,16 @@ class SubscriptionManager {
return await db.subscriptions.get(subscriptionId)
}
async save(subscription) {
async add(baseUrl, topic, ephemeral) {
const subscription = {
id: topicUrl(baseUrl, topic),
baseUrl: baseUrl,
topic: topic,
ephemeral: ephemeral,
last: null
};
await db.subscriptions.put(subscription);
return subscription;
}
async updateState(subscriptionId, state) {