+}))
+@Scopes(() => ({
+ [ScopeNames.SUMMARY]: (withAccount = false) => {
+ const base: FindOptions = {
+ attributes: [ 'name', 'description', 'id', 'actorId' ],
+ include: [
+ {
+ attributes: [ 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
+ model: ActorModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'host' ],
+ model: ServerModel.unscoped(),
+ required: false
+ },
+ {
+ model: AvatarModel.unscoped(),
+ required: false
+ }
+ ]
+ }
+ ]
+ }
+
+ if (withAccount === true) {
+ base.include.push({
+ model: AccountModel.scope(AccountModelScopeNames.SUMMARY),
+ required: true
+ })
+ }
+
+ return base
+ },
+ [ScopeNames.AVAILABLE_FOR_LIST]: (options: AvailableForListOptions) => {
+ // Only list local channels OR channels that are on an instance followed by actorId
+ const inQueryInstanceFollow = buildServerIdsFollowedBy(options.actorId)
+
+ return {
+ include: [
+ {
+ attributes: {
+ exclude: unusedActorAttributesForAPI
+ },
+ model: ActorModel,
+ where: {
+ [Op.or]: [
+ {
+ serverId: null
+ },
+ {
+ serverId: {
+ [ Op.in ]: Sequelize.literal(inQueryInstanceFollow)
+ }
+ }
+ ]
+ }
+ },
+ {
+ model: AccountModel,
+ required: true,
+ include: [
+ {
+ attributes: {
+ exclude: unusedActorAttributesForAPI
+ },
+ model: ActorModel, // Default scope includes avatar and server
+ required: true
+ }
+ ]
+ }
+ ]
+ }
+ },