diff options
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account-interface.ts | 2 | ||||
-rw-r--r-- | server/models/account/account.ts | 17 |
2 files changed, 18 insertions, 1 deletions
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 { | |||
12 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> | 12 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> |
13 | export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> | 13 | export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> |
14 | export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> | 14 | export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> |
15 | export type ListByFollowersUrls = (followerUrls: string[], transaction?: Sequelize.Transaction) => Bluebird<AccountInstance[]> | ||
15 | 16 | ||
16 | export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor | 17 | export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor |
17 | export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount | 18 | export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount |
@@ -29,6 +30,7 @@ export interface AccountClass { | |||
29 | loadByUrl: AccountMethods.LoadByUrl | 30 | loadByUrl: AccountMethods.LoadByUrl |
30 | loadLocalByName: AccountMethods.LoadLocalByName | 31 | loadLocalByName: AccountMethods.LoadLocalByName |
31 | loadByNameAndHost: AccountMethods.LoadByNameAndHost | 32 | loadByNameAndHost: AccountMethods.LoadByNameAndHost |
33 | listByFollowersUrls: AccountMethods.ListByFollowersUrls | ||
32 | } | 34 | } |
33 | 35 | ||
34 | export interface AccountAttributes { | 36 | 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 | |||
26 | let loadByUrl: AccountMethods.LoadByUrl | 26 | let loadByUrl: AccountMethods.LoadByUrl |
27 | let loadLocalByName: AccountMethods.LoadLocalByName | 27 | let loadLocalByName: AccountMethods.LoadLocalByName |
28 | let loadByNameAndHost: AccountMethods.LoadByNameAndHost | 28 | let loadByNameAndHost: AccountMethods.LoadByNameAndHost |
29 | let listByFollowersUrls: AccountMethods.ListByFollowersUrls | ||
29 | let isOwned: AccountMethods.IsOwned | 30 | let isOwned: AccountMethods.IsOwned |
30 | let toActivityPubObject: AccountMethods.ToActivityPubObject | 31 | let toActivityPubObject: AccountMethods.ToActivityPubObject |
31 | let toFormattedJSON: AccountMethods.ToFormattedJSON | 32 | let toFormattedJSON: AccountMethods.ToFormattedJSON |
@@ -188,7 +189,8 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
188 | loadByUUID, | 189 | loadByUUID, |
189 | loadByUrl, | 190 | loadByUrl, |
190 | loadLocalByName, | 191 | loadLocalByName, |
191 | loadByNameAndHost | 192 | loadByNameAndHost, |
193 | listByFollowersUrls | ||
192 | ] | 194 | ] |
193 | const instanceMethods = [ | 195 | const instanceMethods = [ |
194 | isOwned, | 196 | isOwned, |
@@ -427,3 +429,16 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) { | |||
427 | 429 | ||
428 | return Account.findOne(query) | 430 | return Account.findOne(query) |
429 | } | 431 | } |
432 | |||
433 | listByFollowersUrls = function (followersUrls: string[], transaction?: Sequelize.Transaction) { | ||
434 | const query: Sequelize.FindOptions<AccountAttributes> = { | ||
435 | where: { | ||
436 | followersUrl: { | ||
437 | [Sequelize.Op.in]: followersUrls | ||
438 | } | ||
439 | }, | ||
440 | transaction | ||
441 | } | ||
442 | |||
443 | return Account.findAll(query) | ||
444 | } | ||