+ accountId: {
+ [Op.in]: accountIds
+ }
+ },
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: AccountModel.unscoped(),
+ required: true,
+ as: 'BlockedAccount',
+ include: [
+ {
+ attributes: [ 'preferredUsername' ],
+ model: ActorModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'host' ],
+ model: ServerModel.unscoped(),
+ required: true
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+
+ return AccountBlocklistModel.findAll(query)
+ .then(entries => entries.map(e => `${e.BlockedAccount.Actor.preferredUsername}@${e.BlockedAccount.Actor.Server.host}`))
+ }
+
+ static getBlockStatus (byAccountIds: number[], handles: string[]): Promise<{ name: string, host: string, accountId: number }[]> {
+ const sanitizedHandles = handlesToNameAndHost(handles)
+
+ const localHandles = sanitizedHandles.filter(h => !h.host)
+ .map(h => h.name)
+
+ const remoteHandles = sanitizedHandles.filter(h => !!h.host)
+ .map(h => ([ h.name, h.host ]))
+
+ const handlesWhere: string[] = []
+
+ if (localHandles.length !== 0) {
+ handlesWhere.push(`("actor"."preferredUsername" IN (:localHandles) AND "server"."id" IS NULL)`)
+ }
+
+ if (remoteHandles.length !== 0) {
+ handlesWhere.push(`(("actor"."preferredUsername", "server"."host") IN (:remoteHandles))`)