aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account/account-follow.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-15 16:28:35 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit8e10cf1a5a438a00e5f7e0691cb830769867cffc (patch)
tree23c0aeb43d7fb05b2d280c37b4334c2f320b647e /server/models/account/account-follow.ts
parent8e13fa7d09e9925b4559cbba6c5d72c5ff1bd391 (diff)
downloadPeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.gz
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.tar.zst
PeerTube-8e10cf1a5a438a00e5f7e0691cb830769867cffc.zip
Fix video upload and videos list
Diffstat (limited to 'server/models/account/account-follow.ts')
-rw-r--r--server/models/account/account-follow.ts24
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
149listAcceptedFollowerUrlsForApi = function (id: number, start: number, count?: number) { 149listAcceptedFollowerUrlsForApi = 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
153listAcceptedFollowingUrlsForApi = function (id: number, start: number, count?: number) { 153listAcceptedFollowingUrlsForApi = 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
159async function createListAcceptedFollowForApiQuery (type: 'followers' | 'following', id: number, start: number, count?: number) { 159async 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))