Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/dbv1/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (q *Queries) GetBulkTrackAccess(
var mint string
var balance int64
if err := rows.Scan(&mint, &balance); err == nil {
walletTokenBalances[mint] = balance
walletTokenBalances[mint] += balance
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

}
}
return rows.Err()
Expand Down
34 changes: 17 additions & 17 deletions api/dbv1/full_comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type FullComment struct {
Replies []FullComment `json:"replies"`
ParentCommentId pgtype.Int4 `json:"parent_comment_id"`

// this should be omitted
ReplyIds []int32 `db:"reply_ids" json:"-"`
}

Expand All @@ -51,12 +50,12 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)

sql := `
SELECT
comment_id as id,
parent_comment_id,
entity_type,
entity_id,
user_id,
text as message,
comments.comment_id AS id,
comment_threads.parent_comment_id,
comments.entity_type,
comments.entity_id,
comments.user_id,
comments.text AS message,

(
SELECT json_agg(
Expand All @@ -72,7 +71,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
) m
)::jsonb as mentions,

track_timestamp_s,
comments.track_timestamp_s,

(
SELECT count(*)
Expand All @@ -90,7 +89,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
AND cc.is_delete = false
) as reply_ids,

is_edited,
comments.is_edited,

EXISTS (
SELECT 1
Expand All @@ -104,7 +103,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
SELECT 1
FROM comment_reactions
WHERE comment_id = comments.comment_id
AND user_id = tracks.owner_id
AND user_id = COALESCE(tracks.owner_id, comments.entity_id)
AND is_delete = false
) AS is_artist_reacted,

Expand All @@ -115,19 +114,22 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
FROM comment_notification_settings mutes
WHERE @my_id > 0
AND mutes.user_id = @my_id
AND mutes.entity_type = entity_type
AND mutes.entity_id = entity_id
AND mutes.entity_type = comments.entity_type
AND mutes.entity_id = comments.entity_id
LIMIT 1
), false) as is_muted,

comments.created_at,
comments.updated_at

FROM comments
JOIN tracks ON entity_id = track_id
LEFT JOIN tracks ON comments.entity_type = 'Track' AND comments.entity_id = tracks.track_id
LEFT JOIN comment_threads USING (comment_id)
WHERE comment_id = ANY(@ids::int[])
AND (@include_unlisted = true OR tracks.is_unlisted = false)
WHERE comments.comment_id = ANY(@ids::int[])
AND (
(comments.entity_type = 'Track' AND (@include_unlisted = true OR COALESCE(tracks.is_unlisted, false) = false))
OR comments.entity_type = 'FanClub'
)
ORDER BY comments.created_at DESC
`

Expand All @@ -150,7 +152,6 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
commentMap[int32(comment.Id)] = comment
}

// fetch replies
replyIds := []int32{}
for _, comment := range comments {
replyIds = append(replyIds, comment.ReplyIds...)
Expand All @@ -170,7 +171,6 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
comment.Replies = append(comment.Replies, reply)
}
}
// todo: sort replies?
comment.ReplyCount = len(comment.Replies)

if comment.IsDelete {
Expand Down
10 changes: 5 additions & 5 deletions api/dbv1/parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
)

type ParallelParams struct {
UserIds []int32
TrackIds []int32
PlaylistIds []int32
MyID int32
AuthedWallet string
UserIds []int32
TrackIds []int32
PlaylistIds []int32
MyID int32
AuthedWallet string
}

type ParallelResult struct {
Expand Down
3 changes: 3 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ func NewApiServer(config config.Config) *ApiServer {
g.Post("/tracks/:trackId/downloads", app.requireAuthMiddleware, app.requireWriteScope, app.postV1TrackDownload)
g.Put("/tracks/:trackId", app.requireAuthMiddleware, app.requireWriteScope, app.putV1Track)
g.Delete("/tracks/:trackId", app.requireAuthMiddleware, app.requireWriteScope, app.deleteV1Track)
g.Get("/fan_club/feed", app.v1FanClubFeed)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add fan-club? i think we are generally moving in the direction of - instead of _

g.Get("/fan-club/feed", app.v1FanClubFeed)

g.Get("/tracks/:trackId/comments", app.v1TrackComments)
g.Get("/tracks/:trackId/comment_count", app.v1TrackCommentCount)
g.Get("/tracks/:trackId/comment-count", app.v1TrackCommentCount)
Expand Down
95 changes: 95 additions & 0 deletions api/swagger/swagger-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,100 @@ paths:
"500":
description: Server error
content: {}
/fan_club/feed:
get:
tags:
- fan_club
description: Get the fan club feed for a given artist, including text posts and comments
operationId: Get Fan Club Feed
security:
- {}
- OAuth2:
- read
parameters:
- name: mint
in: query
description: The mint address of the artist's fan club token
required: true
schema:
type: string
- name: user_id
in: query
description: The user ID of the user making the request
schema:
type: string
- name: offset
in: query
description:
The number of items to skip. Useful for pagination (page number
* limit)
schema:
type: integer
- name: limit
in: query
description: The number of items to fetch
schema:
type: integer
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/track_comments_response"
"400":
description: Bad request
content: {}
"500":
description: Server error
content: {}
/fan-club/feed:
get:
tags:
- fan_club
description: Get the fan club feed for a given artist (hyphenated alias), including text posts and comments
operationId: Get Fan Club Feed Alias
security:
- {}
- OAuth2:
- read
parameters:
- name: mint
in: query
description: The mint address of the artist's fan club token
required: true
schema:
type: string
- name: user_id
in: query
description: The user ID of the user making the request
schema:
type: string
- name: offset
in: query
description:
The number of items to skip. Useful for pagination (page number
* limit)
schema:
type: integer
- name: limit
in: query
description: The number of items to fetch
schema:
type: integer
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: "#/components/schemas/track_comments_response"
"400":
description: Bad request
content: {}
"500":
description: Server error
content: {}
/developer-apps:
post:
tags:
Expand Down Expand Up @@ -14682,6 +14776,7 @@ components:
description: Type of entity that can be commented on
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also probably want the new endpoint changes in swagger too

enum:
- Track
- Coin
top_listener:
type: object
properties:
Expand Down
Loading
Loading