add push settings

This commit is contained in:
lendry
2026-07-07 13:58:01 +03:00
parent 1bd95fa99e
commit 57925fb2c4
25 changed files with 3036 additions and 1756 deletions

View File

@@ -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
})
);
}
}