formatting and update image

This commit is contained in:
Preston Baxter 2023-11-23 12:22:16 -06:00
parent 5f967bcde1
commit 9ad4170b82
13 changed files with 26 additions and 26 deletions

BIN
code.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 371 KiB

After

Width:  |  Height:  |  Size: 409 KiB

View File

@ -22,7 +22,7 @@ func BuildRouter(r *gin.Engine) {
log = logrus.New() log = logrus.New()
log.SetFormatter(&logrus.TextFormatter{ log.SetFormatter(&logrus.TextFormatter{
DisableColors: true, DisableColors: true,
}) })
log.SetLevel(logrus.DebugLevel) log.SetLevel(logrus.DebugLevel)

View File

@ -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 { func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery) error {
//get uid from context. Lots of sanitizing just incase //get uid from context. Lots of sanitizing just incase
uid := userIdFromContext(c) uid := userIdFromContext(c)
@ -278,7 +278,7 @@ func ScheduleBroadcastFromWebhook(c *gin.Context, body *webhooks.EventDelivery)
} }
//save audit trail //save audit trail
err = mongo.SaveModels( actionTaken) err = mongo.SaveModels(actionTaken)
if err != nil { if err != nil {
log.WithError(err).Error("Failed to save broadcastModel and actionTaken") log.WithError(err).Error("Failed to save broadcastModel and actionTaken")
return err return err

View File

@ -7,9 +7,9 @@ import (
) )
func TestPlanEventMatch(t *testing.T) { 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 { for _, event := range events {
assert.Equal(t, eventMatch("plan", event), true) assert.Equal(t, eventMatch("plan", event), true)
} }
} }

View File

@ -24,7 +24,6 @@ func (api *PcoApiClient) GetSubscriptions() ([]webhooks.Subscription, error) {
return nil, err return nil, err
} }
if resp.StatusCode > 299 || resp.StatusCode < 200 { if resp.StatusCode > 299 || resp.StatusCode < 200 {
if raw, err := io.ReadAll(resp.Body); err == nil { 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)) return nil, fmt.Errorf("Failed to retrieve subscriptions with status code: %d. Error %s", resp.StatusCode, string(raw))

View File

@ -6,7 +6,7 @@ type Subscription struct {
Id string `jsonapi:"primary,Subscription" bson:"id"` Id string `jsonapi:"primary,Subscription" bson:"id"`
//attrs //attrs
Active bool `jsonapi:"attr,active,omitempty" bson:"active"` 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"` AuthenticitySecret string `jsonapi:"attr,authenticity_secret,omitempty" bson:"authenticity_secret"`
CreatedAt time.Time `jsonapi:"attr,created_at,rfc3339,omitempty" bson:"created_at"` CreatedAt time.Time `jsonapi:"attr,created_at,rfc3339,omitempty" bson:"created_at"`
UpdatedAt time.Time `jsonapi:"attr,updated_at,rfc3339,omitempty" bson:"updated_at"` UpdatedAt time.Time `jsonapi:"attr,updated_at,rfc3339,omitempty" bson:"updated_at"`

View File

@ -23,7 +23,7 @@ var pcoMockAccount models.VendorAccount = models.VendorAccount{
TokenType: "bearer", TokenType: "bearer",
RefreshToken: "asdfas;lkdjfas;dlkfj;asdlkj;aslf", RefreshToken: "asdfas;lkdjfas;dlkfj;asdlkj;aslf",
}, },
Name: "pco", Name: "pco",
} }
func TestCreateSubscriptions(t *testing.T) { func TestCreateSubscriptions(t *testing.T) {
@ -59,14 +59,14 @@ func TestCreateSubscriptions(t *testing.T) {
mockSubscriptoins := []webhooks.Subscription{ mockSubscriptoins := []webhooks.Subscription{
{ {
Active: true, Active: true,
Name: "eventsandstuff", Name: "eventsandstuff",
Url: "https://thing.com/asdf/asdf/asdf", Url: "https://thing.com/asdf/asdf/asdf",
}, },
{ {
Active: true, Active: true,
Name: "eventsandstuff", Name: "eventsandstuff",
Url: "https://thing.com/asdf/asdf/asdf", Url: "https://thing.com/asdf/asdf/asdf",
}, },
} }
@ -75,5 +75,4 @@ func TestCreateSubscriptions(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
} }

View File

@ -9,7 +9,7 @@ import (
const ( const (
STATUS_PRIVATE = "private" STATUS_PRIVATE = "private"
STATUS_PUBLIC = "public" STATUS_PUBLIC = "public"
ISO_8601 = "2006-01-02T15:04:05.000Z" ISO_8601 = "2006-01-02T15:04:05.000Z"
) )
// Inserts Broadcast into youtube // 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() 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) { func UpdateBroadcast(service *youtube.Service, id, title string, startTime time.Time, privacyStatus string) (*youtube.LiveBroadcast, error) {
liveBroadcast := &youtube.LiveBroadcast{ liveBroadcast := &youtube.LiveBroadcast{
Id: id, Id: id,

View File

@ -147,7 +147,7 @@ func setupPcoSubscriptions(user *models.User) error {
for index := range builtHooks { for index := range builtHooks {
err = pcoApi.CreateSubscription(&builtHooks[index]) err = pcoApi.CreateSubscription(&builtHooks[index])
if err != nil { 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)
} }
} }

View File

@ -22,7 +22,7 @@ func BuildRouter(r *gin.Engine) {
log = logrus.New() log = logrus.New()
log.SetFormatter(&logrus.TextFormatter{ log.SetFormatter(&logrus.TextFormatter{
DisableColors: true, DisableColors: true,
}) })
log.SetLevel(logrus.DebugLevel) log.SetLevel(logrus.DebugLevel)

View File

@ -76,4 +76,6 @@ func (db *DB) FindAuditTrailForUser(userId primitive.ObjectID) ([]models.EventRe
return events, actions, nil 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{}
}

View File

@ -43,11 +43,11 @@ func (obj *EventRecieved) UpdateObjectInfo() {
// Action Taken // Action Taken
type ActionTaken struct { type ActionTaken struct {
*CommonFields `bson:"obj_info"` *CommonFields `bson:"obj_info"`
Id primitive.ObjectID `bson:"_id,omitempty"` Id primitive.ObjectID `bson:"_id,omitempty"`
UserId primitive.ObjectID `bson:"user_id,omitempty"` //what user is this associated too 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 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 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 VendorName string `bson:"vendor_name,omitempty"` //Vendor name that the action was taken against
} }
func (obj *ActionTaken) MongoId() primitive.ObjectID { func (obj *ActionTaken) MongoId() primitive.ObjectID {

View File

@ -1,4 +1,4 @@
{ {
"webhook_version": "0.0.59", "webhook_version": "0.0.60",
"frontend_version": "0.0.40" "frontend_version": "0.0.40"
} }