Skip to content

Commit

Permalink
WIP4
Browse files Browse the repository at this point in the history
  • Loading branch information
Saliou Diallo committed Sep 28, 2022
1 parent 55a1e57 commit d599e7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions discovery-provider/src/premium_content/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def does_user_follow_artist(user_id: int, artist_id: int):
result = (
session.query(Follow)
.filter(Follow.is_current == True)
.filter(Follow.is_delete == False)
.filter(Follow.follower_user_id == user_id)
.filter(Follow.followee_user_id == artist_id)
.one_or_none()
Expand Down
13 changes: 8 additions & 5 deletions libs/src/api/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class File extends Base {
creatorNodeGateways: string[],
callback: Nullable<(url: string) => void> = null,
responseType: ResponseType = 'blob',
trackId = null
trackId = null,
premiumContentHeaders = {}
) {
const urls: string[] = []

Expand All @@ -63,19 +64,20 @@ export class File extends Base {
callback!,
{
method: 'get',
responseType
responseType,
...premiumContentHeaders
},
/* timeout */ null
)

if (!response) {
const allUnauthorized = errored.every(
const allForbidden = errored.every(
// @ts-expect-error not valid axios error
(error) => error.response.status === 403
)
if (allUnauthorized) {
if (allForbidden) {
// In the case for a 403, do not retry fetching
bail(new Error('Unauthorized'))
bail(new Error('Forbidden'))
return
}
throw new Error(`Could not fetch ${cid}`)
Expand All @@ -99,6 +101,7 @@ export class File extends Base {
{
method: 'get',
responseType
// todo: Do we need to also set the premium content headers in this legacy flow?
},
/* timeout */ null
)
Expand Down

0 comments on commit d599e7a

Please sign in to comment.