From 63c93323ecdeaa4b6183d75dd3f13469e1ef3ebd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Nov 2017 13:41:10 +0100 Subject: Correctly forward like/dislikes and undo --- server/models/account/account-interface.ts | 2 ++ server/models/account/account.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'server/models/account') diff --git a/server/models/account/account-interface.ts b/server/models/account/account-interface.ts index 2e4b0382d..6fc98ba45 100644 --- a/server/models/account/account-interface.ts +++ b/server/models/account/account-interface.ts @@ -12,6 +12,7 @@ export namespace AccountMethods { export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird export type LoadLocalByName = (name: string) => Bluebird export type LoadByNameAndHost = (name: string, host: string) => Bluebird + export type ListByFollowersUrls = (followerUrls: string[], transaction?: Sequelize.Transaction) => Bluebird export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount @@ -29,6 +30,7 @@ export interface AccountClass { loadByUrl: AccountMethods.LoadByUrl loadLocalByName: AccountMethods.LoadLocalByName loadByNameAndHost: AccountMethods.LoadByNameAndHost + listByFollowersUrls: AccountMethods.ListByFollowersUrls } export interface AccountAttributes { diff --git a/server/models/account/account.ts b/server/models/account/account.ts index f2bd325f3..fff3ce087 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -26,6 +26,7 @@ let loadByUUID: AccountMethods.LoadByUUID let loadByUrl: AccountMethods.LoadByUrl let loadLocalByName: AccountMethods.LoadLocalByName let loadByNameAndHost: AccountMethods.LoadByNameAndHost +let listByFollowersUrls: AccountMethods.ListByFollowersUrls let isOwned: AccountMethods.IsOwned let toActivityPubObject: AccountMethods.ToActivityPubObject let toFormattedJSON: AccountMethods.ToFormattedJSON @@ -188,7 +189,8 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes loadByUUID, loadByUrl, loadLocalByName, - loadByNameAndHost + loadByNameAndHost, + listByFollowersUrls ] const instanceMethods = [ isOwned, @@ -427,3 +429,16 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) { return Account.findOne(query) } + +listByFollowersUrls = function (followersUrls: string[], transaction?: Sequelize.Transaction) { + const query: Sequelize.FindOptions = { + where: { + followersUrl: { + [Sequelize.Op.in]: followersUrls + } + }, + transaction + } + + return Account.findAll(query) +} -- cgit v1.2.3