Unlisted videos are not displayed on Mastodon now

pull/311/head
Chocobozzz 2018-02-21 10:07:02 +01:00
parent 3bf1ec2ebb
commit 276d03ed1a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
4 changed files with 19 additions and 23 deletions

View File

@ -21,7 +21,7 @@ function keysExcluder (key, value) {
return excludedKeys[key] === true ? undefined : value 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) let additionalInfos = JSON.stringify(info, keysExcluder, 2)
if (additionalInfos === '{}') additionalInfos = '' if (additionalInfos === '{}') additionalInfos = ''
else additionalInfos = ' ' + additionalInfos else additionalInfos = ' ' + additionalInfos
@ -30,6 +30,12 @@ const loggerFormat = winston.format.printf(info => {
return `[${info.label}] ${info.timestamp} ${info.level}: ${info.message}${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({ const timestampFormatter = winston.format.timestamp({
format: 'YYYY-MM-dd HH:mm:ss.SSS' format: 'YYYY-MM-dd HH:mm:ss.SSS'
}) })
@ -49,18 +55,18 @@ const logger = new winston.createLogger({
timestampFormatter, timestampFormatter,
labelFormatter, labelFormatter,
winston.format.splat(), winston.format.splat(),
winston.format.json() jsonLoggerFormat
) )
}), }),
new winston.transports.Console({ new winston.transports.Console({
handleExceptions: true, handleExcegiptions: true,
humanReadableUnhandledException: true, humanReadableUnhandledException: true,
format: winston.format.combine( format: winston.format.combine(
timestampFormatter, timestampFormatter,
winston.format.splat(), winston.format.splat(),
labelFormatter, labelFormatter,
winston.format.colorize(), winston.format.colorize(),
loggerFormat consoleLoggerFormat
) )
}) })
], ],
@ -72,6 +78,6 @@ const logger = new winston.createLogger({
export { export {
timestampFormatter, timestampFormatter,
labelFormatter, labelFormatter,
loggerFormat, consoleLoggerFormat,
logger logger
} }

View File

@ -71,7 +71,7 @@ async function updateRemoteVideo (actor: ActorModel, activity: ActivityUpdate) {
throw new Error('Account ' + actor.url + ' does not own video channel ' + videoChannel.Actor.url) 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('name', videoData.name)
videoInstance.set('uuid', videoData.uuid) videoInstance.set('uuid', videoData.uuid)
videoInstance.set('url', videoData.url) videoInstance.set('url', videoData.url)

View File

@ -153,8 +153,8 @@ function buildAudience (followerInboxUrls: string[], isPublic = true) {
to = [ ACTIVITY_PUB.PUBLIC ] to = [ ACTIVITY_PUB.PUBLIC ]
cc = followerInboxUrls cc = followerInboxUrls
} else { // Unlisted } else { // Unlisted
to = followerInboxUrls to = [ ]
cc = [ ACTIVITY_PUB.PUBLIC ] cc = [ ]
} }
return { to, cc } return { to, cc }

View File

@ -56,11 +56,8 @@ function generateThumbnailFromUrl (video: VideoModel, icon: ActivityIconObject)
async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel, async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelModel,
videoObject: VideoTorrentObject, videoObject: VideoTorrentObject,
to: string[] = [], to: string[] = []) {
cc: string[] = []) { const privacy = to.indexOf(ACTIVITY_PUB.PUBLIC) !== -1 ? VideoPrivacy.PUBLIC : VideoPrivacy.UNLISTED
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
const duration = videoObject.duration.replace(/[^\d]+/, '') const duration = videoObject.duration.replace(/[^\d]+/, '')
let language = null let language = null
@ -78,15 +75,8 @@ async function videoActivityObjectToDBAttributes (videoChannel: VideoChannelMode
licence = parseInt(videoObject.licence.identifier, 10) licence = parseInt(videoObject.licence.identifier, 10)
} }
let description = null const description = videoObject.content || null
if (videoObject.content) { const support = videoObject.support || null
description = videoObject.content
}
let support = null
if (videoObject.support) {
support = videoObject.support
}
return { return {
name: videoObject.name, name: videoObject.name,
@ -157,7 +147,7 @@ async function getOrCreateVideo (videoObject: VideoTorrentObject, channelActor:
const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t) const videoFromDatabase = await VideoModel.loadByUUIDOrURLAndPopulateAccount(videoObject.uuid, videoObject.id, t)
if (videoFromDatabase) return videoFromDatabase 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) const video = VideoModel.build(videoData)
// Don't block on request // Don't block on request