-// ------------------------------ UTILS ------------------------------
-
-async function createListFollowForApiQuery (type: 'followers' | 'following', name: string, start: number, count: number) {
- let firstJoin: string
- let secondJoin: string
-
- if (type === 'followers') {
- firstJoin = 'targetAccountId'
- secondJoin = 'accountId'
- } else {
- firstJoin = 'accountId'
- secondJoin = 'targetAccountId'
- }
-
- const selections = [ '"Followers"."url" AS "url"', 'COUNT(*) AS "total"' ]
- const tasks: Promise<any>[] = []
-
- for (const selection of selections) {
- const query = 'SELECT ' + selection + ' FROM "Account" ' +
- 'INNER JOIN "AccountFollower" ON "AccountFollower"."' + firstJoin + '" = "Account"."id" ' +
- 'INNER JOIN "Account" AS "Followers" ON "Followers"."id" = "AccountFollower"."' + secondJoin + '" ' +
- 'WHERE "Account"."name" = \'$name\' ' +
- 'LIMIT ' + start + ', ' + count
-
- const options = {
- bind: { name },
- type: Sequelize.QueryTypes.SELECT
- }
- tasks.push(Account['sequelize'].query(query, options))
+loadAccountByServerAndUUID = function (uuid: string, serverId: number, transaction: Sequelize.Transaction) {
+ const query: Sequelize.FindOptions<AccountAttributes> = {
+ where: {
+ serverId,
+ uuid
+ },
+ transaction