diff --git a/api/swagger/swagger-v1.yaml b/api/swagger/swagger-v1.yaml index 4548a35c..0500b210 100644 --- a/api/swagger/swagger-v1.yaml +++ b/api/swagger/swagger-v1.yaml @@ -1556,6 +1556,12 @@ paths: required: true schema: type: string + requestBody: + required: false + content: + application/json: + schema: + $ref: "#/components/schemas/repost_request_body" responses: "200": description: Playlist reposted successfully @@ -3147,6 +3153,12 @@ paths: required: true schema: type: string + requestBody: + required: false + content: + application/json: + schema: + $ref: "#/components/schemas/repost_request_body" responses: "200": description: Track reposted successfully @@ -10556,6 +10568,13 @@ components: is_save_of_repost: type: boolean description: Set to true when favoriting a reposted item (used for notifications) + repost_request_body: + type: object + description: Optional metadata for repost operations + properties: + is_repost_of_repost: + type: boolean + description: Set to true when reposting an item that was reposted (used for notifications) pin_comment_request_body: type: object required: diff --git a/api/v1_playlist_reposts.go b/api/v1_playlist_reposts.go index 58eb8fcc..33880fed 100644 --- a/api/v1_playlist_reposts.go +++ b/api/v1_playlist_reposts.go @@ -1,6 +1,7 @@ package api import ( + "encoding/json" "strconv" "time" @@ -50,6 +51,17 @@ func (app *ApiServer) postV1PlaylistRepost(c *fiber.Ctx) error { return err } + metadata := "" + if body := c.Body(); len(body) > 0 { + var reqBody struct { + IsRepostOfRepost *bool `json:"is_repost_of_repost"` + } + if err := json.Unmarshal(body, &reqBody); err == nil && reqBody.IsRepostOfRepost != nil { + metadataBytes, _ := json.Marshal(map[string]bool{"is_repost_of_repost": *reqBody.IsRepostOfRepost}) + metadata = string(metadataBytes) + } + } + nonce := time.Now().UnixNano() manageEntityTx := &corev1.ManageEntityLegacy{ @@ -59,7 +71,7 @@ func (app *ApiServer) postV1PlaylistRepost(c *fiber.Ctx) error { Action: indexer.Action_Repost, 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_reposts.go b/api/v1_track_reposts.go index e9e0bc14..ae147d37 100644 --- a/api/v1_track_reposts.go +++ b/api/v1_track_reposts.go @@ -1,6 +1,7 @@ package api import ( + "encoding/json" "strconv" "time" @@ -50,9 +51,18 @@ func (app *ApiServer) postV1TrackRepost(c *fiber.Ctx) error { return err } + metadata := "" + if body := c.Body(); len(body) > 0 { + var reqBody struct { + IsRepostOfRepost *bool `json:"is_repost_of_repost"` + } + if err := json.Unmarshal(body, &reqBody); err == nil && reqBody.IsRepostOfRepost != nil { + metadataBytes, _ := json.Marshal(map[string]bool{"is_repost_of_repost": *reqBody.IsRepostOfRepost}) + metadata = string(metadataBytes) + } + } + nonce := time.Now().UnixNano() - nonceBytes := make([]byte, 32) - copy(nonceBytes, []byte(strconv.FormatInt(nonce, 10))) manageEntityTx := &corev1.ManageEntityLegacy{ Signer: common.HexToAddress(signer.Address).String(), @@ -61,7 +71,7 @@ func (app *ApiServer) postV1TrackRepost(c *fiber.Ctx) error { Action: indexer.Action_Repost, EntityType: indexer.Entity_Track, Nonce: strconv.FormatInt(nonce, 10), - Metadata: "", + Metadata: metadata, } response, err := app.sendTransactionWithSigner(manageEntityTx, signer.PrivateKey)