Skip to content
Snippets Groups Projects
Commit 21f1604e authored by Samuli Virtapohja's avatar Samuli Virtapohja
Browse files

Merge branch 'notification-update' into HEAD

parents c81bae60 f4928547
No related branches found
No related tags found
3 merge requests!59Development to master,!44Development to testing,!39added notifications controller&service
import { Controller, Get, Param } from '@nestjs/common';
import { NotificationsService } from './notifications.service';
import { Roles } from 'src/shared/guard.decorator';
@Controller('notifications')
export class NotificationsController {
constructor(private notificationService: NotificationsService) {}
// get all sent notifications for game
// :id is the id of the game
@Get(':id')
@Roles('admin', 'factionleader', 'soldier', 'groupleader')
async(@Param('id') gameId) {
return this.notificationService.getNotifications(gameId);
}
}
...@@ -4,10 +4,13 @@ import { TypeOrmModule } from '@nestjs/typeorm'; ...@@ -4,10 +4,13 @@ import { TypeOrmModule } from '@nestjs/typeorm';
import { NotificationGateway } from './notifications.gateway'; import { NotificationGateway } from './notifications.gateway';
import { NotificationEntity } from './notification.entity'; import { NotificationEntity } from './notification.entity';
import { GameEntity } from '../game/game.entity'; import { GameEntity } from '../game/game.entity';
import { NotificationsController } from './notifications.controller';
import { NotificationsService } from './notifications.service';
@Module({ @Module({
imports: [TypeOrmModule.forFeature([NotificationEntity, GameEntity])], imports: [TypeOrmModule.forFeature([NotificationEntity, GameEntity])],
providers: [NotificationGateway], providers: [NotificationGateway, NotificationsService],
exports: [NotificationGateway], exports: [NotificationGateway],
controllers: [NotificationsController],
}) })
export class NotificationModule {} export class NotificationModule {}
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { NotificationEntity } from './notification.entity';
import { Repository } from 'typeorm';
@Injectable()
export class NotificationsService {
constructor(
@InjectRepository(NotificationEntity)
private notificationRepository: Repository<NotificationEntity>,
) {}
async getNotifications(game: string) {
return this.notificationRepository.find({ game });
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment