aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/helpers/database-utils.ts1
-rw-r--r--server/lib/activitypub/process/process.ts3
-rw-r--r--server/lib/activitypub/videos.ts2
-rw-r--r--server/models/video/video.ts11
4 files changed, 12 insertions, 5 deletions
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.ts
index 31808f9e4..d09b4b245 100644
--- a/server/helpers/database-utils.ts
+++ b/server/helpers/database-utils.ts
@@ -16,7 +16,6 @@ function retryTransactionWrapper <T> (
16 .catch(err => callback(err)) 16 .catch(err => callback(err))
17 }) 17 })
18 .catch(err => { 18 .catch(err => {
19 console.error(err)
20 logger.error(options.errorMessage, err) 19 logger.error(options.errorMessage, err)
21 throw err 20 throw err
22 }) 21 })
diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.ts
index 7edf3bba0..094219489 100644
--- a/server/lib/activitypub/process/process.ts
+++ b/server/lib/activitypub/process/process.ts
@@ -40,8 +40,7 @@ async function processActivities (activities: Activity[], signatureActor?: Actor
40 try { 40 try {
41 await activityProcessor(activity, inboxActor) 41 await activityProcessor(activity, inboxActor)
42 } catch (err) { 42 } catch (err) {
43 logger.warn(err.stack) 43 logger.warn('Cannot process activity %s.', activity.type, { error: err.stack })
44 logger.warn('Cannot process activity %s.', activity.type, err)
45 } 44 }
46 } 45 }
47} 46}
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index e7b516129..907fe458d 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -187,7 +187,7 @@ async function getOrCreateAccountAndVideoAndChannel (videoObject: VideoTorrentOb
187 } 187 }
188 188
189 videoObject = await fetchRemoteVideo(videoObject) 189 videoObject = await fetchRemoteVideo(videoObject)
190 if (!videoObject) throw new Error('Cannot fetch remote video') 190 if (!videoObject) throw new Error('Cannot fetch remote video (maybe invalid...)')
191 } 191 }
192 192
193 if (!actor) { 193 if (!actor) {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 4e175c410..f43b73e49 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -1166,10 +1166,19 @@ export class VideoModel extends Model<VideoModel> {
1166 getTruncatedDescription () { 1166 getTruncatedDescription () {
1167 if (!this.description) return null 1167 if (!this.description) return null
1168 1168
1169 const maxLength = CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max
1170
1169 const options = { 1171 const options = {
1170 length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max 1172 length: maxLength
1171 } 1173 }
1174 const truncatedDescription = truncate(this.description, options)
1175
1176 // The truncated string is okay, we can return it
1177 if (truncatedDescription.length <= maxLength) return truncatedDescription
1172 1178
1179 // Lodash takes into account all UTF characters, whereas String.prototype.length does not: some characters have a length of 2
1180 // We always use the .length so we need to truncate more if needed
1181 options.length -= maxLength - truncatedDescription.length
1173 return truncate(this.description, options) 1182 return truncate(this.description, options)
1174 } 1183 }
1175 1184