X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fusers%2Fuser-notification.model.ts;h=bc1861c643697d1530bd8a05fbe7e71c1ba2e89d;hb=5baee5fca418487e72ddcd6419d31bca8659b668;hp=7d0eb5ea28703d56e93ee022cd1af44e942ee0df;hpb=7ccddd7b5250bd25a917a6e77e58b87b9484a2a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts index 7d0eb5ea2..bc1861c64 100644 --- a/client/src/app/shared/users/user-notification.model.ts +++ b/client/src/app/shared/users/user-notification.model.ts @@ -1,4 +1,4 @@ -import { UserNotification as UserNotificationServer, UserNotificationType, VideoInfo, ActorInfo } from '../../../../../shared' +import { ActorInfo, FollowState, UserNotification as UserNotificationServer, UserNotificationType, VideoInfo, Avatar } from '../../../../../shared' import { Actor } from '@app/shared/actor/actor.model' export class UserNotification implements UserNotificationServer { @@ -39,11 +39,13 @@ export class UserNotification implements UserNotificationServer { actorFollow?: { id: number + state: FollowState follower: ActorInfo & { avatarUrl?: string } following: { - type: 'account' | 'channel' + type: 'account' | 'channel' | 'instance' name: string displayName: string + host: string } } @@ -58,6 +60,7 @@ export class UserNotification implements UserNotificationServer { accountUrl?: string videoImportIdentifier?: string videoImportUrl?: string + instanceFollowUrl?: string constructor (hash: UserNotificationServer) { this.id = hash.id @@ -93,12 +96,13 @@ export class UserNotification implements UserNotificationServer { this.videoUrl = this.buildVideoUrl(this.video) break - case UserNotificationType.UNBLACKLIST_ON_MY_VIDEO: + case UserNotificationType.UNBLOCK_ON_MY_VIDEO: this.videoUrl = this.buildVideoUrl(this.video) break case UserNotificationType.NEW_COMMENT_ON_MY_VIDEO: case UserNotificationType.COMMENT_MENTION: + if (!this.comment) break this.accountUrl = this.buildAccountUrl(this.comment.account) this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ] break @@ -108,12 +112,15 @@ export class UserNotification implements UserNotificationServer { this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) break - case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: + case UserNotificationType.VIDEO_AUTO_BLOCK_FOR_MODERATORS: this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list' - this.videoUrl = this.buildVideoUrl(this.video) + // Backward compatibility where we did not assign videoBlacklist to this type of notification before + if (!this.videoBlacklist) this.videoBlacklist = { id: null, video: this.video } + + this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) break - case UserNotificationType.BLACKLIST_ON_MY_VIDEO: + case UserNotificationType.BLOCK_ON_MY_VIDEO: this.videoUrl = this.buildVideoUrl(this.videoBlacklist.video) break @@ -140,8 +147,17 @@ export class UserNotification implements UserNotificationServer { case UserNotificationType.NEW_FOLLOW: this.accountUrl = this.buildAccountUrl(this.actorFollow.follower) break + + case UserNotificationType.NEW_INSTANCE_FOLLOWER: + this.instanceFollowUrl = '/admin/follows/followers-list' + break + + case UserNotificationType.AUTO_INSTANCE_FOLLOWING: + this.instanceFollowUrl = '/admin/follows/following-list' + break } } catch (err) { + this.type = null console.error(err) } } @@ -162,7 +178,7 @@ export class UserNotification implements UserNotificationServer { return videoImport.targetUrl || videoImport.magnetUri || videoImport.torrentName } - private setAvatarUrl (actor: { avatarUrl?: string, avatar?: { path: string } }) { + private setAvatarUrl (actor: { avatarUrl?: string, avatar?: Avatar }) { actor.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(actor) } }