isVideoChannelSupportValid
} from '../../helpers/custom-validators/video-channels'
import { sendDeleteActor } from '../../lib/activitypub/send'
-import { AccountModel, ScopeNames as AccountModelScopeNames } from '../account/account'
+import { AccountModel, ScopeNames as AccountModelScopeNames, SummaryOptions as AccountSummaryOptions } from '../account/account'
import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
import { buildServerIdsFollowedBy, buildTrigramSearchIndex, createSimilarityAttribute, getSort, throwIfNotValid } from '../utils'
import { VideoModel } from './video'
actorId: number
}
+export type SummaryOptions = {
+ withAccount?: boolean // Default: false
+ withAccountBlockerIds?: number[]
+}
+
@DefaultScope(() => ({
include: [
{
]
}))
@Scopes(() => ({
- [ScopeNames.SUMMARY]: (withAccount = false) => {
+ [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
const base: FindOptions = {
attributes: [ 'name', 'description', 'id', 'actorId' ],
include: [
{
- attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
+ attributes: [ 'preferredUsername', 'url', 'serverId', 'avatarId' ],
model: ActorModel.unscoped(),
required: true,
include: [
]
}
- if (withAccount === true) {
+ if (options.withAccount === true) {
base.include.push({
- model: AccountModel.scope(AccountModelScopeNames.SUMMARY),
+ model: AccountModel.scope({
+ method: [ AccountModelScopeNames.SUMMARY, { withAccountBlockerIds: options.withAccountBlockerIds } as AccountSummaryOptions ]
+ }),
required: true
})
}
.findByPk(id)
}
- static loadByUUIDAndPopulateAccount (uuid: string) {
- const query = {
- include: [
- {
- model: ActorModel,
- required: true,
- where: {
- uuid
- }
- }
- ]
- }
-
- return VideoChannelModel
- .scope([ ScopeNames.WITH_ACCOUNT ])
- .findOne(query)
- }
-
static loadByUrlAndPopulateAccount (url: string) {
const query = {
include: [
return {
id: this.id,
- uuid: actor.uuid,
name: actor.name,
displayName: this.getDisplayName(),
url: actor.url,