Skip to content
Merged
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
19 changes: 19 additions & 0 deletions api/swagger/swagger-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion api/v1_playlist_reposts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"encoding/json"
"strconv"
"time"

Expand Down Expand Up @@ -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{
Expand All @@ -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)
Expand Down
16 changes: 13 additions & 3 deletions api/v1_track_reposts.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"encoding/json"
"strconv"
"time"

Expand Down Expand Up @@ -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(),
Expand All @@ -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)
Expand Down