ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix issues with truncated description and utf characters
Chocobozzzbffbebbe6b33
diff --git a/server/helpers/database-utils.ts b/server/helpers/database-utils.tsindex 31808f9e4b..d09b4b245b 100644--- a/server/helpers/database-utils.ts+++ b/server/helpers/database-utils.ts@@ -16,7 +16,6 @@ function retryTransactionWrapper <T> (.catch(err => callback(err))}).catch(err => {- console.error(err)logger.error(options.errorMessage, err)throw err})diff --git a/server/lib/activitypub/process/process.ts b/server/lib/activitypub/process/process.tsindex 7edf3bba00..094219489f 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?: Actortry {await activityProcessor(activity, inboxActor)} catch (err) {- logger.warn(err.stack)- logger.warn('Cannot process activity %s.', activity.type, err)+ logger.warn('Cannot process activity %s.', activity.type, { error: err.stack })}}}diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.tsindex e7b516129a..907fe458d5 100644--- a/server/lib/activitypub/videos.ts+++ b/server/lib/activitypub/videos.ts@@ -187,7 +187,7 @@ async function getOrCreateAccountAndVideoAndChannel (videoObject: VideoTorrentOb}videoObject = await fetchRemoteVideo(videoObject)- if (!videoObject) throw new Error('Cannot fetch remote video')+ if (!videoObject) throw new Error('Cannot fetch remote video (maybe invalid...)')}if (!actor) {diff --git a/server/models/video/video.ts b/server/models/video/video.tsindex 4e175c410e..f43b73e49c 100644--- a/server/models/video/video.ts+++ b/server/models/video/video.ts@@ -1166,10 +1166,19 @@ export class VideoModel extends Model<VideoModel> {getTruncatedDescription () {if (!this.description) return null+ const maxLength = CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max+const options = {- length: CONSTRAINTS_FIELDS.VIDEOS.TRUNCATED_DESCRIPTION.max+ length: maxLength}+ const truncatedDescription = truncate(this.description, options)++ // The truncated string is okay, we can return it+ if (truncatedDescription.length <= maxLength) return truncatedDescription+ // Lodash takes into account all UTF characters, whereas String.prototype.length does not: some characters have a length of 2+ // We always use the .length so we need to truncate more if needed+ options.length -= maxLength - truncatedDescription.lengthreturn truncate(this.description, options)}