aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-09 10:42:07 +0200
committerChocobozzz <me@florianbigard.com>2019-04-09 10:42:07 +0200
commit8ce1ba6e3efe0a688d6a0b57e8201cde33ad7aac (patch)
tree10fb184225bea38057979019c0427f893b03f77c
parent846751c98b8704c09234688be6e7e23b837a3739 (diff)
downloadPeerTube-8ce1ba6e3efe0a688d6a0b57e8201cde33ad7aac.tar.gz
PeerTube-8ce1ba6e3efe0a688d6a0b57e8201cde33ad7aac.tar.zst
PeerTube-8ce1ba6e3efe0a688d6a0b57e8201cde33ad7aac.zip
Add new instance follower notification in client
-rw-r--r--client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html8
-rw-r--r--client/src/app/shared/images/global-icon.component.ts3
-rw-r--r--client/src/app/shared/users/user-notification.model.ts5
-rw-r--r--client/src/app/shared/users/user-notifications.component.html9
-rw-r--r--client/src/assets/images/global/users.html11
-rw-r--r--client/src/assets/images/global/videos.svg14
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/models/account/user-notification.ts2
8 files changed, 33 insertions, 21 deletions
diff --git a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html
index 59422d682..93e294a96 100644
--- a/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html
+++ b/client/src/app/+my-account/my-account-settings/my-account-notification-preferences/my-account-notification-preferences.component.html
@@ -4,8 +4,8 @@
4 <div i18n *ngIf="emailEnabled">Email</div> 4 <div i18n *ngIf="emailEnabled">Email</div>
5</div> 5</div>
6 6
7<div class="custom-row" *ngFor="let notificationType of notificationSettingKeys"> 7<ng-container *ngFor="let notificationType of notificationSettingKeys">
8 <ng-container *ngIf="hasUserRight(notificationType)"> 8 <div class="custom-row" *ngIf="hasUserRight(notificationType)">
9 <div>{{ labelNotifications[notificationType] }}</div> 9 <div>{{ labelNotifications[notificationType] }}</div>
10 10
11 <div> 11 <div>
@@ -15,5 +15,5 @@
15 <div *ngIf="emailEnabled"> 15 <div *ngIf="emailEnabled">
16 <p-inputSwitch [(ngModel)]="emailNotifications[notificationType]" (onChange)="updateEmailSetting(notificationType, $event.checked)"></p-inputSwitch> 16 <p-inputSwitch [(ngModel)]="emailNotifications[notificationType]" (onChange)="updateEmailSetting(notificationType, $event.checked)"></p-inputSwitch>
17 </div> 17 </div>
18 </ng-container> 18 </div>
19</div> 19</ng-container>
diff --git a/client/src/app/shared/images/global-icon.component.ts b/client/src/app/shared/images/global-icon.component.ts
index d85f269ea..bd5b11bb0 100644
--- a/client/src/app/shared/images/global-icon.component.ts
+++ b/client/src/app/shared/images/global-icon.component.ts
@@ -43,7 +43,8 @@ const icons = {
43 'videos': require('../../../assets/images/global/videos.html'), 43 'videos': require('../../../assets/images/global/videos.html'),
44 'folder': require('../../../assets/images/global/folder.html'), 44 'folder': require('../../../assets/images/global/folder.html'),
45 'administration': require('../../../assets/images/menu/administration.html'), 45 'administration': require('../../../assets/images/menu/administration.html'),
46 'subscriptions': require('../../../assets/images/menu/subscriptions.html') 46 'subscriptions': require('../../../assets/images/menu/subscriptions.html'),
47 'users': require('../../../assets/images/global/users.html')
47} 48}
48 49
49export type GlobalIconName = keyof typeof icons 50export type GlobalIconName = keyof typeof icons
diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts
index 76b983152..72fc3e7b4 100644
--- a/client/src/app/shared/users/user-notification.model.ts
+++ b/client/src/app/shared/users/user-notification.model.ts
@@ -59,6 +59,7 @@ export class UserNotification implements UserNotificationServer {
59 accountUrl?: string 59 accountUrl?: string
60 videoImportIdentifier?: string 60 videoImportIdentifier?: string
61 videoImportUrl?: string 61 videoImportUrl?: string
62 instanceFollowUrl?: string
62 63
63 constructor (hash: UserNotificationServer) { 64 constructor (hash: UserNotificationServer) {
64 this.id = hash.id 65 this.id = hash.id
@@ -141,6 +142,10 @@ export class UserNotification implements UserNotificationServer {
141 case UserNotificationType.NEW_FOLLOW: 142 case UserNotificationType.NEW_FOLLOW:
142 this.accountUrl = this.buildAccountUrl(this.actorFollow.follower) 143 this.accountUrl = this.buildAccountUrl(this.actorFollow.follower)
143 break 144 break
145
146 case UserNotificationType.NEW_INSTANCE_FOLLOWER:
147 this.instanceFollowUrl = '/admin/follows/followers-list'
148 break
144 } 149 }
145 } catch (err) { 150 } catch (err) {
146 console.error(err) 151 console.error(err)
diff --git a/client/src/app/shared/users/user-notifications.component.html b/client/src/app/shared/users/user-notifications.component.html
index 6d2f2750e..d27f60158 100644
--- a/client/src/app/shared/users/user-notifications.component.html
+++ b/client/src/app/shared/users/user-notifications.component.html
@@ -102,6 +102,15 @@
102 <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.comment.account.displayName }}</a> mentioned you on <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">video {{ notification.comment.video.name }}</a> 102 <a (click)="markAsRead(notification)" [routerLink]="notification.accountUrl">{{ notification.comment.account.displayName }}</a> mentioned you on <a (click)="markAsRead(notification)" [routerLink]="notification.commentUrl">video {{ notification.comment.video.name }}</a>
103 </div> 103 </div>
104 </ng-container> 104 </ng-container>
105
106 <ng-container i18n *ngSwitchCase="UserNotificationType.NEW_INSTANCE_FOLLOWER">
107 <my-global-icon iconName="users"></my-global-icon>
108
109 <div class="message">
110 Your instance has <a (click)="markAsRead(notification)" [routerLink]="notification.instanceFollowUrl">a new follower</a>
111 <ng-container *ngIf="notification.actorFollow.state === 'pending'"> awaiting your approval</ng-container>
112 </div>
113 </ng-container>
105 </ng-container> 114 </ng-container>
106 115
107 <div class="from-date">{{ notification.createdAt | myFromNow }}</div> 116 <div class="from-date">{{ notification.createdAt | myFromNow }}</div>
diff --git a/client/src/assets/images/global/users.html b/client/src/assets/images/global/users.html
new file mode 100644
index 000000000..522883785
--- /dev/null
+++ b/client/src/assets/images/global/users.html
@@ -0,0 +1,11 @@
1<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3 <g id="Artboard-4" transform="translate(-92.000000, -863.000000)">
4 <g id="342" transform="translate(92.000000, 863.000000)">
5 <path d="M7,21 C7,21 7,17 11,17 C15,17 14.9937515,17 19,17 C23.0062485,17 23.0062485,21 23.0062485,21" id="Path-41" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
6 <path d="M8.27455269,11.9477557 C5.85692935,11.5963698 4,9.51503944 4,7 C4,4.23857625 6.23857625,2 9,2 C10.373942,2 11.6184509,2.55416948 12.5221996,3.45118158 C11.8469348,3.70680858 11.2215328,4.06387931 10.664592,4.50379553 C10.1883045,4.18555118 9.61582114,4 9,4 C7.34314575,4 6,5.34314575 6,7 C6,8.3069749 6.83577432,9.41874424 8.00202365,9.83000873 C8.00067709,9.88650926 8,9.94317556 8,10 C8,10.6759052 8.09579644,11.329436 8.27455269,11.9477557 Z M8.67363116,13 L5,13 C2.85717375,13 1.39436214,13.9752077 0.605572809,15.5527864 C0.148670182,16.4665917 -7.10542736e-14,17.3586127 -7.10542736e-14,18 C-7.10542736e-14,18.5522847 0.44771525,19 1,19 C1.55228475,19 2,18.5522847 2,18 C2,17.9269061 2.01176795,17.7621548 2.04889392,17.539399 C2.11167338,17.1627222 2.22417415,16.7877197 2.39442719,16.4472136 C2.85563786,15.5247923 3.64282625,15 5,15 L10.1010173,15 C9.51513298,14.4258795 9.02972955,13.7496048 8.67363116,13 Z" id="Combined-Shape" fill="#000000" fill-rule="nonzero"/>
7 <circle id="Oval-40" stroke="#000000" stroke-width="2" cx="15" cy="10" r="4"/>
8 </g>
9 </g>
10 </g>
11</svg>
diff --git a/client/src/assets/images/global/videos.svg b/client/src/assets/images/global/videos.svg
deleted file mode 100644
index 6e37f466f..000000000
--- a/client/src/assets/images/global/videos.svg
+++ /dev/null
@@ -1,14 +0,0 @@
1<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
2 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3 <g id="Artboard-4" transform="translate(-312.000000, -511.000000)">
4 <g id="187" transform="translate(312.000000, 511.000000)">
5 <rect id="Rectangle-124" stroke="#000000" stroke-width="2" x="3" y="6" width="18" height="16" rx="1"/>
6
7 <polygon fill="#000000" id="Triangle-1" points="10 17.5 10 10.4 15.5 13.9"/>
8
9 <rect id="Rectangle-125" fill="#000000" x="4" y="3" width="16" height="1" rx="0.5"/>
10 <rect id="Rectangle-125" fill="#000000" x="5" y="1" width="14" height="1" rx="0.5"/>
11 </g>
12 </g>
13 </g>
14</svg>
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 7d9ffc668..78dd7cb9d 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -18,7 +18,7 @@ let config: IConfig = require('config')
18 18
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
21const LAST_MIGRATION_VERSION = 355 21const LAST_MIGRATION_VERSION = 360
22 22
23// --------------------------------------------------------------------------- 23// ---------------------------------------------------------------------------
24 24
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts
index ccf8277ab..33480f3b5 100644
--- a/server/models/account/user-notification.ts
+++ b/server/models/account/user-notification.ts
@@ -119,7 +119,7 @@ function buildAccountInclude (required: boolean, withActor = false) {
119 }, 119 },
120 120
121 { 121 {
122 attributes: [ 'id' ], 122 attributes: [ 'id', 'state' ],
123 model: () => ActorFollowModel.unscoped(), 123 model: () => ActorFollowModel.unscoped(),
124 required: false, 124 required: false,
125 include: [ 125 include: [