diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/models/users/user-notification-setting.model.ts | 7 | ||||
-rw-r--r-- | shared/models/users/user-notification.model.ts | 4 | ||||
-rw-r--r-- | shared/utils/server/jobs.ts | 3 | ||||
-rw-r--r-- | shared/utils/users/user-notifications.ts | 11 |
4 files changed, 20 insertions, 5 deletions
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts index f580e827e..531e12bba 100644 --- a/shared/models/users/user-notification-setting.model.ts +++ b/shared/models/users/user-notification-setting.model.ts | |||
@@ -1,8 +1,7 @@ | |||
1 | export enum UserNotificationSettingValue { | 1 | export enum UserNotificationSettingValue { |
2 | NONE = 1, | 2 | NONE = 0, |
3 | WEB_NOTIFICATION = 2, | 3 | WEB = 1 << 0, |
4 | EMAIL = 3, | 4 | EMAIL = 1 << 1 |
5 | WEB_NOTIFICATION_AND_EMAIL = 4 | ||
6 | } | 5 | } |
7 | 6 | ||
8 | export interface UserNotificationSetting { | 7 | export interface UserNotificationSetting { |
diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts index 9dd4f099f..f41b6f534 100644 --- a/shared/models/users/user-notification.model.ts +++ b/shared/models/users/user-notification.model.ts | |||
@@ -2,11 +2,15 @@ export enum UserNotificationType { | |||
2 | NEW_VIDEO_FROM_SUBSCRIPTION = 1, | 2 | NEW_VIDEO_FROM_SUBSCRIPTION = 1, |
3 | NEW_COMMENT_ON_MY_VIDEO = 2, | 3 | NEW_COMMENT_ON_MY_VIDEO = 2, |
4 | NEW_VIDEO_ABUSE_FOR_MODERATORS = 3, | 4 | NEW_VIDEO_ABUSE_FOR_MODERATORS = 3, |
5 | |||
5 | BLACKLIST_ON_MY_VIDEO = 4, | 6 | BLACKLIST_ON_MY_VIDEO = 4, |
6 | UNBLACKLIST_ON_MY_VIDEO = 5, | 7 | UNBLACKLIST_ON_MY_VIDEO = 5, |
8 | |||
7 | MY_VIDEO_PUBLISHED = 6, | 9 | MY_VIDEO_PUBLISHED = 6, |
10 | |||
8 | MY_VIDEO_IMPORT_SUCCESS = 7, | 11 | MY_VIDEO_IMPORT_SUCCESS = 7, |
9 | MY_VIDEO_IMPORT_ERROR = 8, | 12 | MY_VIDEO_IMPORT_ERROR = 8, |
13 | |||
10 | NEW_USER_REGISTRATION = 9, | 14 | NEW_USER_REGISTRATION = 9, |
11 | NEW_FOLLOW = 10, | 15 | NEW_FOLLOW = 10, |
12 | COMMENT_MENTION = 11 | 16 | COMMENT_MENTION = 11 |
diff --git a/shared/utils/server/jobs.ts b/shared/utils/server/jobs.ts index 6218c0b66..692b5e24d 100644 --- a/shared/utils/server/jobs.ts +++ b/shared/utils/server/jobs.ts | |||
@@ -29,6 +29,7 @@ function getJobsListPaginationAndSort (url: string, accessToken: string, state: | |||
29 | } | 29 | } |
30 | 30 | ||
31 | async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { | 31 | async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { |
32 | const pendingJobWait = process.env.NODE_PENDING_JOB_WAIT ? parseInt(process.env.NODE_PENDING_JOB_WAIT, 10) : 2000 | ||
32 | let servers: ServerInfo[] | 33 | let servers: ServerInfo[] |
33 | 34 | ||
34 | if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ] | 35 | if (Array.isArray(serversArg) === false) servers = [ serversArg as ServerInfo ] |
@@ -62,7 +63,7 @@ async function waitJobs (serversArg: ServerInfo[] | ServerInfo) { | |||
62 | 63 | ||
63 | // Retry, in case of new jobs were created | 64 | // Retry, in case of new jobs were created |
64 | if (pendingRequests === false) { | 65 | if (pendingRequests === false) { |
65 | await wait(2000) | 66 | await wait(pendingJobWait) |
66 | await Promise.all(tasksBuilder()) | 67 | await Promise.all(tasksBuilder()) |
67 | } | 68 | } |
68 | 69 | ||
diff --git a/shared/utils/users/user-notifications.ts b/shared/utils/users/user-notifications.ts index 1222899e7..bcbe29fc7 100644 --- a/shared/utils/users/user-notifications.ts +++ b/shared/utils/users/user-notifications.ts | |||
@@ -54,6 +54,16 @@ function markAsReadNotifications (url: string, token: string, ids: number[], sta | |||
54 | statusCodeExpected | 54 | statusCodeExpected |
55 | }) | 55 | }) |
56 | } | 56 | } |
57 | function markAsReadAllNotifications (url: string, token: string, statusCodeExpected = 204) { | ||
58 | const path = '/api/v1/users/me/notifications/read-all' | ||
59 | |||
60 | return makePostBodyRequest({ | ||
61 | url, | ||
62 | path, | ||
63 | token, | ||
64 | statusCodeExpected | ||
65 | }) | ||
66 | } | ||
57 | 67 | ||
58 | async function getLastNotification (serverUrl: string, accessToken: string) { | 68 | async function getLastNotification (serverUrl: string, accessToken: string) { |
59 | const res = await getUserNotifications(serverUrl, accessToken, 0, 1, undefined, '-createdAt') | 69 | const res = await getUserNotifications(serverUrl, accessToken, 0, 1, undefined, '-createdAt') |
@@ -409,6 +419,7 @@ export { | |||
409 | CheckerBaseParams, | 419 | CheckerBaseParams, |
410 | CheckerType, | 420 | CheckerType, |
411 | checkNotification, | 421 | checkNotification, |
422 | markAsReadAllNotifications, | ||
412 | checkMyVideoImportIsFinished, | 423 | checkMyVideoImportIsFinished, |
413 | checkUserRegistered, | 424 | checkUserRegistered, |
414 | checkVideoIsPublished, | 425 | checkVideoIsPublished, |