aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/videos/refresh.ts10
-rw-r--r--server/lib/activitypub/videos/shared/abstract-builder.ts2
-rw-r--r--server/lib/activitypub/videos/shared/creator.ts10
-rw-r--r--server/lib/activitypub/videos/shared/video-sync-attributes.ts6
-rw-r--r--server/lib/activitypub/videos/updater.ts12
5 files changed, 22 insertions, 18 deletions
diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts
index da068cde9..71a4e75b0 100644
--- a/server/lib/activitypub/videos/refresh.ts
+++ b/server/lib/activitypub/videos/refresh.ts
@@ -8,8 +8,6 @@ import { HttpStatusCode } from '@shared/core-utils'
8import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' 8import { fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
9import { APVideoUpdater } from './updater' 9import { APVideoUpdater } from './updater'
10 10
11const lTags = loggerTagsFactory('ap', 'video', 'refresh')
12
13async function refreshVideoIfNeeded (options: { 11async function refreshVideoIfNeeded (options: {
14 video: MVideoThumbnail 12 video: MVideoThumbnail
15 fetchedType: VideoFetchByUrlType 13 fetchedType: VideoFetchByUrlType
@@ -22,11 +20,13 @@ async function refreshVideoIfNeeded (options: {
22 ? options.video as MVideoAccountLightBlacklistAllFiles 20 ? options.video as MVideoAccountLightBlacklistAllFiles
23 : await VideoModel.loadByUrlAndPopulateAccount(options.video.url) 21 : await VideoModel.loadByUrlAndPopulateAccount(options.video.url)
24 22
23 const lTags = loggerTagsFactory('ap', 'video', 'refresh', video.uuid, video.url)
24
25 try { 25 try {
26 const { videoObject } = await fetchRemoteVideo(video.url) 26 const { videoObject } = await fetchRemoteVideo(video.url)
27 27
28 if (videoObject === undefined) { 28 if (videoObject === undefined) {
29 logger.warn('Cannot refresh remote video %s: invalid body.', video.url, lTags(video.uuid)) 29 logger.warn('Cannot refresh remote video %s: invalid body.', video.url, lTags())
30 30
31 await video.setAsRefreshed() 31 await video.setAsRefreshed()
32 return video 32 return video
@@ -42,14 +42,14 @@ async function refreshVideoIfNeeded (options: {
42 return video 42 return video
43 } catch (err) { 43 } catch (err) {
44 if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) { 44 if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
45 logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url, lTags(video.uuid)) 45 logger.info('Cannot refresh remote video %s: video does not exist anymore. Deleting it.', video.url, lTags())
46 46
47 // Video does not exist anymore 47 // Video does not exist anymore
48 await video.destroy() 48 await video.destroy()
49 return undefined 49 return undefined
50 } 50 }
51 51
52 logger.warn('Cannot refresh video %s.', options.video.url, { err, ...lTags(video.uuid) }) 52 logger.warn('Cannot refresh video %s.', options.video.url, { err, ...lTags() })
53 53
54 ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId) 54 ActorFollowScoreCache.Instance.addBadServerId(video.VideoChannel.Actor.serverId)
55 55
diff --git a/server/lib/activitypub/videos/shared/abstract-builder.ts b/server/lib/activitypub/videos/shared/abstract-builder.ts
index f8e4d6aa3..4bd38b40c 100644
--- a/server/lib/activitypub/videos/shared/abstract-builder.ts
+++ b/server/lib/activitypub/videos/shared/abstract-builder.ts
@@ -43,7 +43,7 @@ export abstract class APVideoAbstractBuilder {
43 video, 43 video,
44 type: ThumbnailType.MINIATURE 44 type: ThumbnailType.MINIATURE
45 }).catch(err => { 45 }).catch(err => {
46 logger.warn('Cannot generate thumbnail of %s.', this.videoObject.id, { err, ...this.lTags(video.uuid) }) 46 logger.warn('Cannot generate thumbnail of %s.', this.videoObject.id, { err, ...this.lTags() })
47 47
48 return undefined 48 return undefined
49 }) 49 })
diff --git a/server/lib/activitypub/videos/shared/creator.ts b/server/lib/activitypub/videos/shared/creator.ts
index ba3f6f77f..767bf0695 100644
--- a/server/lib/activitypub/videos/shared/creator.ts
+++ b/server/lib/activitypub/videos/shared/creator.ts
@@ -1,5 +1,5 @@
1 1
2import { logger, loggerTagsFactory } from '@server/helpers/logger' 2import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger'
3import { sequelizeTypescript } from '@server/initializers/database' 3import { sequelizeTypescript } from '@server/initializers/database'
4import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' 4import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist'
5import { VideoModel } from '@server/models/video/video' 5import { VideoModel } from '@server/models/video/video'
@@ -9,14 +9,16 @@ import { APVideoAbstractBuilder } from './abstract-builder'
9import { getVideoAttributesFromObject } from './object-to-model-attributes' 9import { getVideoAttributesFromObject } from './object-to-model-attributes'
10 10
11export class APVideoCreator extends APVideoAbstractBuilder { 11export class APVideoCreator extends APVideoAbstractBuilder {
12 protected lTags = loggerTagsFactory('ap', 'video', 'create') 12 protected lTags: LoggerTagsFn
13 13
14 constructor (protected readonly videoObject: VideoObject) { 14 constructor (protected readonly videoObject: VideoObject) {
15 super() 15 super()
16
17 this.lTags = loggerTagsFactory('ap', 'video', 'create', this.videoObject.uuid, this.videoObject.id)
16 } 18 }
17 19
18 async create (waitThumbnail = false) { 20 async create (waitThumbnail = false) {
19 logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags(this.videoObject.uuid)) 21 logger.debug('Adding remote video %s.', this.videoObject.id, this.lTags())
20 22
21 const channelActor = await this.getOrCreateVideoChannelFromVideoObject() 23 const channelActor = await this.getOrCreateVideoChannelFromVideoObject()
22 const channel = channelActor.VideoChannel 24 const channel = channelActor.VideoChannel
@@ -57,7 +59,7 @@ export class APVideoCreator extends APVideoAbstractBuilder {
57 transaction: t 59 transaction: t
58 }) 60 })
59 61
60 logger.info('Remote video with uuid %s inserted.', this.videoObject.uuid, this.lTags(videoCreated.uuid)) 62 logger.info('Remote video with uuid %s inserted.', this.videoObject.uuid, this.lTags())
61 63
62 return { autoBlacklisted, videoCreated } 64 return { autoBlacklisted, videoCreated }
63 } catch (err) { 65 } catch (err) {
diff --git a/server/lib/activitypub/videos/shared/video-sync-attributes.ts b/server/lib/activitypub/videos/shared/video-sync-attributes.ts
index 102d40621..c4e101005 100644
--- a/server/lib/activitypub/videos/shared/video-sync-attributes.ts
+++ b/server/lib/activitypub/videos/shared/video-sync-attributes.ts
@@ -62,7 +62,7 @@ function syncRates (type: 'like' | 'dislike', video: MVideo, fetchedVideo: Video
62 const cleaner = crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, type, crawlStartDate) 62 const cleaner = crawlStartDate => AccountVideoRateModel.cleanOldRatesOf(video.id, type, crawlStartDate)
63 63
64 return crawlCollectionPage<string>(uri, handler, cleaner) 64 return crawlCollectionPage<string>(uri, handler, cleaner)
65 .catch(err => logger.error('Cannot add rate of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) })) 65 .catch(err => logger.error('Cannot add rate of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
66} 66}
67 67
68function syncShares (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) { 68function syncShares (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) {
@@ -76,7 +76,7 @@ function syncShares (video: MVideo, fetchedVideo: VideoObject, isSync: boolean)
76 const cleaner = crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate) 76 const cleaner = crawlStartDate => VideoShareModel.cleanOldSharesOf(video.id, crawlStartDate)
77 77
78 return crawlCollectionPage<string>(uri, handler, cleaner) 78 return crawlCollectionPage<string>(uri, handler, cleaner)
79 .catch(err => logger.error('Cannot add shares of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) })) 79 .catch(err => logger.error('Cannot add shares of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
80} 80}
81 81
82function syncComments (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) { 82function syncComments (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) {
@@ -90,5 +90,5 @@ function syncComments (video: MVideo, fetchedVideo: VideoObject, isSync: boolean
90 const cleaner = crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate) 90 const cleaner = crawlStartDate => VideoCommentModel.cleanOldCommentsOf(video.id, crawlStartDate)
91 91
92 return crawlCollectionPage<string>(uri, handler, cleaner) 92 return crawlCollectionPage<string>(uri, handler, cleaner)
93 .catch(err => logger.error('Cannot add comments of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid) })) 93 .catch(err => logger.error('Cannot add comments of video %s.', video.uuid, { err, rootUrl: uri, ...lTags(video.uuid, video.url) }))
94} 94}
diff --git a/server/lib/activitypub/videos/updater.ts b/server/lib/activitypub/videos/updater.ts
index 6745e2efd..3339611fc 100644
--- a/server/lib/activitypub/videos/updater.ts
+++ b/server/lib/activitypub/videos/updater.ts
@@ -1,6 +1,6 @@
1import { Transaction } from 'sequelize/types' 1import { Transaction } from 'sequelize/types'
2import { resetSequelizeInstance } from '@server/helpers/database-utils' 2import { resetSequelizeInstance } from '@server/helpers/database-utils'
3import { logger, loggerTagsFactory } from '@server/helpers/logger' 3import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger'
4import { sequelizeTypescript } from '@server/initializers/database' 4import { sequelizeTypescript } from '@server/initializers/database'
5import { Notifier } from '@server/lib/notifier' 5import { Notifier } from '@server/lib/notifier'
6import { PeerTubeSocket } from '@server/lib/peertube-socket' 6import { PeerTubeSocket } from '@server/lib/peertube-socket'
@@ -19,7 +19,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
19 19
20 private readonly oldVideoChannel: MChannelAccountLight 20 private readonly oldVideoChannel: MChannelAccountLight
21 21
22 protected lTags = loggerTagsFactory('ap', 'video', 'update') 22 protected lTags: LoggerTagsFn
23 23
24 constructor ( 24 constructor (
25 protected readonly videoObject: VideoObject, 25 protected readonly videoObject: VideoObject,
@@ -33,12 +33,14 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
33 this.oldVideoChannel = this.video.VideoChannel 33 this.oldVideoChannel = this.video.VideoChannel
34 34
35 this.videoFieldsSave = this.video.toJSON() 35 this.videoFieldsSave = this.video.toJSON()
36
37 this.lTags = loggerTagsFactory('ap', 'video', 'update', video.uuid, video.url)
36 } 38 }
37 39
38 async update (overrideTo?: string[]) { 40 async update (overrideTo?: string[]) {
39 logger.debug( 41 logger.debug(
40 'Updating remote video "%s".', this.videoObject.uuid, 42 'Updating remote video "%s".', this.videoObject.uuid,
41 { videoObject: this.videoObject, ...this.lTags(this.videoObject.uuid) } 43 { videoObject: this.videoObject, ...this.lTags() }
42 ) 44 )
43 45
44 try { 46 try {
@@ -82,7 +84,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
82 PeerTubeSocket.Instance.sendVideoViewsUpdate(videoUpdated) 84 PeerTubeSocket.Instance.sendVideoViewsUpdate(videoUpdated)
83 } 85 }
84 86
85 logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags(this.videoObject.uuid)) 87 logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags())
86 88
87 return videoUpdated 89 return videoUpdated
88 } catch (err) { 90 } catch (err) {
@@ -158,7 +160,7 @@ export class APVideoUpdater extends APVideoAbstractBuilder {
158 } 160 }
159 161
160 // This is just a debug because we will retry the insert 162 // This is just a debug because we will retry the insert
161 logger.debug('Cannot update the remote video.', { err, ...this.lTags(this.videoObject.uuid) }) 163 logger.debug('Cannot update the remote video.', { err, ...this.lTags() })
162 throw err 164 throw err
163 } 165 }
164} 166}