Skip to content

Commit

Permalink
Update custom reward redemptions response
Browse files Browse the repository at this point in the history
  • Loading branch information
aaricdev committed Dec 16, 2023
1 parent dc6e431 commit 18c1ae5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/database/channel_points_redemptions.go
Expand Up @@ -15,7 +15,7 @@ type ChannelPointsRedemption struct {
UserLogin string `db:"user_login" dbi:"false" json:"user_login"`
UserName string `db:"user_name" dbi:"false" json:"user_name"`
UserInput sql.NullString `db:"user_input" json:"-"`
RealUserInput *string `json:"user_input"`
RealUserInput string `json:"user_input"`
RedemptionStatus string `db:"redemption_status" json:"status"`
RedeemedAt string `db:"redeemed_at" json:"redeemed_at"`
RewardID string `db:"reward_id" json:"-"`
Expand All @@ -25,7 +25,7 @@ type ChannelPointsRedemption struct {
type ChannelPointsRedemptionRewardInfo struct {
ID string `dbi:"false" db:"red_id" json:"id" dbs:"red.id"`
Title string `dbi:"false" db:"title" json:"title"`
RewardPrompt string `dbi:"false" db:"reward_prompt" json:"reward_prompt"`
RewardPrompt string `dbi:"false" db:"reward_prompt" json:"prompt"`
Cost int `dbi:"false" db:"cost" json:"cost"`
}

Expand All @@ -50,9 +50,9 @@ func (q *Query) GetChannelPointsRedemption(cpr ChannelPointsRedemption, sort str
if err != nil {
return nil, err
}
red.RealUserInput = &red.UserInput.String
red.RealUserInput = red.UserInput.String
if !red.UserInput.Valid {
red.RealUserInput = nil
red.RealUserInput = ""
}
r = append(r, red)
}
Expand Down
5 changes: 5 additions & 0 deletions internal/mock_api/endpoints/channel_points/redemptions.go
Expand Up @@ -68,6 +68,11 @@ func getRedemptions(w http.ResponseWriter, r *http.Request) {
status := r.URL.Query().Get("status")
sort := r.URL.Query().Get("sort")

if id == "" && status == "" {
mock_errors.WriteBadRequest(w, "The status query parameter is required if you don't specify the id query parameter.")
return
}

if !userCtx.MatchesBroadcasterIDParam(r) {
mock_errors.WriteUnauthorized(w, "Broadcaster ID mismatch")
return
Expand Down

0 comments on commit 18c1ae5

Please sign in to comment.