diff options
Diffstat (limited to 'server/models/account/account-follow.ts')
-rw-r--r-- | server/models/account/account-follow.ts | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/server/models/account/account-follow.ts b/server/models/account/account-follow.ts index c940d7cd4..f457e43e9 100644 --- a/server/models/account/account-follow.ts +++ b/server/models/account/account-follow.ts | |||
@@ -146,17 +146,17 @@ listFollowersForApi = function (id: number, start: number, count: number, sort: | |||
146 | }) | 146 | }) |
147 | } | 147 | } |
148 | 148 | ||
149 | listAcceptedFollowerUrlsForApi = function (id: number, start: number, count?: number) { | 149 | listAcceptedFollowerUrlsForApi = function (accountId: number, start?: number, count?: number) { |
150 | return createListAcceptedFollowForApiQuery('followers', id, start, count) | 150 | return createListAcceptedFollowForApiQuery('followers', accountId, start, count) |
151 | } | 151 | } |
152 | 152 | ||
153 | listAcceptedFollowingUrlsForApi = function (id: number, start: number, count?: number) { | 153 | listAcceptedFollowingUrlsForApi = function (accountId: number, start?: number, count?: number) { |
154 | return createListAcceptedFollowForApiQuery('following', id, start, count) | 154 | return createListAcceptedFollowForApiQuery('following', accountId, start, count) |
155 | } | 155 | } |
156 | 156 | ||
157 | // ------------------------------ UTILS ------------------------------ | 157 | // ------------------------------ UTILS ------------------------------ |
158 | 158 | ||
159 | async function createListAcceptedFollowForApiQuery (type: 'followers' | 'following', id: number, start: number, count?: number) { | 159 | async function createListAcceptedFollowForApiQuery (type: 'followers' | 'following', accountId: number, start?: number, count?: number) { |
160 | let firstJoin: string | 160 | let firstJoin: string |
161 | let secondJoin: string | 161 | let secondJoin: string |
162 | 162 | ||
@@ -168,20 +168,20 @@ async function createListAcceptedFollowForApiQuery (type: 'followers' | 'followi | |||
168 | secondJoin = 'targetAccountId' | 168 | secondJoin = 'targetAccountId' |
169 | } | 169 | } |
170 | 170 | ||
171 | const selections = [ '"Followers"."url" AS "url"', 'COUNT(*) AS "total"' ] | 171 | const selections = [ '"Follows"."url" AS "url"', 'COUNT(*) AS "total"' ] |
172 | const tasks: Promise<any>[] = [] | 172 | const tasks: Promise<any>[] = [] |
173 | 173 | ||
174 | for (const selection of selections) { | 174 | for (const selection of selections) { |
175 | let query = 'SELECT ' + selection + ' FROM "Account" ' + | 175 | let query = 'SELECT ' + selection + ' FROM "Accounts" ' + |
176 | 'INNER JOIN "AccountFollow" ON "AccountFollow"."' + firstJoin + '" = "Account"."id" ' + | 176 | 'INNER JOIN "AccountFollows" ON "AccountFollows"."' + firstJoin + '" = "Accounts"."id" ' + |
177 | 'INNER JOIN "Account" AS "Follows" ON "Followers"."id" = "Follows"."' + secondJoin + '" ' + | 177 | 'INNER JOIN "Accounts" AS "Follows" ON "AccountFollows"."' + secondJoin + '" = "Follows"."id" ' + |
178 | 'WHERE "Account"."id" = $id AND "AccountFollow"."state" = \'accepted\' ' + | 178 | 'WHERE "Accounts"."id" = $accountId AND "AccountFollows"."state" = \'accepted\' ' |
179 | 'LIMIT ' + start | ||
180 | 179 | ||
180 | if (start !== undefined) query += 'LIMIT ' + start | ||
181 | if (count !== undefined) query += ', ' + count | 181 | if (count !== undefined) query += ', ' + count |
182 | 182 | ||
183 | const options = { | 183 | const options = { |
184 | bind: { id }, | 184 | bind: { accountId }, |
185 | type: Sequelize.QueryTypes.SELECT | 185 | type: Sequelize.QueryTypes.SELECT |
186 | } | 186 | } |
187 | tasks.push(AccountFollow['sequelize'].query(query, options)) | 187 | tasks.push(AccountFollow['sequelize'].query(query, options)) |