mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
Add banners support
This commit is contained in:
parent
f479685678
commit
2cb03dc1f4
33 changed files with 392 additions and 240 deletions
|
@ -6,7 +6,7 @@ import { sequelizeTypescript } from '../../../initializers/database'
|
|||
import { AccountModel } from '../../../models/account/account'
|
||||
import { ActorModel } from '../../../models/activitypub/actor'
|
||||
import { VideoChannelModel } from '../../../models/video/video-channel'
|
||||
import { getAvatarInfoIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor'
|
||||
import { getImageInfoIfExists, updateActorImageInstance, updateActorInstance } from '../actor'
|
||||
import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos'
|
||||
import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
|
||||
import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file'
|
||||
|
@ -17,6 +17,7 @@ import { createOrUpdateVideoPlaylist } from '../playlist'
|
|||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
import { MActorSignature, MAccountIdActor } from '../../../types/models'
|
||||
import { isRedundancyAccepted } from '@server/lib/redundancy'
|
||||
import { ActorImageType } from '@shared/models'
|
||||
|
||||
async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) {
|
||||
const { activity, byActor } = options
|
||||
|
@ -119,7 +120,8 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
|
|||
let accountOrChannelFieldsSave: object
|
||||
|
||||
// Fetch icon?
|
||||
const avatarInfo = await getAvatarInfoIfExists(actorAttributesToUpdate)
|
||||
const avatarInfo = getImageInfoIfExists(actorAttributesToUpdate, ActorImageType.AVATAR)
|
||||
const bannerInfo = getImageInfoIfExists(actorAttributesToUpdate, ActorImageType.BANNER)
|
||||
|
||||
try {
|
||||
await sequelizeTypescript.transaction(async t => {
|
||||
|
@ -132,10 +134,12 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
|
|||
|
||||
await updateActorInstance(actor, actorAttributesToUpdate)
|
||||
|
||||
if (avatarInfo !== undefined) {
|
||||
const avatarOptions = Object.assign({}, avatarInfo, { onDisk: false })
|
||||
for (const imageInfo of [ avatarInfo, bannerInfo ]) {
|
||||
if (!imageInfo) continue
|
||||
|
||||
await updateActorAvatarInstance(actor, avatarOptions, t)
|
||||
const imageOptions = Object.assign({}, imageInfo, { onDisk: false })
|
||||
|
||||
await updateActorImageInstance(actor, imageOptions, t)
|
||||
}
|
||||
|
||||
await actor.save({ transaction: t })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue