aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main')
-rw-r--r--client/src/app/shared/shared-main/users/user-notification.model.ts28
-rw-r--r--client/src/app/shared/shared-main/users/user-notification.service.ts5
-rw-r--r--client/src/app/shared/shared-main/users/user-notifications.component.html26
-rw-r--r--client/src/app/shared/shared-main/users/user-notifications.component.ts6
4 files changed, 56 insertions, 9 deletions
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 @@
1import {
2 AbuseState,
3 ActorInfo,
4 FollowState,
5 UserNotification as UserNotificationServer,
6 UserNotificationType,
7 VideoInfo,
8 UserRight
9} from '@shared/models'
1import { Actor } from '../account/actor.model' 10import { Actor } from '../account/actor.model'
2import { ActorInfo, Avatar, FollowState, UserNotification as UserNotificationServer, UserNotificationType, VideoInfo } from '@shared/models' 11import { AuthUser } from '@app/core'
3 12
4export class UserNotification implements UserNotificationServer { 13export class UserNotification implements UserNotificationServer {
5 id: number 14 id: number
@@ -27,6 +36,7 @@ export class UserNotification implements UserNotificationServer {
27 36
28 abuse?: { 37 abuse?: {
29 id: number 38 id: number
39 state: AbuseState
30 40
31 video?: VideoInfo 41 video?: VideoInfo
32 42
@@ -69,13 +79,14 @@ export class UserNotification implements UserNotificationServer {
69 videoUrl?: string 79 videoUrl?: string
70 commentUrl?: any[] 80 commentUrl?: any[]
71 abuseUrl?: string 81 abuseUrl?: string
82 abuseQueryParams?: { [id: string]: string } = {}
72 videoAutoBlacklistUrl?: string 83 videoAutoBlacklistUrl?: string
73 accountUrl?: string 84 accountUrl?: string
74 videoImportIdentifier?: string 85 videoImportIdentifier?: string
75 videoImportUrl?: string 86 videoImportUrl?: string
76 instanceFollowUrl?: string 87 instanceFollowUrl?: string
77 88
78 constructor (hash: UserNotificationServer) { 89 constructor (hash: UserNotificationServer, user: AuthUser) {
79 this.id = hash.id 90 this.id = hash.id
80 this.type = hash.type 91 this.type = hash.type
81 this.read = hash.read 92 this.read = hash.read
@@ -122,12 +133,25 @@ export class UserNotification implements UserNotificationServer {
122 133
123 case UserNotificationType.NEW_ABUSE_FOR_MODERATORS: 134 case UserNotificationType.NEW_ABUSE_FOR_MODERATORS:
124 this.abuseUrl = '/admin/moderation/abuses/list' 135 this.abuseUrl = '/admin/moderation/abuses/list'
136 this.abuseQueryParams.search = '#' + this.abuse.id
125 137
126 if (this.abuse.video) this.videoUrl = this.buildVideoUrl(this.abuse.video) 138 if (this.abuse.video) this.videoUrl = this.buildVideoUrl(this.abuse.video)
127 else if (this.abuse.comment) this.commentUrl = this.buildCommentUrl(this.abuse.comment) 139 else if (this.abuse.comment) this.commentUrl = this.buildCommentUrl(this.abuse.comment)
128 else if (this.abuse.account) this.accountUrl = this.buildAccountUrl(this.abuse.account) 140 else if (this.abuse.account) this.accountUrl = this.buildAccountUrl(this.abuse.account)
129 break 141 break
130 142
143 case UserNotificationType.ABUSE_STATE_CHANGE:
144 this.abuseUrl = '/my-account/abuses'
145 this.abuseQueryParams.search = '#' + this.abuse.id
146 break
147
148 case UserNotificationType.ABUSE_NEW_MESSAGE:
149 this.abuseUrl = user.hasRight(UserRight.MANAGE_ABUSES)
150 ? '/admin/moderation/abuses/list'
151 : '/my-account/abuses'
152 this.abuseQueryParams.search = '#' + this.abuse.id
153 break
154
131 case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: 155 case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS:
132 this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list' 156 this.videoAutoBlacklistUrl = '/admin/moderation/video-auto-blacklist/list'
133 // Backward compatibility where we did not assign videoBlacklist to this type of notification before 157 // 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 @@
1import { catchError, map, tap } from 'rxjs/operators' 1import { catchError, map, tap } from 'rxjs/operators'
2import { HttpClient, HttpParams } from '@angular/common/http' 2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotificationSocket } from '@app/core' 4import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotificationSocket, AuthService } from '@app/core'
5import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' 5import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models'
6import { environment } from '../../../../environments/environment' 6import { environment } from '../../../../environments/environment'
7import { UserNotification } from './user-notification.model' 7import { UserNotification } from './user-notification.model'
@@ -14,6 +14,7 @@ export class UserNotificationService {
14 14
15 constructor ( 15 constructor (
16 private authHttp: HttpClient, 16 private authHttp: HttpClient,
17 private auth: AuthService,
17 private restExtractor: RestExtractor, 18 private restExtractor: RestExtractor,
18 private restService: RestService, 19 private restService: RestService,
19 private userNotificationSocket: UserNotificationSocket 20 private userNotificationSocket: UserNotificationSocket
@@ -84,6 +85,6 @@ export class UserNotificationService {
84 } 85 }
85 86
86 private formatNotification (notification: UserNotificationServer) { 87 private formatNotification (notification: UserNotificationServer) {
87 return new UserNotification(notification) 88 return new UserNotification(notification, this.auth.getUser())
88 } 89 }
89} 90}
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 @@
46 <my-global-icon iconName="flag" aria-hidden="true"></my-global-icon> 46 <my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
47 47
48 <div class="message" *ngIf="notification.videoUrl" i18n> 48 <div class="message" *ngIf="notification.videoUrl" i18n>
49 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl">A new video abuse</a> has been created on video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.abuse.video.name }}</a> 49 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">A new video abuse</a> has been created on video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.abuse.video.name }}</a>
50 </div> 50 </div>
51 51
52 <div class="message" *ngIf="notification.commentUrl" i18n> 52 <div class="message" *ngIf="notification.commentUrl" i18n>
53 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl">A new comment abuse</a> has been created on video <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">{{ notification.abuse.comment.video.name }}</a> 53 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">A new comment abuse</a> has been created on video <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">{{ notification.abuse.comment.video.name }}</a>
54 </div> 54 </div>
55 55
56 <div class="message" *ngIf="notification.accountUrl" i18n> 56 <div class="message" *ngIf="notification.accountUrl" i18n>
57 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl">A new account abuse</a> has been created on account <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.abuse.account.displayName }}</a> 57 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">A new account abuse</a> has been created on account <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.abuse.account.displayName }}</a>
58 </div> 58 </div>
59 59
60 <!-- Deleted entity associated to the abuse --> 60 <!-- Deleted entity associated to the abuse -->
61 <div class="message" *ngIf="!notification.videoUrl && !notification.commentUrl && !notification.accountUrl" i18n> 61 <div class="message" *ngIf="!notification.videoUrl && !notification.commentUrl && !notification.accountUrl" i18n>
62 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl">A new abuse</a> has been created 62 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">A new abuse</a> has been created
63 </div>
64 </ng-container>
65
66 <ng-container *ngSwitchCase="UserNotificationType.ABUSE_STATE_CHANGE">
67 <my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
68
69 <div class="message" i18n>
70 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">Your abuse {{ notification.abuse.id }}</a> has been
71 <ng-container *ngIf="isAccepted(notification)">accepted</ng-container>
72 <ng-container *ngIf="!isAccepted(notification)">rejected</ng-container>
73 </div>
74 </ng-container>
75
76 <ng-container *ngSwitchCase="UserNotificationType.ABUSE_NEW_MESSAGE">
77 <my-global-icon iconName="flag" aria-hidden="true"></my-global-icon>
78
79 <div class="message" i18n>
80 <a (click)="markAsRead(notification)" [routerLink]="notification.abuseUrl" [queryParams]="notification.abuseQueryParams">Abuse {{ notification.abuse.id }}</a> has a new message
63 </div> 81 </div>
64 </ng-container> 82 </ng-container>
65 83
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 @@
1import { Subject } from 'rxjs' 1import { Subject } from 'rxjs'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { ComponentPagination, hasMoreItems, Notifier } from '@app/core' 3import { ComponentPagination, hasMoreItems, Notifier } from '@app/core'
4import { UserNotificationType } from '@shared/models' 4import { UserNotificationType, AbuseState } from '@shared/models'
5import { UserNotification } from './user-notification.model' 5import { UserNotification } from './user-notification.model'
6import { UserNotificationService } from './user-notification.service' 6import { UserNotificationService } from './user-notification.service'
7 7
@@ -116,4 +116,8 @@ export class UserNotificationsComponent implements OnInit {
116 this.sortField = column 116 this.sortField = column
117 this.loadNotifications(true) 117 this.loadNotifications(true)
118 } 118 }
119
120 isAccepted (notification: UserNotification) {
121 return notification.abuse.state === AbuseState.ACCEPTED
122 }
119} 123}