+import {
+ AbuseState,
+ ActorInfo,
+ FollowState,
+ UserNotification as UserNotificationServer,
+ UserNotificationType,
+ VideoInfo,
+ UserRight
+} from '@shared/models'
import { Actor } from '../account/actor.model'
-import { ActorInfo, Avatar, FollowState, UserNotification as UserNotificationServer, UserNotificationType, VideoInfo } from '@shared/models'
+import { AuthUser } from '@app/core'
export class UserNotification implements UserNotificationServer {
id: number
abuse?: {
id: number
+ state: AbuseState
video?: VideoInfo
videoUrl?: string
commentUrl?: any[]
abuseUrl?: string
+ abuseQueryParams?: { [id: string]: string } = {}
videoAutoBlacklistUrl?: string
accountUrl?: string
videoImportIdentifier?: string
videoImportUrl?: string
instanceFollowUrl?: string
- constructor (hash: UserNotificationServer) {
+ constructor (hash: UserNotificationServer, user: AuthUser) {
this.id = hash.id
this.type = hash.type
this.read = hash.read
case UserNotificationType.NEW_ABUSE_FOR_MODERATORS:
this.abuseUrl = '/admin/moderation/abuses/list'
+ this.abuseQueryParams.search = '#' + this.abuse.id
if (this.abuse.video) this.videoUrl = this.buildVideoUrl(this.abuse.video)
else if (this.abuse.comment) this.commentUrl = this.buildCommentUrl(this.abuse.comment)
else if (this.abuse.account) this.accountUrl = this.buildAccountUrl(this.abuse.account)
break
+ case UserNotificationType.ABUSE_STATE_CHANGE:
+ this.abuseUrl = '/my-account/abuses'
+ this.abuseQueryParams.search = '#' + this.abuse.id
+ break
+
+ case UserNotificationType.ABUSE_NEW_MESSAGE:
+ this.abuseUrl = user.hasRight(UserRight.MANAGE_ABUSES)
+ ? '/admin/moderation/abuses/list'
+ : '/my-account/abuses'
+ this.abuseQueryParams.search = '#' + this.abuse.id
+ break
+
case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS:
this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list'
// Backward compatibility where we did not assign videoBlacklist to this type of notification before