diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-22 10:43:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-22 10:43:11 +0200 |
commit | 5c5e587307a27e173333789b5b5167d35f468b01 (patch) | |
tree | 94e3721caf2e11d38fd5f4112c0fc98da89ac535 /server/models/account/user-notification.ts | |
parent | 1b42d73f44811eec1b7ddd72dd0d640a57c3376c (diff) | |
parent | b5fecbf44192144d1ca27c23a0b53922de288c10 (diff) | |
download | PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.tar.gz PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.tar.zst PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.zip |
Merge branch 'feature/strong-model-types' into develop
Diffstat (limited to 'server/models/account/user-notification.ts')
-rw-r--r-- | server/models/account/user-notification.ts | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts index f38cd7e78..9b13a8376 100644 --- a/server/models/account/user-notification.ts +++ b/server/models/account/user-notification.ts | |||
@@ -16,6 +16,7 @@ import { ActorModel } from '../activitypub/actor' | |||
16 | import { ActorFollowModel } from '../activitypub/actor-follow' | 16 | import { ActorFollowModel } from '../activitypub/actor-follow' |
17 | import { AvatarModel } from '../avatar/avatar' | 17 | import { AvatarModel } from '../avatar/avatar' |
18 | import { ServerModel } from '../server/server' | 18 | import { ServerModel } from '../server/server' |
19 | import { UserNotificationIncludes, UserNotificationModelForApi } from '@server/typings/models/user' | ||
19 | 20 | ||
20 | enum ScopeNames { | 21 | enum ScopeNames { |
21 | WITH_ALL = 'WITH_ALL' | 22 | WITH_ALL = 'WITH_ALL' |
@@ -371,7 +372,7 @@ export class UserNotificationModel extends Model<UserNotificationModel> { | |||
371 | return UserNotificationModel.update({ read: true }, query) | 372 | return UserNotificationModel.update({ read: true }, query) |
372 | } | 373 | } |
373 | 374 | ||
374 | toFormattedJSON (): UserNotification { | 375 | toFormattedJSON (this: UserNotificationModelForApi): UserNotification { |
375 | const video = this.Video | 376 | const video = this.Video |
376 | ? Object.assign(this.formatVideo(this.Video),{ channel: this.formatActor(this.Video.VideoChannel) }) | 377 | ? Object.assign(this.formatVideo(this.Video),{ channel: this.formatActor(this.Video.VideoChannel) }) |
377 | : undefined | 378 | : undefined |
@@ -436,7 +437,7 @@ export class UserNotificationModel extends Model<UserNotificationModel> { | |||
436 | } | 437 | } |
437 | } | 438 | } |
438 | 439 | ||
439 | private formatVideo (video: VideoModel) { | 440 | formatVideo (this: UserNotificationModelForApi, video: UserNotificationIncludes.VideoInclude) { |
440 | return { | 441 | return { |
441 | id: video.id, | 442 | id: video.id, |
442 | uuid: video.uuid, | 443 | uuid: video.uuid, |
@@ -444,7 +445,10 @@ export class UserNotificationModel extends Model<UserNotificationModel> { | |||
444 | } | 445 | } |
445 | } | 446 | } |
446 | 447 | ||
447 | private formatActor (accountOrChannel: AccountModel | VideoChannelModel) { | 448 | formatActor ( |
449 | this: UserNotificationModelForApi, | ||
450 | accountOrChannel: UserNotificationIncludes.AccountIncludeActor | UserNotificationIncludes.VideoChannelIncludeActor | ||
451 | ) { | ||
448 | const avatar = accountOrChannel.Actor.Avatar | 452 | const avatar = accountOrChannel.Actor.Avatar |
449 | ? { path: accountOrChannel.Actor.Avatar.getStaticPath() } | 453 | ? { path: accountOrChannel.Actor.Avatar.getStaticPath() } |
450 | : undefined | 454 | : undefined |