isVideoChannelNameValid,
isVideoChannelSupportValid
} from '../../helpers/custom-validators/video-channels'
+import { sendDeleteActor } from '../../lib/activitypub/send'
import { AccountModel } from '../account/account'
import { ActorModel } from '../activitypub/actor'
import { getSort, throwIfNotValid } from '../utils'
instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
}
- return instance.Actor.destroy({ transaction: options.transaction })
+ if (instance.Actor.isOwned()) {
+ return sendDeleteActor(instance.Actor, options.transaction)
+ }
+
+ return undefined
}
static countByAccount (accountId: number) {
.findById(id, options)
}
+ static loadLocalByName (name: string) {
+ const query = {
+ include: [
+ {
+ model: ActorModel,
+ required: true,
+ where: {
+ preferredUsername: name,
+ serverId: null
+ }
+ }
+ ]
+ }
+
+ return VideoChannelModel.findOne(query)
+ }
+
toFormattedJSON (): VideoChannel {
const actor = this.Actor.toFormattedJSON()
const videoChannel = {
isLocal: this.Actor.isOwned(),
createdAt: this.createdAt,
updatedAt: this.updatedAt,
- ownerAccount: undefined,
- videos: undefined
+ ownerAccount: undefined
}
if (this.Account) videoChannel.ownerAccount = this.Account.toFormattedJSON()