- static listFollowingForApi (id: number, start: number, count: number, sort: string) {
+ static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]) {
+ const whereTab = targets
+ .map(t => {
+ if (t.host) {
+ return {
+ [ Sequelize.Op.and ]: [
+ {
+ '$preferredUsername$': t.name
+ },
+ {
+ '$host$': t.host
+ }
+ ]
+ }
+ }
+
+ return {
+ [ Sequelize.Op.and ]: [
+ {
+ '$preferredUsername$': t.name
+ },
+ {
+ '$serverId$': null
+ }
+ ]
+ }
+ })
+
+ const query = {
+ attributes: [],
+ where: {
+ [ Sequelize.Op.and ]: [
+ {
+ [ Sequelize.Op.or ]: whereTab
+ },
+ {
+ actorId
+ }
+ ]
+ },
+ include: [
+ {
+ attributes: [ 'preferredUsername' ],
+ model: ActorModel.unscoped(),
+ required: true,
+ as: 'ActorFollowing',
+ include: [
+ {
+ attributes: [ 'host' ],
+ model: ServerModel.unscoped(),
+ required: false
+ }
+ ]
+ }
+ ]
+ }
+
+ return ActorFollowModel.findAll(query)
+ }
+
+ static listFollowingForApi (id: number, start: number, count: number, sort: string, search?: string) {