diff --git a/code.png b/code.png index a169c3a..911da57 100644 Binary files a/code.png and b/code.png differ diff --git a/service/controllers/controllers.go b/service/controllers/controllers.go index e389351..cc79a80 100644 --- a/service/controllers/controllers.go +++ b/service/controllers/controllers.go @@ -22,7 +22,7 @@ func BuildRouter(r *gin.Engine) { log = logrus.New() log.SetFormatter(&logrus.TextFormatter{ - DisableColors: true, + DisableColors: true, }) log.SetLevel(logrus.DebugLevel) diff --git a/service/controllers/pco_webhook.go b/service/controllers/pco_webhook.go index 5bac390..7a3292b 100644 --- a/service/controllers/pco_webhook.go +++ b/service/controllers/pco_webhook.go @@ -195,7 +195,7 @@ func youtubeServiceForUser(userId primitive.ObjectID) (*youtube.Service, error) } } -//TODO: Revisit the structure of this function +// TODO: Revisit the structure of this function func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery) error { //get uid from context. Lots of sanitizing just incase uid := userIdFromContext(c) @@ -278,7 +278,7 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery) } //save audit trail - err = mongo.SaveModels( actionTaken) + err = mongo.SaveModels(actionTaken) if err != nil { log.WithError(err).Error("Failed to save broadcastModel and actionTaken") return err diff --git a/service/controllers/pco_webhook_test.go b/service/controllers/pco_webhook_test.go index 4528381..d493d0f 100644 --- a/service/controllers/pco_webhook_test.go +++ b/service/controllers/pco_webhook_test.go @@ -7,9 +7,9 @@ import ( ) func TestPlanEventMatch(t *testing.T) { - events := []string{"services.v2.events.plan.updated","services.v2.events.plan.destroyed","services.v2.events.plan.created"} + events := []string{"services.v2.events.plan.updated", "services.v2.events.plan.destroyed", "services.v2.events.plan.created"} for _, event := range events { - assert.Equal(t, eventMatch("plan", event), true) + assert.Equal(t, eventMatch("plan", event), true) } } diff --git a/service/vendors/pco/webhooks.go b/service/vendors/pco/webhooks.go index 9140735..77f58f6 100644 --- a/service/vendors/pco/webhooks.go +++ b/service/vendors/pco/webhooks.go @@ -24,7 +24,6 @@ func (api *PcoApiClient) GetSubscriptions() ([]webhooks.Subscription, error) { return nil, err } - if resp.StatusCode > 299 || resp.StatusCode < 200 { if raw, err := io.ReadAll(resp.Body); err == nil { return nil, fmt.Errorf("Failed to retrieve subscriptions with status code: %d. Error %s", resp.StatusCode, string(raw)) diff --git a/service/vendors/pco/webhooks/subscription.go b/service/vendors/pco/webhooks/subscription.go index 107d195..a77db83 100644 --- a/service/vendors/pco/webhooks/subscription.go +++ b/service/vendors/pco/webhooks/subscription.go @@ -6,7 +6,7 @@ type Subscription struct { Id string `jsonapi:"primary,Subscription" bson:"id"` //attrs Active bool `jsonapi:"attr,active,omitempty" bson:"active"` - ApplicationId int `jsonapi:"attr,application_id,omitempty" bson:"application_id"` + ApplicationId int `jsonapi:"attr,application_id,omitempty" bson:"application_id"` AuthenticitySecret string `jsonapi:"attr,authenticity_secret,omitempty" bson:"authenticity_secret"` CreatedAt time.Time `jsonapi:"attr,created_at,rfc3339,omitempty" bson:"created_at"` UpdatedAt time.Time `jsonapi:"attr,updated_at,rfc3339,omitempty" bson:"updated_at"` diff --git a/service/vendors/pco/webhooks_test.go b/service/vendors/pco/webhooks_test.go index 1a2b8d7..1e3532d 100644 --- a/service/vendors/pco/webhooks_test.go +++ b/service/vendors/pco/webhooks_test.go @@ -23,7 +23,7 @@ var pcoMockAccount models.VendorAccount = models.VendorAccount{ TokenType: "bearer", RefreshToken: "asdfas;lkdjfas;dlkfj;asdlkj;aslf", }, - Name: "pco", + Name: "pco", } func TestCreateSubscriptions(t *testing.T) { @@ -59,14 +59,14 @@ func TestCreateSubscriptions(t *testing.T) { mockSubscriptoins := []webhooks.Subscription{ { - Active: true, - Name: "eventsandstuff", - Url: "https://thing.com/asdf/asdf/asdf", + Active: true, + Name: "eventsandstuff", + Url: "https://thing.com/asdf/asdf/asdf", }, { - Active: true, - Name: "eventsandstuff", - Url: "https://thing.com/asdf/asdf/asdf", + Active: true, + Name: "eventsandstuff", + Url: "https://thing.com/asdf/asdf/asdf", }, } @@ -75,5 +75,4 @@ func TestCreateSubscriptions(t *testing.T) { t.Fatal(err) } - } diff --git a/service/vendors/youtube/youtube.go b/service/vendors/youtube/youtube.go index ed3fbff..b93b023 100644 --- a/service/vendors/youtube/youtube.go +++ b/service/vendors/youtube/youtube.go @@ -9,7 +9,7 @@ import ( const ( STATUS_PRIVATE = "private" STATUS_PUBLIC = "public" - ISO_8601 = "2006-01-02T15:04:05.000Z" + ISO_8601 = "2006-01-02T15:04:05.000Z" ) // Inserts Broadcast into youtube @@ -26,7 +26,7 @@ func InsertBroadcast(service *youtube.Service, title string, startTime time.Time return service.LiveBroadcasts.Insert([]string{"snippet", "status"}, liveBroadcast).Do() } -//given a broadcast ID update the broadcast +// given a broadcast ID update the broadcast func UpdateBroadcast(service *youtube.Service, id, title string, startTime time.Time, privacyStatus string) (*youtube.LiveBroadcast, error) { liveBroadcast := &youtube.LiveBroadcast{ Id: id, diff --git a/ui/controllers/actions.go b/ui/controllers/actions.go index 9b308f2..82afe9b 100644 --- a/ui/controllers/actions.go +++ b/ui/controllers/actions.go @@ -147,7 +147,7 @@ func setupPcoSubscriptions(user *models.User) error { for index := range builtHooks { err = pcoApi.CreateSubscription(&builtHooks[index]) if err != nil { - return errors.Join(fmt.Errorf("Failed to create subscription: %s for user: %s", builtHooks[index].Name ,user.Id), err) + return errors.Join(fmt.Errorf("Failed to create subscription: %s for user: %s", builtHooks[index].Name, user.Id), err) } } diff --git a/ui/controllers/controllers.go b/ui/controllers/controllers.go index d4859e1..cfe4dcc 100644 --- a/ui/controllers/controllers.go +++ b/ui/controllers/controllers.go @@ -22,7 +22,7 @@ func BuildRouter(r *gin.Engine) { log = logrus.New() log.SetFormatter(&logrus.TextFormatter{ - DisableColors: true, + DisableColors: true, }) log.SetLevel(logrus.DebugLevel) diff --git a/ui/db/audit.go b/ui/db/audit.go index 35a79bc..45fd905 100644 --- a/ui/db/audit.go +++ b/ui/db/audit.go @@ -76,4 +76,6 @@ func (db *DB) FindAuditTrailForUser(userId primitive.ObjectID) ([]models.EventRe return events, actions, nil } -func (db *DB) FindEventRecievedByVendorId(id string) ([]models.EventRecieved) {return []models.EventRecieved{}} +func (db *DB) FindEventRecievedByVendorId(id string) []models.EventRecieved { + return []models.EventRecieved{} +} diff --git a/ui/db/models/audit.go b/ui/db/models/audit.go index 17d9329..aa948e7 100644 --- a/ui/db/models/audit.go +++ b/ui/db/models/audit.go @@ -43,11 +43,11 @@ func (obj *EventRecieved) UpdateObjectInfo() { // Action Taken type ActionTaken struct { *CommonFields `bson:"obj_info"` - Id primitive.ObjectID `bson:"_id,omitempty"` - UserId primitive.ObjectID `bson:"user_id,omitempty"` //what user is this associated too - TriggeringEvent primitive.ObjectID `bson:"triggering_event,omitempty"` //what triggered this action to be taken - Result string `bson:"result,omitempty"` //list of entities effected or created from action - VendorName string `bson:"vendor_name,omitempty"` //Vendor name that the action was taken against + Id primitive.ObjectID `bson:"_id,omitempty"` + UserId primitive.ObjectID `bson:"user_id,omitempty"` //what user is this associated too + TriggeringEvent primitive.ObjectID `bson:"triggering_event,omitempty"` //what triggered this action to be taken + Result string `bson:"result,omitempty"` //list of entities effected or created from action + VendorName string `bson:"vendor_name,omitempty"` //Vendor name that the action was taken against } func (obj *ActionTaken) MongoId() primitive.ObjectID { diff --git a/versions.json b/versions.json index 18102dc..e20b4d5 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,4 @@ { - "webhook_version": "0.0.59", + "webhook_version": "0.0.60", "frontend_version": "0.0.40" }