Skip to content

Commit

Permalink
Merge pull request #102 from twitchdev/bugfix/fixing-unban
Browse files Browse the repository at this point in the history
fixing unban fields
  • Loading branch information
lleadbet authored Sep 7, 2021
2 parents 5508e02 + 24172a7 commit f5e790a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
35 changes: 21 additions & 14 deletions internal/events/types/ban/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven

switch params.Transport {
case models.TransportEventSub:
e := models.BanEventSubEvent{
UserID: params.FromUserID,
UserLogin: params.FromUserName,
UserName: params.FromUserName,
BroadcasterUserID: params.ToUserID,
BroadcasterUserLogin: params.ToUserName,
BroadcasterUserName: params.ToUserName,
ModeratorUserId: util.RandomUserID(),
ModeratorUserLogin: "CLIModerator",
ModeratorUserName: "CLIModerator",
}

if params.Trigger == "ban" {
reason := "This is a test event"
endsAt := util.GetTimestamp().Format(time.RFC3339Nano)
e.Reason = &reason
e.EndsAt = &endsAt
e.IsPermanent = &params.IsPermanent
}

body := *&models.EventsubResponse{
Subscription: models.EventsubSubscription{
ID: params.ID,
Expand All @@ -53,20 +73,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
Cost: 0,
CreatedAt: util.GetTimestamp().Format(time.RFC3339Nano),
},
Event: models.BanEventSubEvent{
UserID: params.FromUserID,
UserLogin: params.FromUserName,
UserName: params.FromUserName,
BroadcasterUserID: params.ToUserID,
BroadcasterUserLogin: params.ToUserName,
BroadcasterUserName: params.ToUserName,
ModeratorUserId: util.RandomUserID(),
ModeratorUserLogin: "CLIModerator",
ModeratorUserName: "CLIModerator",
Reason: "This is a test event",
EndsAt: util.GetTimestamp().Format(time.RFC3339Nano),
IsPermanent: params.IsPermanent,
},
Event: e,
}

event, err = json.Marshal(body)
Expand Down
24 changes: 12 additions & 12 deletions internal/models/ban.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
package models

type BanEventSubEvent struct {
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
BroadcasterUserID string `json:"broadcaster_user_id"`
BroadcasterUserLogin string `json:"broadcaster_user_login"`
BroadcasterUserName string `json:"broadcaster_user_name"`
ModeratorUserId string `json:"moderator_user_id"`
ModeratorUserLogin string `json:"moderator_user_login"`
ModeratorUserName string `json:"moderator_user_name"`
Reason string `json:"reason"`
EndsAt string `json:"ends_at"`
IsPermanent bool `json:"is_permanent"`
UserID string `json:"user_id"`
UserLogin string `json:"user_login"`
UserName string `json:"user_name"`
BroadcasterUserID string `json:"broadcaster_user_id"`
BroadcasterUserLogin string `json:"broadcaster_user_login"`
BroadcasterUserName string `json:"broadcaster_user_name"`
ModeratorUserId string `json:"moderator_user_id"`
ModeratorUserLogin string `json:"moderator_user_login"`
ModeratorUserName string `json:"moderator_user_name"`
Reason *string `json:"reason,omitempty"`
EndsAt *string `json:"ends_at,omitempty"`
IsPermanent *bool `json:"is_permanent,omitempty"`
}

type BanEventSubResponse struct {
Expand Down

0 comments on commit f5e790a

Please sign in to comment.