aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/helpers/logger.ts16
-rw-r--r--server/lib/activitypub/process/process-update.ts2
-rw-r--r--server/lib/activitypub/send/misc.ts4
-rw-r--r--server/lib/activitypub/videos.ts20
4 files changed, 19 insertions, 23 deletions
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index bcd4885af..7d1d72f29 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -21,7 +21,7 @@ function keysExcluder (key, value) {
21 return excludedKeys[key] === true ? undefined : value 21 return excludedKeys[key] === true ? undefined : value
22} 22}
23 23
24const loggerFormat = winston.format.printf(info => { 24const consoleLoggerFormat = winston.format.printf(info => {
25 let additionalInfos = JSON.stringify(info, keysExcluder, 2) 25 let additionalInfos = JSON.stringify(info, keysExcluder, 2)
26 if (additionalInfos === '{}') additionalInfos = '' 26 if (additionalInfos === '{}') additionalInfos = ''
27 else additionalInfos = ' ' + additionalInfos 27 else additionalInfos = ' ' + additionalInfos
@@ -30,6 +30,12 @@ const loggerFormat = winston.format.printf(info => {
30 return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}` 30 return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${additionalInfos}`
31}) 31})
32 32
33const jsonLoggerFormat = winston.format.printf(info => {
34 if (info.message && info.message.stack !== undefined) info.message = info.message.stack
35
36 return JSON.stringify(info)
37})
38
33const timestampFormatter = winston.format.timestamp({ 39const timestampFormatter = winston.format.timestamp({
34 format: 'YYYY-MM-dd HH:mm:ss.SSS' 40 format: 'YYYY-MM-dd HH:mm:ss.SSS'
35}) 41})
@@ -49,18 +55,18 @@ const logger = new winston.createLogger({
49 timestampFormatter, 55 timestampFormatter,
50 labelFormatter, 56 labelFormatter,
51 winston.format.splat(), 57 winston.format.splat(),
52 winston.format.json() 58 jsonLoggerFormat
53 ) 59 )
54 }), 60 }),
55 new winston.transports.Console({ 61 new winston.transports.Console({
56 handleExceptions: true, 62 handleExcegiptions: true,
57 humanReadableUnhandledException: true, 63 humanReadableUnhandledException: true,
58 format: winston.format.combine( 64 format: winston.format.combine(
59 timestampFormatter, 65 timestampFormatter,
60 winston.format.splat(), 66 winston.format.splat(),
61 labelFormatter, 67 labelFormatter,
62 winston.format.colorize(), 68 winston.format.colorize(),
63 loggerFormat 69 consoleLoggerFormat
64 ) 70 )
65 }) 71 })
66 ], 72 ],
@@ -72,6 +78,6 @@ const logger = new winston.createLogger({
72export { 78export {
73 timestampFormatter, 79 timestampFormatter,
74 labelFormatter, 80 labelFormatter,
75 loggerFormat, 81 consoleLoggerFormat,
76 logger 82 logger
77} 83}
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts
index 566e5938b..24e5589d4 100644
--- a/server/lib/activitypub/process/process-update.ts
+++ b/server/lib/activitypub/process/process-update.ts
@@ -71,7 +71,7 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
71 throw new Error('Account ' + actor.url + ' does not own video channel ' + videoChannel.Actor.url) 71 throw new Error('Account ' + actor.url + ' does not own video channel ' + videoChannel.Actor.url)
72 } 72 }
73 73
74 const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to, activity.cc) 74 const videoData = await videoActivityObjectToDBAttributes(videoChannel, videoAttributesToUpdate, activity.to)
75 videoInstance.set('name', videoData.name) 75 videoInstance.set('name', videoData.name)
76 videoInstance.set('uuid', videoData.uuid) 76 videoInstance.set('uuid', videoData.uuid)
77 videoInstance.set('url', videoData.url) 77 videoInstance.set('url', videoData.url)
diff --git a/server/lib/activitypub/send/misc.ts b/server/lib/activitypub/send/misc.ts
index 7a21f0c94..607822d16 100644
--- a/server/lib/activitypub/send/misc.ts
+++ b/server/lib/activitypub/send/misc.ts
@@ -153,8 +153,8 @@ function buildAudience (followerInboxUrls: string[], isPublic = true) {
153 to = [ ACTIVITY_PUB.PUBLIC ] 153 to = [ ACTIVITY_PUB.PUBLIC ]
154 cc = followerInboxUrls 154 cc = followerInboxUrls
155 } else { // Unlisted 155 } else { // Unlisted
156 to = followerInboxUrls 156 to = [ ]
157 cc = [ ACTIVITY_PUB.PUBLIC ] 157 cc = [ ]
158 } 158 }
159 159
160 return { to, cc } 160 return { to, cc }
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts
index e65362190..e7b516129 100644
--- a/server/lib/activitypub/videos.ts
+++ b/server/lib/activitypub/videos.ts
@@ -56,11 +56,8 @@ function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject)
56 56
57async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel, 57async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel,
58 videoObject: VideoTorrentObject, 58 videoObject: VideoTorrentObject,
59 to: string[] = [], 59 to: string[] = []) {
60 cc: string[] = []) { 60 const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
61 let privacy = VideoPrivacy.PRIVATE
62 if (to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.PUBLIC
63 else if (cc.indexOf(ACTIVITY_PUB.PUBLIC) !== -1) privacy = VideoPrivacy.UNLISTED
64 61
65 const duration = videoObject.duration.replace(/[^\d]+/, '') 62 const duration = videoObject.duration.replace(/[^\d]+/, '')
66 let language = null 63 let language = null
@@ -78,15 +75,8 @@ async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelMode
78 licence = parseInt(videoObject.licence.identifier, 10) 75 licence = parseInt(videoObject.licence.identifier, 10)
79 } 76 }
80 77
81 let description = null 78 const description = videoObject.content || null
82 if (videoObject.content) { 79 const support = videoObject.support || null
83 description = videoObject.content
84 }
85
86 let support = null
87 if (videoObject.support) {
88 support = videoObject.support
89 }
90 80
91 return { 81 return {
92 name: videoObject.name, 82 name: videoObject.name,
@@ -157,7 +147,7 @@ async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor:
157 const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t) 147 const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t)
158 if (videoFromDatabase) return videoFromDatabase 148 if (videoFromDatabase) return videoFromDatabase
159 149
160 const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to, videoObject.cc) 150 const videoData = await videoActivityObjectToDBAttributes(channelActor.VideoChannel, videoObject, videoObject.to)
161 const video = VideoModel.build(videoData) 151 const video = VideoModel.build(videoData)
162 152
163 // Don't block on request 153 // Don't block on request