From 4d385fad66974856bba59fb40d82875eadffaa40 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Tue, 17 Feb 2026 16:41:18 -0800 Subject: [PATCH] Add is_save_of_repost to track and playlist favorites --- api/swagger/swagger-v1.yaml | 21 +++++++++++++++++++++ api/v1_playlist_favorites.go | 16 +++++++++++++++- api/v1_track_favorites.go | 14 +++++++++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/api/swagger/swagger-v1.yaml b/api/swagger/swagger-v1.yaml index 65728fa7..862f29ee 100644 --- a/api/swagger/swagger-v1.yaml +++ b/api/swagger/swagger-v1.yaml @@ -1474,6 +1474,13 @@ paths: required: true schema: type: string + requestBody: + required: false + x-codegen-request-body-name: metadata + content: + application/json: + schema: + $ref: "#/components/schemas/favorite_request_body" responses: "200": description: Playlist favorited successfully @@ -2922,6 +2929,13 @@ paths: required: true schema: type: string + requestBody: + required: false + x-codegen-request-body-name: metadata + content: + application/json: + schema: + $ref: "#/components/schemas/favorite_request_body" responses: "200": description: Track favorited successfully @@ -10532,6 +10546,13 @@ components: type: integer description: ID of the entity (track) being commented on example: 12345 + favorite_request_body: + type: object + description: Optional metadata for favorite/save operations + properties: + is_save_of_repost: + type: boolean + description: Set to true when favoriting a reposted item (used for notifications) pin_comment_request_body: type: object required: diff --git a/api/v1_playlist_favorites.go b/api/v1_playlist_favorites.go index 732013d4..a00e29f2 100644 --- a/api/v1_playlist_favorites.go +++ b/api/v1_playlist_favorites.go @@ -1,6 +1,7 @@ package api import ( + "encoding/json" "strconv" "time" @@ -13,6 +14,10 @@ import ( "go.uber.org/zap" ) +type favoriteRequestBody struct { + IsSaveOfRepost *bool `json:"is_save_of_repost"` +} + func (app *ApiServer) v1PlaylistFavorites(c *fiber.Ctx) error { sql := ` SELECT user_id @@ -50,6 +55,15 @@ func (app *ApiServer) postV1PlaylistFavorite(c *fiber.Ctx) error { return err } + metadata := "" + if body := c.Body(); len(body) > 0 { + var reqBody favoriteRequestBody + if err := json.Unmarshal(body, &reqBody); err == nil && reqBody.IsSaveOfRepost != nil { + metadataBytes, _ := json.Marshal(map[string]bool{"is_save_of_repost": *reqBody.IsSaveOfRepost}) + metadata = string(metadataBytes) + } + } + nonce := time.Now().UnixNano() manageEntityTx := &corev1.ManageEntityLegacy{ @@ -59,7 +73,7 @@ func (app *ApiServer) postV1PlaylistFavorite(c *fiber.Ctx) error { Action: indexer.Action_Save, EntityType: indexer.Entity_Playlist, Nonce: strconv.FormatInt(nonce, 10), - Metadata: "", + Metadata: metadata, } response, err := app.sendTransactionWithSigner(manageEntityTx, signer.PrivateKey) diff --git a/api/v1_track_favorites.go b/api/v1_track_favorites.go index 4d35f4c3..ed73df0b 100644 --- a/api/v1_track_favorites.go +++ b/api/v1_track_favorites.go @@ -1,6 +1,7 @@ package api import ( + "encoding/json" "strconv" "time" @@ -50,6 +51,17 @@ func (app *ApiServer) postV1TrackFavorite(c *fiber.Ctx) error { return err } + metadata := "" + if body := c.Body(); len(body) > 0 { + var reqBody struct { + IsSaveOfRepost *bool `json:"is_save_of_repost"` + } + if err := json.Unmarshal(body, &reqBody); err == nil && reqBody.IsSaveOfRepost != nil { + metadataBytes, _ := json.Marshal(map[string]bool{"is_save_of_repost": *reqBody.IsSaveOfRepost}) + metadata = string(metadataBytes) + } + } + nonce := time.Now().UnixNano() manageEntityTx := &corev1.ManageEntityLegacy{ @@ -59,7 +71,7 @@ func (app *ApiServer) postV1TrackFavorite(c *fiber.Ctx) error { Action: indexer.Action_Save, EntityType: indexer.Entity_Track, Nonce: strconv.FormatInt(nonce, 10), - Metadata: "", + Metadata: metadata, } response, err := app.sendTransactionWithSigner(manageEntityTx, signer.PrivateKey)