diff options
Diffstat (limited to 'client/src/app/shared/shared-main')
3 files changed, 59 insertions, 18 deletions
diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index 5fc7989dd..bda88bdee 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts | |||
@@ -14,7 +14,9 @@ export abstract class Actor implements ActorServer { | |||
14 | 14 | ||
15 | avatarUrl: string | 15 | avatarUrl: string |
16 | 16 | ||
17 | static GET_ACTOR_AVATAR_URL (actor: { avatar?: Avatar }) { | 17 | isLocal: boolean |
18 | |||
19 | static GET_ACTOR_AVATAR_URL (actor: { avatar?: { url?: string, path: string } }) { | ||
18 | if (actor?.avatar?.url) return actor.avatar.url | 20 | if (actor?.avatar?.url) return actor.avatar.url |
19 | 21 | ||
20 | if (actor && actor.avatar) { | 22 | if (actor && actor.avatar) { |
@@ -46,10 +48,16 @@ export abstract class Actor implements ActorServer { | |||
46 | this.host = hash.host | 48 | this.host = hash.host |
47 | this.followingCount = hash.followingCount | 49 | this.followingCount = hash.followingCount |
48 | this.followersCount = hash.followersCount | 50 | this.followersCount = hash.followersCount |
49 | this.createdAt = new Date(hash.createdAt.toString()) | 51 | |
50 | this.updatedAt = new Date(hash.updatedAt.toString()) | 52 | if (hash.createdAt) this.createdAt = new Date(hash.createdAt.toString()) |
53 | if (hash.updatedAt) this.updatedAt = new Date(hash.updatedAt.toString()) | ||
54 | |||
51 | this.avatar = hash.avatar | 55 | this.avatar = hash.avatar |
52 | 56 | ||
57 | const absoluteAPIUrl = getAbsoluteAPIUrl() | ||
58 | const thisHost = new URL(absoluteAPIUrl).host | ||
59 | this.isLocal = this.host.trim() === thisHost | ||
60 | |||
53 | this.updateComputedAttributes() | 61 | this.updateComputedAttributes() |
54 | } | 62 | } |
55 | 63 | ||
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 de25d3ab9..61b48a806 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 | |||
@@ -25,9 +25,22 @@ export class UserNotification implements UserNotificationServer { | |||
25 | video: VideoInfo | 25 | video: VideoInfo |
26 | } | 26 | } |
27 | 27 | ||
28 | videoAbuse?: { | 28 | abuse?: { |
29 | id: number | 29 | id: number |
30 | video: VideoInfo | 30 | |
31 | video?: VideoInfo | ||
32 | |||
33 | comment?: { | ||
34 | threadId: number | ||
35 | |||
36 | video: { | ||
37 | id: number | ||
38 | uuid: string | ||
39 | name: string | ||
40 | } | ||
41 | } | ||
42 | |||
43 | account?: ActorInfo | ||
31 | } | 44 | } |
32 | 45 | ||
33 | videoBlacklist?: { | 46 | videoBlacklist?: { |
@@ -55,7 +68,7 @@ export class UserNotification implements UserNotificationServer { | |||
55 | // Additional fields | 68 | // Additional fields |
56 | videoUrl?: string | 69 | videoUrl?: string |
57 | commentUrl?: any[] | 70 | commentUrl?: any[] |
58 | videoAbuseUrl?: string | 71 | abuseUrl?: string |
59 | videoAutoBlacklistUrl?: string | 72 | videoAutoBlacklistUrl?: string |
60 | accountUrl?: string | 73 | accountUrl?: string |
61 | videoImportIdentifier?: string | 74 | videoImportIdentifier?: string |
@@ -78,7 +91,7 @@ export class UserNotification implements UserNotificationServer { | |||
78 | this.comment = hash.comment | 91 | this.comment = hash.comment |
79 | if (this.comment) this.setAvatarUrl(this.comment.account) | 92 | if (this.comment) this.setAvatarUrl(this.comment.account) |
80 | 93 | ||
81 | this.videoAbuse = hash.videoAbuse | 94 | this.abuse = hash.abuse |
82 | 95 | ||
83 | this.videoBlacklist = hash.videoBlacklist | 96 | this.videoBlacklist = hash.videoBlacklist |
84 | 97 | ||
@@ -104,12 +117,15 @@ export class UserNotification implements UserNotificationServer { | |||
104 | case UserNotificationType.COMMENT_MENTION: | 117 | case UserNotificationType.COMMENT_MENTION: |
105 | if (!this.comment) break | 118 | if (!this.comment) break |
106 | this.accountUrl = this.buildAccountUrl(this.comment.account) | 119 | this.accountUrl = this.buildAccountUrl(this.comment.account) |
107 | this.commentUrl = [ this.buildVideoUrl(this.comment.video), { threadId: this.comment.threadId } ] | 120 | this.commentUrl = this.buildCommentUrl(this.comment) |
108 | break | 121 | break |
109 | 122 | ||
110 | case UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS: | 123 | case UserNotificationType.NEW_ABUSE_FOR_MODERATORS: |
111 | this.videoAbuseUrl = '/admin/moderation/video-abuses/list' | 124 | this.abuseUrl = '/admin/moderation/abuses/list' |
112 | this.videoUrl = this.buildVideoUrl(this.videoAbuse.video) | 125 | |
126 | if (this.abuse.video) this.videoUrl = this.buildVideoUrl(this.abuse.video) | ||
127 | 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) | ||
113 | break | 129 | break |
114 | 130 | ||
115 | case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: | 131 | case UserNotificationType.VIDEO_AUTO_BLACKLIST_FOR_MODERATORS: |
@@ -178,7 +194,11 @@ export class UserNotification implements UserNotificationServer { | |||
178 | return videoImport.targetUrl || videoImport.magnetUri || videoImport.torrentName | 194 | return videoImport.targetUrl || videoImport.magnetUri || videoImport.torrentName |
179 | } | 195 | } |
180 | 196 | ||
181 | private setAvatarUrl (actor: { avatarUrl?: string, avatar?: Avatar }) { | 197 | private buildCommentUrl (comment: { video: { uuid: string }, threadId: number }) { |
198 | return [ this.buildVideoUrl(comment.video), { threadId: comment.threadId } ] | ||
199 | } | ||
200 | |||
201 | private setAvatarUrl (actor: { avatarUrl?: string, avatar?: { url?: string, path: string } }) { | ||
182 | actor.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(actor) | 202 | actor.avatarUrl = Actor.GET_ACTOR_AVATAR_URL(actor) |
183 | } | 203 | } |
184 | } | 204 | } |
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 d5be1470e..8127ae979 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 | |||
@@ -19,7 +19,7 @@ | |||
19 | 19 | ||
20 | <ng-template #noVideo> | 20 | <ng-template #noVideo> |
21 | <my-global-icon iconName="alert" aria-hidden="true"></my-global-icon> | 21 | <my-global-icon iconName="alert" aria-hidden="true"></my-global-icon> |
22 | 22 | ||
23 | <div class="message" i18n> | 23 | <div class="message" i18n> |
24 | The notification concerns a video now unavailable | 24 | The notification concerns a video now unavailable |
25 | </div> | 25 | </div> |
@@ -42,11 +42,24 @@ | |||
42 | </div> | 42 | </div> |
43 | </ng-container> | 43 | </ng-container> |
44 | 44 | ||
45 | <ng-container *ngSwitchCase="UserNotificationType.NEW_VIDEO_ABUSE_FOR_MODERATORS"> | 45 | <ng-container *ngSwitchCase="UserNotificationType.NEW_ABUSE_FOR_MODERATORS"> |
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" i18n> | 48 | <div class="message" *ngIf="notification.videoUrl" i18n> |
49 | <a (click)="markAsRead(notification)" [routerLink]="notification.videoAbuseUrl">A new video abuse</a> has been created on video <a (click)="markAsRead(notification)" [routerLink]="notification.videoUrl">{{ notification.videoAbuse.video.name }}</a> | 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> |
50 | </div> | ||
51 | |||
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> | ||
54 | </div> | ||
55 | |||
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> | ||
58 | </div> | ||
59 | |||
60 | <!-- Deleted entity associated to the abuse --> | ||
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 | ||
50 | </div> | 63 | </div> |
51 | </ng-container> | 64 | </ng-container> |
52 | 65 | ||
@@ -65,7 +78,7 @@ | |||
65 | <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl"> | 78 | <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl"> |
66 | <img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" /> | 79 | <img alt="" aria-labelledby="avatar" class="avatar" [src]="notification.comment.account.avatarUrl" /> |
67 | </a> | 80 | </a> |
68 | 81 | ||
69 | <div class="message" i18n> | 82 | <div class="message" i18n> |
70 | <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.comment.account.displayName }}</a> commented your video <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">{{ notification.comment.video.name }}</a> | 83 | <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.comment.account.displayName }}</a> commented your video <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">{{ notification.comment.video.name }}</a> |
71 | </div> | 84 | </div> |
@@ -73,7 +86,7 @@ | |||
73 | 86 | ||
74 | <ng-template #noComment> | 87 | <ng-template #noComment> |
75 | <my-global-icon iconName="alert" aria-hidden="true"></my-global-icon> | 88 | <my-global-icon iconName="alert" aria-hidden="true"></my-global-icon> |
76 | 89 | ||
77 | <div class="message" i18n> | 90 | <div class="message" i18n> |
78 | The notification concerns a comment now unavailable | 91 | The notification concerns a comment now unavailable |
79 | </div> | 92 | </div> |