Skip to content

Commit d642093

Browse files
committed
Add coin-gated text posts
1 parent fe05114 commit d642093

7 files changed

Lines changed: 828 additions & 21 deletions

File tree

api/dbv1/access.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func (q *Queries) GetBulkTrackAccess(
323323
var mint string
324324
var balance int64
325325
if err := rows.Scan(&mint, &balance); err == nil {
326-
walletTokenBalances[mint] = balance
326+
walletTokenBalances[mint] += balance
327327
}
328328
}
329329
return rows.Err()

api/dbv1/full_comments.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ type FullComment struct {
4040
Replies []FullComment `json:"replies"`
4141
ParentCommentId pgtype.Int4 `json:"parent_comment_id"`
4242

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

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

5251
sql := `
5352
SELECT
54-
comment_id as id,
55-
parent_comment_id,
56-
entity_type,
57-
entity_id,
58-
user_id,
59-
text as message,
53+
comments.comment_id AS id,
54+
comment_threads.parent_comment_id,
55+
comments.entity_type,
56+
comments.entity_id,
57+
comments.user_id,
58+
comments.text AS message,
6059
6160
(
6261
SELECT json_agg(
@@ -72,7 +71,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
7271
) m
7372
)::jsonb as mentions,
7473
75-
track_timestamp_s,
74+
comments.track_timestamp_s,
7675
7776
(
7877
SELECT count(*)
@@ -90,7 +89,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
9089
AND cc.is_delete = false
9190
) as reply_ids,
9291
93-
is_edited,
92+
comments.is_edited,
9493
9594
EXISTS (
9695
SELECT 1
@@ -104,7 +103,7 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
104103
SELECT 1
105104
FROM comment_reactions
106105
WHERE comment_id = comments.comment_id
107-
AND user_id = tracks.owner_id
106+
AND user_id = COALESCE(tracks.owner_id, comments.entity_id)
108107
AND is_delete = false
109108
) AS is_artist_reacted,
110109
@@ -115,19 +114,22 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
115114
FROM comment_notification_settings mutes
116115
WHERE @my_id > 0
117116
AND mutes.user_id = @my_id
118-
AND mutes.entity_type = entity_type
119-
AND mutes.entity_id = entity_id
117+
AND mutes.entity_type = comments.entity_type
118+
AND mutes.entity_id = comments.entity_id
120119
LIMIT 1
121120
), false) as is_muted,
122121
123122
comments.created_at,
124123
comments.updated_at
125124
126125
FROM comments
127-
JOIN tracks ON entity_id = track_id
126+
LEFT JOIN tracks ON comments.entity_type = 'Track' AND comments.entity_id = tracks.track_id
128127
LEFT JOIN comment_threads USING (comment_id)
129-
WHERE comment_id = ANY(@ids::int[])
130-
AND (@include_unlisted = true OR tracks.is_unlisted = false)
128+
WHERE comments.comment_id = ANY(@ids::int[])
129+
AND (
130+
(comments.entity_type = 'Track' AND (@include_unlisted = true OR COALESCE(tracks.is_unlisted, false) = false))
131+
OR comments.entity_type = 'Coin'
132+
)
131133
ORDER BY comments.created_at DESC
132134
`
133135

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

153-
// fetch replies
154155
replyIds := []int32{}
155156
for _, comment := range comments {
156157
replyIds = append(replyIds, comment.ReplyIds...)
@@ -170,7 +171,6 @@ func (q *Queries) FullCommentsKeyed(ctx context.Context, arg GetCommentsParams)
170171
comment.Replies = append(comment.Replies, reply)
171172
}
172173
}
173-
// todo: sort replies?
174174
comment.ReplyCount = len(comment.Replies)
175175

176176
if comment.IsDelete {

api/dbv1/parallel.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type ParallelParams struct {
1212
PlaylistIds []int32
1313
MyID int32
1414
AuthedWallet string
15+
SolanaWallet string
1516
}
1617

1718
type ParallelResult struct {
@@ -47,6 +48,7 @@ func (q *Queries) Parallel(ctx context.Context, arg ParallelParams) (*ParallelRe
4748
MyID: arg.MyID,
4849
AuthedWallet: arg.AuthedWallet,
4950
},
51+
SolanaWallet: arg.SolanaWallet,
5052
})
5153
return err
5254
})

api/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,8 @@ func NewApiServer(config config.Config) *ApiServer {
507507
g.Post("/tracks/:trackId/downloads", app.requireAuthMiddleware, app.requireWriteScope, app.postV1TrackDownload)
508508
g.Put("/tracks/:trackId", app.requireAuthMiddleware, app.requireWriteScope, app.putV1Track)
509509
g.Delete("/tracks/:trackId", app.requireAuthMiddleware, app.requireWriteScope, app.deleteV1Track)
510+
g.Get("/fan_club/feed", app.v1FanClubFeed)
511+
510512
g.Get("/tracks/:trackId/comments", app.v1TrackComments)
511513
g.Get("/tracks/:trackId/comment_count", app.v1TrackCommentCount)
512514
g.Get("/tracks/:trackId/comment-count", app.v1TrackCommentCount)

0 commit comments

Comments
 (0)