From 3fda088864b738df89e2260c3eb9f7ba8f451a99 Mon Sep 17 00:00:00 2001 From: lleadbet Date: Tue, 7 Sep 2021 10:21:54 -0400 Subject: [PATCH] fixing unban fields --- internal/events/types/ban/ban.go | 35 +++++++++++++++++++------------- internal/models/ban.go | 24 +++++++++++----------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/internal/events/types/ban/ban.go b/internal/events/types/ban/ban.go index fd9816f3..84e96550 100644 --- a/internal/events/types/ban/ban.go +++ b/internal/events/types/ban/ban.go @@ -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 = ¶ms.IsPermanent + } + body := *&models.EventsubResponse{ Subscription: models.EventsubSubscription{ ID: params.ID, @@ -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) diff --git a/internal/models/ban.go b/internal/models/ban.go index 0ade7f7e..11ceed37 100644 --- a/internal/models/ban.go +++ b/internal/models/ban.go @@ -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 {