Change stats NOT IMPLEMENTED for unfinished methods #2
@@ -14,4 +14,7 @@ export class Subscription {
|
|||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
keys_auth: string;
|
keys_auth: string;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
muted: boolean = false;
|
||||||
}
|
}
|
||||||
|
|||||||
28
src/db.ts
28
src/db.ts
@@ -58,12 +58,40 @@ class DBService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async removeSubscription(endpoint: string): Promise<Boolean> {
|
||||||
|
let result = true;
|
||||||
|
if (this.isReady) {
|
||||||
|
await this.dataSource.manager.delete(Subscription, { endpoint: endpoint });
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async toggleMuteSubscription(endpoint: string): Promise<Boolean> {
|
||||||
|
let result = true;
|
||||||
|
if (this.isReady) {
|
||||||
|
const subscription = await this.dataSource.manager.findOne(Subscription, { where : {endpoint: endpoint} });
|
||||||
|
subscription.muted = !subscription.muted;
|
||||||
|
await this.dataSource.manager.save(subscription)
|
||||||
|
} else {
|
||||||
|
result = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
async getVapidKeys(): Promise<VapidKeys[]> {
|
async getVapidKeys(): Promise<VapidKeys[]> {
|
||||||
console.log(__filename, "getVapidKeys", this.isReady);
|
console.log(__filename, "getVapidKeys", this.isReady);
|
||||||
let result = [ new VapidKeys() ];
|
let result = [ new VapidKeys() ];
|
||||||
if ( this.isReady ) {
|
if ( this.isReady ) {
|
||||||
result = await this.dataSource.manager.find(VapidKeys);
|
result = await this.dataSource.manager.find(VapidKeys);
|
||||||
console.log(__filename, "results of find: ", result);
|
console.log(__filename, "results of find: ", result);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log(__filename, "Database is not ready");
|
console.log(__filename, "Database is not ready");
|
||||||
|
|
||||||
|
|||||||
@@ -54,14 +54,14 @@ class Server {
|
|||||||
const subscription = req.body as Subscription;
|
const subscription = req.body as Subscription;
|
||||||
console.log(subscription);
|
console.log(subscription);
|
||||||
|
|
||||||
res.status(201).send();
|
res.status(501).send();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.app.post('/mute', async (req: Request, res: Response) => {
|
this.app.post('/mute', async (req: Request, res: Response) => {
|
||||||
const subscription = req.body as Subscription;
|
const subscription = req.body as Subscription;
|
||||||
console.log(subscription);
|
console.log(subscription);
|
||||||
|
|
||||||
res.status(201).send();
|
res.status(501).send();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.app.get('/vapid', async (_: Request, res: Response) => {
|
this.app.get('/vapid', async (_: Request, res: Response) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user