try {
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 })
}
}
}
}
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) {
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.length
return truncate(this.description, options)
}