import { VideoAbuseModel } from '../../../models/video/video-abuse'
import { addVideoComment, resolveThread } from '../video-comments'
import { getOrCreateVideoAndAccountAndChannel } from '../videos'
-import { forwardActivity, forwardVideoRelatedActivity } from '../send/utils'
+import { forwardVideoRelatedActivity } from '../send/utils'
import { Redis } from '../../redis'
-import { createCacheFile } from '../cache-file'
+import { createOrUpdateCacheFile } from '../cache-file'
+import { getVideoDislikeActivityPubUrl } from '../url'
async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) {
const activityObject = activity.object
videoId: video.id,
accountId: byAccount.id
}
+
const [ , created ] = await AccountVideoRateModel.findOrCreate({
where: rate,
- defaults: rate,
+ defaults: Object.assign({}, rate, { url: getVideoDislikeActivityPubUrl(byActor, video) }),
transaction: t
})
if (created === true) await video.increment('dislikes', { transaction: t })
}
const { video } = await getOrCreateVideoAndAccountAndChannel(options)
- const actorExists = await ActorModel.isActorUrlExist(view.actor)
- if (actorExists === false) throw new Error('Unknown actor ' + view.actor)
-
await Redis.Instance.addVideoView(video.id)
if (video.isOwned()) {
// Don't resend the activity to the sender
const exceptions = [ byActor ]
- await forwardActivity(activity, undefined, exceptions)
+ await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
}
}
const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: cacheFile.object })
- await createCacheFile(cacheFile, video, byActor)
+ await sequelizeTypescript.transaction(async t => {
+ return createOrUpdateCacheFile(cacheFile, video, byActor, t)
+ })
if (video.isOwned()) {
// Don't resend the activity to the sender
const exceptions = [ byActor ]
- await forwardActivity(activity, undefined, exceptions)
+ await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
}
}