Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Commit

Permalink
feat: add post to comment notifications; include post in notification…
Browse files Browse the repository at this point in the history
… response
  • Loading branch information
mentos1386 committed Jul 17, 2018
1 parent 6b9efbb commit 48e386d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/modules/comment/events/handlers/create.handler.ts
Expand Up @@ -35,6 +35,7 @@ export class CreateCommentEventHandler implements IEventHandler<CreateCommentEve
notification.senderCharacter = event.comment.character;
notification.recipient = participant;
notification.comment = event.comment;
notification.post = event.comment.post;
notification.type = NOTIFICATION_TYPE.NEW_COMMENT_ON_A_POST_YOU_PARTICIPATE;
// Execute create notification command
await this.commandBus.execute(new CreateNotificationCommand(notification));
Expand Down
5 changes: 3 additions & 2 deletions src/modules/notification/notification.dto.ts
Expand Up @@ -8,6 +8,7 @@ import { DCharacterShort } from '../character/character.dto';
import { DCorporationShort } from '../corporation/corporation.dto';
import { DAllianceShort } from '../alliance/alliance.dto';
import { ApiModelProperty, ApiModelPropertyOptional } from '@nestjs/swagger';
import { DPost } from '../post/post.dto';

export class DNotification {
@ApiModelProperty()
Expand All @@ -21,7 +22,7 @@ export class DNotification {
type: NOTIFICATION_TYPE;

@ApiModelPropertyOptional()
postId?: string;
post?: DPost;
@ApiModelPropertyOptional()
commentId?: string;

Expand All @@ -48,7 +49,7 @@ export class DNotification {
this.senderAlliance = new DAllianceShort(notification.senderAlliance);
}

if (notification.post) this.postId = notification.post.id;
if (notification.post) this.post = new DPost(notification.post);
if (notification.comment) this.commentId = notification.comment.id;
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/modules/notification/notification.repository.ts
Expand Up @@ -41,6 +41,32 @@ export class NotificationRepository extends Repository<Notification> {
.leftJoinAndSelect('notification.senderCorporation', 'senderCorporation')
.leftJoinAndSelect('senderCorporation.alliance', 'senderCorporationAlliance')
.leftJoinAndSelect('notification.senderAlliance', 'senderAlliance')
.leftJoinAndSelect('notification.post', 'post')
.leftJoinAndSelect('post.character', 'authorCharacter')
.leftJoinAndSelect('authorCharacter.corporation', 'authorCharacterCorporation')
.leftJoinAndSelect('authorCharacterCorporation.alliance', 'authorCharacterAlliance')
.leftJoinAndSelect('post.corporation', 'authorCorporation')
.leftJoinAndSelect('authorCorporation.alliance', 'authorCorporationAlliance')
.leftJoinAndSelect('post.alliance', 'authorAlliance')
.leftJoinAndSelect('post.characterWall', 'onCharacterWall')
.leftJoinAndSelect('onCharacterWall.corporation', 'onCharacterWallCorporation')
.leftJoinAndSelect('onCharacterWallCorporation.alliance', 'onCharacterWallAlliance')
.leftJoinAndSelect('post.corporationWall', 'onCorporationWall')
.leftJoinAndSelect('onCorporationWall.alliance', 'onCorporationWallAlliance')
.leftJoinAndSelect('post.allianceWall', 'onAllianceWall')
.leftJoinAndSelect('post.killmail', 'killmail')
.leftJoinAndSelect('post.hashtags', 'hashtag')
.leftJoinAndSelect('post.location', 'location')
.leftJoinAndSelect('killmail.participants', 'killmailP')
.leftJoinAndSelect('killmailP.character', 'killmailPCharacter')
.leftJoinAndSelect('killmailPCharacter.corporation', 'killmailPCorporation')
.leftJoinAndSelect('killmailPCorporation.alliance', 'killmailPAlliance')
.leftJoinAndSelect('killmailP.ship', 'killmailPShip')
.leftJoinAndSelect('killmailPShip.group', 'killmailPShipGroup')
.leftJoinAndSelect('killmailPShipGroup.category', 'killmailPShipGroupCategory')
.leftJoinAndSelect('killmailP.weapon', 'killmailPWeapon')
.leftJoinAndSelect('killmailPWeapon.group', 'killmailPWeaponGroup')
.leftJoinAndSelect('killmailPWeaponGroup.category', 'killmailPWeaponGroupCategory')
.where('notification."recipientId" = :characterId', { characterId: character.id })
.orderBy({ 'notification."createdAt"': 'DESC' })
.offset(limit * page)
Expand Down

0 comments on commit 48e386d

Please sign in to comment.