From d573926e9b94fb19c8f51c53f71fc853182e1761 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 28 Jul 2020 09:57:16 +0200 Subject: Add migrations for abuse messages --- .../shared-main/users/user-notification.model.ts | 28 ++++++++++++++++++++-- .../shared-main/users/user-notification.service.ts | 5 ++-- .../users/user-notifications.component.html | 26 ++++++++++++++++---- .../users/user-notifications.component.ts | 6 ++++- 4 files changed, 56 insertions(+), 9 deletions(-) (limited to 'client/src/app/shared/shared-main') diff --git a/client/src/app/shared/shared-main/users/user-notification.model.ts b/client/src/app/shared/shared-main/users/user-notification.model.ts index 61b48a806..a068daaac 100644 --- a/client/src/app/shared/shared-main/users/user-notification.model.ts +++ b/client/src/app/shared/shared-main/users/user-notification.model.ts @@ -1,5 +1,14 @@ +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 @@ -27,6 +36,7 @@ export class UserNotification implements UserNotificationServer { abuse?: { id: number + state: AbuseState video?: VideoInfo @@ -69,13 +79,14 @@ export class UserNotification implements UserNotificationServer { 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 @@ -122,12 +133,25 @@ export class UserNotification implements UserNotificationServer { 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 diff --git a/client/src/app/shared/shared-main/users/user-notification.service.ts b/client/src/app/shared/shared-main/users/user-notification.service.ts index ecc66ecdb..7b9dc34be 100644 --- a/client/src/app/shared/shared-main/users/user-notification.service.ts +++ b/client/src/app/shared/shared-main/users/user-notification.service.ts @@ -1,7 +1,7 @@ import { catchError, map, tap } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' -import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotificationSocket } from '@app/core' +import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotificationSocket, AuthService } from '@app/core' import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' import { environment } from '../../../../environments/environment' import { UserNotification } from './user-notification.model' @@ -14,6 +14,7 @@ export class UserNotificationService { constructor ( private authHttp: HttpClient, + private auth: AuthService, private restExtractor: RestExtractor, private restService: RestService, private userNotificationSocket: UserNotificationSocket @@ -84,6 +85,6 @@ export class UserNotificationService { } private formatNotification (notification: UserNotificationServer) { - return new UserNotification(notification) + return new UserNotification(notification, this.auth.getUser()) } } diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.html b/client/src/app/shared/shared-main/users/user-notifications.component.html index 8127ae979..a56a0859b 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.html +++ b/client/src/app/shared/shared-main/users/user-notifications.component.html @@ -46,20 +46,38 @@
- A new video abuse has been created on video {{ notification.abuse.video.name }} + A new video abuse has been created on video {{ notification.abuse.video.name }}
- A new comment abuse has been created on video {{ notification.abuse.comment.video.name }} + A new comment abuse has been created on video {{ notification.abuse.comment.video.name }}
- A new account abuse has been created on account {{ notification.abuse.account.displayName }} + A new account abuse has been created on account {{ notification.abuse.account.displayName }}
- A new abuse has been created + A new abuse has been created +
+ + + + + +
+ Your abuse {{ notification.abuse.id }} has been + accepted + rejected +
+
+ + + + +
+ Abuse {{ notification.abuse.id }} has a new message
diff --git a/client/src/app/shared/shared-main/users/user-notifications.component.ts b/client/src/app/shared/shared-main/users/user-notifications.component.ts index 7518dbdd0..387c49d94 100644 --- a/client/src/app/shared/shared-main/users/user-notifications.component.ts +++ b/client/src/app/shared/shared-main/users/user-notifications.component.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { ComponentPagination, hasMoreItems, Notifier } from '@app/core' -import { UserNotificationType } from '@shared/models' +import { UserNotificationType, AbuseState } from '@shared/models' import { UserNotification } from './user-notification.model' import { UserNotificationService } from './user-notification.service' @@ -116,4 +116,8 @@ export class UserNotificationsComponent implements OnInit { this.sortField = column this.loadNotifications(true) } + + isAccepted (notification: UserNotification) { + return notification.abuse.state === AbuseState.ACCEPTED + } } -- cgit v1.2.3