add push settings
This commit is contained in:
@@ -5,7 +5,7 @@ import { firstValueFrom } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { CoreGrpcService } from '../core-grpc.service';
|
||||
import { getAuthorizedUserId } from '../document-access';
|
||||
import { MarkNotificationReadDto } from '../dto/notifications.dto';
|
||||
import { MarkNotificationReadDto, RegisterPushTokenDto, UnregisterPushTokenDto } from '../dto/notifications.dto';
|
||||
|
||||
@ApiTags('Уведомления')
|
||||
@ApiBearerAuth()
|
||||
@@ -83,4 +83,36 @@ export class NotificationsController {
|
||||
const userId = await getAuthorizedUserId(this.jwt, this.core, authorization);
|
||||
return firstValueFrom(this.core.notifications.DeleteAllNotifications({ userId }));
|
||||
}
|
||||
|
||||
@Post('push/register')
|
||||
@ApiOperation({ summary: 'Зарегистрировать FCM-токен устройства' })
|
||||
async registerPushToken(
|
||||
@Headers('authorization') authorization: string | undefined,
|
||||
@Body() dto: RegisterPushTokenDto
|
||||
) {
|
||||
const userId = await getAuthorizedUserId(this.jwt, this.core, authorization);
|
||||
return firstValueFrom(
|
||||
this.core.notifications.RegisterPushToken({
|
||||
userId,
|
||||
token: dto.token,
|
||||
platform: dto.platform ?? 'WEB',
|
||||
deviceLabel: dto.deviceLabel
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@Delete('push/register')
|
||||
@ApiOperation({ summary: 'Удалить FCM-токен устройства' })
|
||||
async unregisterPushToken(
|
||||
@Headers('authorization') authorization: string | undefined,
|
||||
@Body() dto: UnregisterPushTokenDto
|
||||
) {
|
||||
const userId = await getAuthorizedUserId(this.jwt, this.core, authorization);
|
||||
return firstValueFrom(
|
||||
this.core.notifications.UnregisterPushToken({
|
||||
userId,
|
||||
token: dto.token
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user