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
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,14 @@ export class SettingsController {
|
||||
return this.core.settings.TestMessagingDelivery({ channel: dto.channel, target: dto.target });
|
||||
}
|
||||
|
||||
@Post('firebase/test')
|
||||
@ApiOperation({ summary: 'Тест Firebase Push', description: 'Отправляет тестовое push-уведомление на устройства текущего администратора.' })
|
||||
@ApiResponse({ status: 200, description: 'Тестовое push-уведомление отправлено' })
|
||||
testFirebasePush(@CurrentAdmin() admin: AdminRequestUser) {
|
||||
assertAdminPermission(admin, 'canManageSettings');
|
||||
return this.core.settings.TestFirebasePush({ userId: admin.id });
|
||||
}
|
||||
|
||||
@Get('linked-accounts/users/:userId')
|
||||
@ApiOperation({ summary: 'Связанные внешние аккаунты', description: 'Возвращает LinkedAccount записи пользователя для Google/Yandex и других провайдеров.' })
|
||||
@ApiParam({ name: 'userId', description: 'ID пользователя' })
|
||||
|
||||
Reference in New Issue
Block a user