return excludedKeys[key] === true ? undefined : value
}
-const loggerFormat = winston.format.printf(info => {
+const consoleLoggerFormat = winston.format.printf(info => {
let additionalInfos = JSON.stringify(info, keysExcluder, 2)
if (additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
})
+const jsonLoggerFormat = winston.format.printf(info => {
+ if (info.message && info.message.stack !== undefined) info.message = info.message.stack
+
+ return JSON.stringify(info)
+})
+
const timestampFormatter = winston.format.timestamp({
format: 'YYYY-MM-dd HH:mm:ss.SSS'
})
timestampFormatter,
labelFormatter,
winston.format.splat(),
- winston.format.json()
+ jsonLoggerFormat
)
}),
new winston.transports.Console({
- handleExceptions: true,
+ handleExcegiptions: true,
humanReadableUnhandledException: true,
format: winston.format.combine(
timestampFormatter,
winston.format.splat(),
labelFormatter,
winston.format.colorize(),
- loggerFormat
+ consoleLoggerFormat
)
})
],
export {
timestampFormatter,
labelFormatter,
- loggerFormat,
+ consoleLoggerFormat,
logger
}
throw new Error('Account ' + actor.url + ' does not own video channel ' + videoChannel.Actor.url)
}
- const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc)
+ const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to)
videoInstance.set('name', videoData.name)
videoInstance.set('uuid', videoData.uuid)
videoInstance.set('url', videoData.url)
to = [ ACTIVITY_PUB.PUBLIC ]
cc = followerInboxUrls
} else { // Unlisted
- to = followerInboxUrls
- cc = [ ACTIVITY_PUB.PUBLIC ]
+ to = [ ]
+ cc = [ ]
}
return { to, cc }
async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel,
videoObject: VideoTorrentObject,
- to: string[] = [],
- cc: string[] = []) {
- let privacy = VideoPrivacy.PRIVATE
- if (to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.PUBLIC
- else if (cc.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.UNLISTED
+ to: string[] = []) {
+ const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
const duration = videoObject.duration.replace(/[^\d]+/, '')
let language = null
licence = parseInt(videoObject.licence.identifier, 10)
}
- let description = null
- if (videoObject.content) {
- description = videoObject.content
- }
-
- let support = null
- if (videoObject.support) {
- support = videoObject.support
- }
+ const description = videoObject.content || null
+ const support = videoObject.support || null
return {
name: videoObject.name,
const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t)
if (videoFromDatabase) return videoFromDatabase
- const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to, videoObject.cc)
+ const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to)
const video = VideoModel.build(videoData)
// Don't block on request