mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-18 10:33:11 +02:00
Refactor the db; move to *Manager classes
This commit is contained in:
parent
f9219d2d96
commit
08846e4cc2
12 changed files with 162 additions and 64 deletions
web/src/app
|
@ -1,17 +1,17 @@
|
|||
import {
|
||||
topicUrlJsonPoll,
|
||||
fetchLinesIterator,
|
||||
topicUrl,
|
||||
topicUrlAuth,
|
||||
maybeWithBasicAuth,
|
||||
topicShortUrl,
|
||||
topicUrl,
|
||||
topicUrlAuth,
|
||||
topicUrlJsonPoll,
|
||||
topicUrlJsonPollWithSince
|
||||
} from "./utils";
|
||||
import db from "./db";
|
||||
import userManager from "./UserManager";
|
||||
|
||||
class Api {
|
||||
async poll(baseUrl, topic, since) {
|
||||
const user = await db.users.get(baseUrl);
|
||||
const user = await userManager.get(baseUrl);
|
||||
const shortUrl = topicShortUrl(baseUrl, topic);
|
||||
const url = (since)
|
||||
? topicUrlJsonPollWithSince(baseUrl, topic, since)
|
||||
|
@ -27,7 +27,7 @@ class Api {
|
|||
}
|
||||
|
||||
async publish(baseUrl, topic, message) {
|
||||
const user = await db.users.get(baseUrl);
|
||||
const user = await userManager.get(baseUrl);
|
||||
const url = topicUrl(baseUrl, topic);
|
||||
console.log(`[Api] Publishing message to ${url}`);
|
||||
await fetch(url, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue