diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/custom-validators/plugins.ts | 8 | ||||
-rw-r--r-- | server/initializers/checker-before-init.ts | 2 | ||||
-rw-r--r-- | server/initializers/config.ts | 4 | ||||
-rw-r--r-- | server/lib/emailer.ts | 34 | ||||
-rw-r--r-- | server/lib/peertube-socket.ts | 16 |
5 files changed, 36 insertions, 28 deletions
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index b5e32abc2..63af91a44 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts | |||
@@ -41,7 +41,11 @@ function isPluginEngineValid (engine: any) { | |||
41 | } | 41 | } |
42 | 42 | ||
43 | function isPluginHomepage (value: string) { | 43 | function isPluginHomepage (value: string) { |
44 | return isUrlValid(value) | 44 | return exists(value) && (!value || isUrlValid(value)) |
45 | } | ||
46 | |||
47 | function isPluginBugs (value: string) { | ||
48 | return exists(value) && (!value || isUrlValid(value)) | ||
45 | } | 49 | } |
46 | 50 | ||
47 | function areStaticDirectoriesValid (staticDirs: any) { | 51 | function areStaticDirectoriesValid (staticDirs: any) { |
@@ -85,7 +89,7 @@ function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginT | |||
85 | isPluginEngineValid(packageJSON.engine) && | 89 | isPluginEngineValid(packageJSON.engine) && |
86 | isPluginHomepage(packageJSON.homepage) && | 90 | isPluginHomepage(packageJSON.homepage) && |
87 | exists(packageJSON.author) && | 91 | exists(packageJSON.author) && |
88 | isUrlValid(packageJSON.bugs) && | 92 | isPluginBugs(packageJSON.bugs) && |
89 | (pluginType === PluginType.THEME || isSafePath(packageJSON.library)) && | 93 | (pluginType === PluginType.THEME || isSafePath(packageJSON.library)) && |
90 | areStaticDirectoriesValid(packageJSON.staticDirs) && | 94 | areStaticDirectoriesValid(packageJSON.staticDirs) && |
91 | areCSSPathsValid(packageJSON.css) && | 95 | areCSSPathsValid(packageJSON.css) && |
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts index 55bc820f5..a986c3e0e 100644 --- a/server/initializers/checker-before-init.ts +++ b/server/initializers/checker-before-init.ts | |||
@@ -11,7 +11,7 @@ function checkMissedConfig () { | |||
11 | 'trust_proxy', | 11 | 'trust_proxy', |
12 | 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', | 12 | 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', 'database.pool.max', |
13 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', | 13 | 'smtp.hostname', 'smtp.port', 'smtp.username', 'smtp.password', 'smtp.tls', 'smtp.from_address', |
14 | 'email.body.signature', 'email.object.prefix', | 14 | 'email.body.signature', 'email.subject.prefix', |
15 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', | 15 | 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', |
16 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', | 16 | 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', |
17 | 'log.level', | 17 | 'log.level', |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 58241e4ea..510f7d64d 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -48,8 +48,8 @@ const CONFIG = { | |||
48 | BODY: { | 48 | BODY: { |
49 | SIGNATURE: config.get<string>('email.body.signature') | 49 | SIGNATURE: config.get<string>('email.body.signature') |
50 | }, | 50 | }, |
51 | OBJECT: { | 51 | SUBJECT: { |
52 | PREFIX: config.get<string>('email.object.prefix') + ' ' | 52 | PREFIX: config.get<string>('email.subject.prefix') + ' ' |
53 | } | 53 | } |
54 | }, | 54 | }, |
55 | STORAGE: { | 55 | STORAGE: { |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index a888b7a72..76349ef8f 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -100,7 +100,7 @@ class Emailer { | |||
100 | 100 | ||
101 | const emailPayload: EmailPayload = { | 101 | const emailPayload: EmailPayload = { |
102 | to, | 102 | to, |
103 | subject: CONFIG.EMAIL.OBJECT.PREFIX + channelName + ' just published a new video', | 103 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + channelName + ' just published a new video', |
104 | text | 104 | text |
105 | } | 105 | } |
106 | 106 | ||
@@ -119,7 +119,7 @@ class Emailer { | |||
119 | 119 | ||
120 | const emailPayload: EmailPayload = { | 120 | const emailPayload: EmailPayload = { |
121 | to, | 121 | to, |
122 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New follower on your channel ' + followingName, | 122 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'New follower on your channel ' + followingName, |
123 | text | 123 | text |
124 | } | 124 | } |
125 | 125 | ||
@@ -137,7 +137,7 @@ class Emailer { | |||
137 | 137 | ||
138 | const emailPayload: EmailPayload = { | 138 | const emailPayload: EmailPayload = { |
139 | to, | 139 | to, |
140 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New instance follower', | 140 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'New instance follower', |
141 | text | 141 | text |
142 | } | 142 | } |
143 | 143 | ||
@@ -157,7 +157,7 @@ class Emailer { | |||
157 | 157 | ||
158 | const emailPayload: EmailPayload = { | 158 | const emailPayload: EmailPayload = { |
159 | to, | 159 | to, |
160 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video ${video.name} is published`, | 160 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + `Your video ${video.name} is published`, |
161 | text | 161 | text |
162 | } | 162 | } |
163 | 163 | ||
@@ -177,7 +177,7 @@ class Emailer { | |||
177 | 177 | ||
178 | const emailPayload: EmailPayload = { | 178 | const emailPayload: EmailPayload = { |
179 | to, | 179 | to, |
180 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} is finished`, | 180 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} is finished`, |
181 | text | 181 | text |
182 | } | 182 | } |
183 | 183 | ||
@@ -197,7 +197,7 @@ class Emailer { | |||
197 | 197 | ||
198 | const emailPayload: EmailPayload = { | 198 | const emailPayload: EmailPayload = { |
199 | to, | 199 | to, |
200 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, | 200 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, |
201 | text | 201 | text |
202 | } | 202 | } |
203 | 203 | ||
@@ -219,7 +219,7 @@ class Emailer { | |||
219 | 219 | ||
220 | const emailPayload: EmailPayload = { | 220 | const emailPayload: EmailPayload = { |
221 | to, | 221 | to, |
222 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New comment on your video ' + video.name, | 222 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'New comment on your video ' + video.name, |
223 | text | 223 | text |
224 | } | 224 | } |
225 | 225 | ||
@@ -241,7 +241,7 @@ class Emailer { | |||
241 | 241 | ||
242 | const emailPayload: EmailPayload = { | 242 | const emailPayload: EmailPayload = { |
243 | to, | 243 | to, |
244 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Mention on video ' + video.name, | 244 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Mention on video ' + video.name, |
245 | text | 245 | text |
246 | } | 246 | } |
247 | 247 | ||
@@ -258,7 +258,7 @@ class Emailer { | |||
258 | 258 | ||
259 | const emailPayload: EmailPayload = { | 259 | const emailPayload: EmailPayload = { |
260 | to, | 260 | to, |
261 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Received a video abuse', | 261 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Received a video abuse', |
262 | text | 262 | text |
263 | } | 263 | } |
264 | 264 | ||
@@ -281,7 +281,7 @@ class Emailer { | |||
281 | 281 | ||
282 | const emailPayload: EmailPayload = { | 282 | const emailPayload: EmailPayload = { |
283 | to, | 283 | to, |
284 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'An auto-blacklisted video is awaiting review', | 284 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'An auto-blacklisted video is awaiting review', |
285 | text | 285 | text |
286 | } | 286 | } |
287 | 287 | ||
@@ -296,7 +296,7 @@ class Emailer { | |||
296 | 296 | ||
297 | const emailPayload: EmailPayload = { | 297 | const emailPayload: EmailPayload = { |
298 | to, | 298 | to, |
299 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New user registration on ' + WEBSERVER.HOST, | 299 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'New user registration on ' + WEBSERVER.HOST, |
300 | text | 300 | text |
301 | } | 301 | } |
302 | 302 | ||
@@ -318,7 +318,7 @@ class Emailer { | |||
318 | 318 | ||
319 | const emailPayload: EmailPayload = { | 319 | const emailPayload: EmailPayload = { |
320 | to, | 320 | to, |
321 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${videoName} blacklisted`, | 321 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + `Video ${videoName} blacklisted`, |
322 | text | 322 | text |
323 | } | 323 | } |
324 | 324 | ||
@@ -336,7 +336,7 @@ class Emailer { | |||
336 | 336 | ||
337 | const emailPayload: EmailPayload = { | 337 | const emailPayload: EmailPayload = { |
338 | to, | 338 | to, |
339 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${video.name} unblacklisted`, | 339 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + `Video ${video.name} unblacklisted`, |
340 | text | 340 | text |
341 | } | 341 | } |
342 | 342 | ||
@@ -353,7 +353,7 @@ class Emailer { | |||
353 | 353 | ||
354 | const emailPayload: EmailPayload = { | 354 | const emailPayload: EmailPayload = { |
355 | to: [ to ], | 355 | to: [ to ], |
356 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Reset your password', | 356 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Reset your password', |
357 | text | 357 | text |
358 | } | 358 | } |
359 | 359 | ||
@@ -370,7 +370,7 @@ class Emailer { | |||
370 | 370 | ||
371 | const emailPayload: EmailPayload = { | 371 | const emailPayload: EmailPayload = { |
372 | to: [ to ], | 372 | to: [ to ], |
373 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Verify your email', | 373 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Verify your email', |
374 | text | 374 | text |
375 | } | 375 | } |
376 | 376 | ||
@@ -391,7 +391,7 @@ class Emailer { | |||
391 | const to = user.email | 391 | const to = user.email |
392 | const emailPayload: EmailPayload = { | 392 | const emailPayload: EmailPayload = { |
393 | to: [ to ], | 393 | to: [ to ], |
394 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Account ' + blockedWord, | 394 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Account ' + blockedWord, |
395 | text | 395 | text |
396 | } | 396 | } |
397 | 397 | ||
@@ -411,7 +411,7 @@ class Emailer { | |||
411 | fromDisplayName: fromEmail, | 411 | fromDisplayName: fromEmail, |
412 | replyTo: fromEmail, | 412 | replyTo: fromEmail, |
413 | to: [ CONFIG.ADMIN.EMAIL ], | 413 | to: [ CONFIG.ADMIN.EMAIL ], |
414 | subject: CONFIG.EMAIL.OBJECT.PREFIX + subject, | 414 | subject: CONFIG.EMAIL.SUBJECT.PREFIX + subject, |
415 | text | 415 | text |
416 | } | 416 | } |
417 | 417 | ||
diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts index 1c7b09175..ad2bb4845 100644 --- a/server/lib/peertube-socket.ts +++ b/server/lib/peertube-socket.ts | |||
@@ -8,7 +8,7 @@ class PeerTubeSocket { | |||
8 | 8 | ||
9 | private static instance: PeerTubeSocket | 9 | private static instance: PeerTubeSocket |
10 | 10 | ||
11 | private userNotificationSockets: { [ userId: number ]: SocketIO.Socket } = {} | 11 | private userNotificationSockets: { [ userId: number ]: SocketIO.Socket[] } = {} |
12 | 12 | ||
13 | private constructor () {} | 13 | private constructor () {} |
14 | 14 | ||
@@ -22,22 +22,26 @@ class PeerTubeSocket { | |||
22 | 22 | ||
23 | logger.debug('User %d connected on the notification system.', userId) | 23 | logger.debug('User %d connected on the notification system.', userId) |
24 | 24 | ||
25 | this.userNotificationSockets[userId] = socket | 25 | if (!this.userNotificationSockets[userId]) this.userNotificationSockets[userId] = [] |
26 | |||
27 | this.userNotificationSockets[userId].push(socket) | ||
26 | 28 | ||
27 | socket.on('disconnect', () => { | 29 | socket.on('disconnect', () => { |
28 | logger.debug('User %d disconnected from SocketIO notifications.', userId) | 30 | logger.debug('User %d disconnected from SocketIO notifications.', userId) |
29 | 31 | ||
30 | delete this.userNotificationSockets[userId] | 32 | this.userNotificationSockets[userId] = this.userNotificationSockets[userId].filter(s => s !== socket) |
31 | }) | 33 | }) |
32 | }) | 34 | }) |
33 | } | 35 | } |
34 | 36 | ||
35 | sendNotification (userId: number, notification: UserNotificationModelForApi) { | 37 | sendNotification (userId: number, notification: UserNotificationModelForApi) { |
36 | const socket = this.userNotificationSockets[userId] | 38 | const sockets = this.userNotificationSockets[userId] |
37 | 39 | ||
38 | if (!socket) return | 40 | if (!sockets) return |
39 | 41 | ||
40 | socket.emit('new-notification', notification.toFormattedJSON()) | 42 | for (const socket of sockets) { |
43 | socket.emit('new-notification', notification.toFormattedJSON()) | ||
44 | } | ||
41 | } | 45 | } |
42 | 46 | ||
43 | static get Instance () { | 47 | static get Instance () { |