push notificaitons
This commit is contained in:
@@ -2,7 +2,6 @@ import express from "express";
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Request,
|
||||
Route,
|
||||
Security,
|
||||
@@ -17,13 +16,6 @@ import { KC_SECURITY_NAME } from "../services/keycloak/user/keycloak-user.js";
|
||||
export class FoundEventsController extends Controller {
|
||||
private readonly foundEventsService = inject(FoundEventsService);
|
||||
|
||||
@Post("crawl")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async crawl(): Promise<void> {
|
||||
await this.foundEventsService.crawl();
|
||||
}
|
||||
|
||||
@Get("future")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
|
||||
@@ -32,39 +32,13 @@ export class PushContoller extends Controller {
|
||||
);
|
||||
}
|
||||
|
||||
@Post("reset")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async resetSubscriptions(
|
||||
@Request() request: express.Request,
|
||||
): Promise<void> {
|
||||
return await this.pushService.reset(request);
|
||||
}
|
||||
|
||||
@Post("clearSingle")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async clearSubscription(
|
||||
@Request() request: express.Request,
|
||||
@Query() clientId: string,
|
||||
@Query() clientId?: string,
|
||||
): Promise<void> {
|
||||
await this.pushService.clearSubscription(clientId, request);
|
||||
}
|
||||
|
||||
//TODO remove
|
||||
@Post("test-publish")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async publishTestMessage(
|
||||
@Request() request: express.Request,
|
||||
): Promise<void> {
|
||||
this.pushService.sendtestNotification(request);
|
||||
}
|
||||
|
||||
//TODO remove
|
||||
@Post("notify")
|
||||
@SuccessResponse("200", "OK")
|
||||
public async notifyEvents(): Promise<void> {
|
||||
await this.pushService.sendEventNotifications();
|
||||
await this.pushService.clearSubscription(clientId ?? null, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Controller, Post, Route, Security, SuccessResponse } from "tsoa";
|
||||
import { Claim } from "../dtos/claim.js";
|
||||
import { inject } from "../infrastructure/di/index.js";
|
||||
import { FoundEventsService } from "../services/foundEvents/foundEventsService.js";
|
||||
import { KC_SECURITY_NAME } from "../services/keycloak/user/keycloak-user.js";
|
||||
import { PushService } from "../services/push/pushService.js";
|
||||
|
||||
@Route("test")
|
||||
export class TestContoller extends Controller {
|
||||
private readonly pushService = inject(PushService);
|
||||
private readonly foundEventsService = inject(FoundEventsService);
|
||||
|
||||
@Post("notify")
|
||||
@Security(KC_SECURITY_NAME, [Claim.UserAdmin])
|
||||
@SuccessResponse("200", "OK")
|
||||
public async notifyEvents(): Promise<void> {
|
||||
await this.pushService.sendEventNotifications();
|
||||
}
|
||||
|
||||
@Post("crawl")
|
||||
@Security(KC_SECURITY_NAME)
|
||||
@SuccessResponse("200", "OK")
|
||||
public async crawl(): Promise<void> {
|
||||
await this.foundEventsService.crawl();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user