- [ ScopeNames.SUMMARY ]: (whereActor?: WhereOptions) => {
- return {
- attributes: [ 'id', 'name' ],
- include: [
+ [ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
+ const whereActor = options.whereActor || undefined
+
+ const serverInclude: IncludeOptions = {
+ attributes: [ 'host' ],
+ model: ServerModel.unscoped(),
+ required: false
+ }
+
+ const queryInclude: Includeable[] = [
+ {
+ attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
+ model: ActorModel.unscoped(),
+ required: options.actorRequired ?? true,
+ where: whereActor,
+ include: [
+ serverInclude,
+
+ {
+ model: ActorImageModel.unscoped(),
+ as: 'Avatar',
+ required: false
+ }
+ ]
+ }
+ ]
+
+ const query: FindOptions = {
+ attributes: [ 'id', 'name', 'actorId' ]
+ }
+
+ if (options.withAccountBlockerIds) {
+ queryInclude.push({
+ attributes: [ 'id' ],
+ model: AccountBlocklistModel.unscoped(),
+ as: 'BlockedAccounts',
+ required: false,
+ where: {
+ accountId: {
+ [Op.in]: options.withAccountBlockerIds
+ }
+ }
+ })
+
+ serverInclude.include = [