Skip to content

Commit 2d3755d

Browse files
committed
Support for larger drop payloads
1 parent 644266d commit 2d3755d

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

cmd/events.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func init() {
149149
triggerCmd.Flags().StringVarP(&subscriptionStatus, "subscription-status", "r", "enabled", "Status of the Subscription object (.subscription.status in JSON). Defaults to \"enabled\".")
150150
triggerCmd.Flags().StringVarP(&itemID, "item-id", "i", "", "Manually set the ID of the event payload item (for example the reward ID in redemption events). For stream events, this is the game ID.")
151151
triggerCmd.Flags().StringVarP(&itemName, "item-name", "n", "", "Manually set the name of the event payload item (for example the reward ID in redemption events). For stream events, this is the game title.")
152-
triggerCmd.Flags().Int64VarP(&cost, "cost", "C", 0, "Amount of subscriptions, bits, or channel points redeemed/used in the event.")
152+
triggerCmd.Flags().Int64VarP(&cost, "cost", "C", 0, "Amount of drops, subscriptions, bits, or channel points redeemed/used in the event.")
153153
triggerCmd.Flags().StringVarP(&description, "description", "d", "", "Title the stream should be updated with.")
154154
triggerCmd.Flags().StringVarP(&gameID, "game-id", "G", "", "Sets the game/category ID for applicable events.")
155155
triggerCmd.Flags().StringVarP(&tier, "tier", "", "", "Sets the subscription tier. Valid values are 1000, 2000, and 3000.")

internal/events/types/drop/drop.go

+36-17
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,41 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
4141
case models.TransportWebhook:
4242
campaignId := util.RandomGUID()
4343

44+
dropEvents := []models.DropsEntitlementEventSubEvent{
45+
{
46+
ID: util.RandomGUID(),
47+
Data: models.DropsEntitlementEventSubEventData{
48+
OrganizationID: params.FromUserID,
49+
CategoryID: params.GameID,
50+
CategoryName: "Special Events",
51+
CampaignID: campaignId,
52+
EntitlementID: util.RandomGUID(),
53+
BenefitID: params.ItemID,
54+
UserID: params.ToUserID,
55+
UserName: params.ToUserName,
56+
UserLogin: params.ToUserName,
57+
CreatedAt: params.Timestamp,
58+
},
59+
},
60+
}
61+
62+
for i := int64(1); i < params.Cost; i++ {
63+
// for the new events, we'll use the entitlement above except generating new users as to avoid conflicting drops
64+
dropEvents = append(dropEvents, models.DropsEntitlementEventSubEvent{
65+
ID: util.RandomGUID(),
66+
Data: models.DropsEntitlementEventSubEventData{
67+
OrganizationID: params.FromUserID,
68+
CategoryID: params.GameID,
69+
CategoryName: "Special Events",
70+
CampaignID: campaignId,
71+
EntitlementID: util.RandomGUID(),
72+
BenefitID: params.ItemID,
73+
UserID: util.RandomUserID(),
74+
UserName: params.ToUserName,
75+
UserLogin: params.ToUserName,
76+
CreatedAt: params.Timestamp,
77+
}})
78+
}
4479
body := &models.DropsEntitlementEventSubResponse{
4580
Subscription: models.EventsubSubscription{
4681
ID: params.ID,
@@ -59,23 +94,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
5994
Cost: 0,
6095
CreatedAt: params.Timestamp,
6196
},
62-
Events: []models.DropsEntitlementEventSubEvent{
63-
{
64-
ID: util.RandomGUID(),
65-
Data: models.DropsEntitlementEventSubEventData{
66-
OrganizationID: params.FromUserID,
67-
CategoryID: params.GameID,
68-
CategoryName: "Special Events",
69-
CampaignID: campaignId,
70-
EntitlementID: util.RandomGUID(),
71-
BenefitID: params.ItemID,
72-
UserID: params.ToUserID,
73-
UserName: params.ToUserName,
74-
UserLogin: params.ToUserName,
75-
CreatedAt: params.Timestamp,
76-
},
77-
},
78-
},
97+
Events: dropEvents,
7998
}
8099
event, err = json.Marshal(body)
81100
if err != nil {

0 commit comments

Comments
 (0)