B: gofmt
This commit is contained in:
parent
f703f2d1ab
commit
6f1ce7dcc1
|
@ -8,7 +8,7 @@ import (
|
|||
"github.com/google/jsonapi"
|
||||
)
|
||||
|
||||
func (api *PcoApiClient) GetPlan(service_type_id, plan_id string) (*services.Plan, error){
|
||||
func (api *PcoApiClient) GetPlan(service_type_id, plan_id string) (*services.Plan, error) {
|
||||
api.Url().Path = fmt.Sprintf("/services/v2/service_types/%s/plans/%s", service_type_id, plan_id)
|
||||
|
||||
req, err := http.NewRequest(http.MethodGet, api.Url().String(), nil)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package services
|
||||
|
||||
|
||||
type Series struct {
|
||||
Id string `jsonapi:"primary,Series"`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package services
|
||||
|
||||
|
||||
type ServiceType struct {
|
||||
Id string `jsonapi:"primary,ServiceType"`
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/google/jsonapi"
|
||||
)
|
||||
|
||||
//Structure delivered to target when sending webhooks
|
||||
// Structure delivered to target when sending webhooks
|
||||
type EventDelivery struct {
|
||||
//uuid of the EventDelivery
|
||||
ID string `jsonapi:"primary,EventDelivery"`
|
||||
|
@ -22,7 +22,7 @@ type EventDelivery struct {
|
|||
Organization *services.Organization `jsonapi:"relation,organization"`
|
||||
}
|
||||
|
||||
//Unmarshall payload of EventDelivery into the struct you think it is
|
||||
// Unmarshall payload of EventDelivery into the struct you think it is
|
||||
func (event *EventDelivery) UnmarshallPayload(obj any) error {
|
||||
return jsonapi.UnmarshalPayload(strings.NewReader(event.Payload), obj)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ const (
|
|||
STATUS_PUBLIC = "public"
|
||||
)
|
||||
|
||||
//Inserts Broadcast into youtube
|
||||
// Inserts Broadcast into youtube
|
||||
func InsertBroadcast(service *youtube.Service, title string, startTime time.Time, privacyStatus string) (*youtube.LiveBroadcast, error) {
|
||||
liveBroadcast := &youtube.LiveBroadcast{
|
||||
Snippet: &youtube.LiveBroadcastSnippet{
|
||||
|
|
|
@ -146,7 +146,6 @@ func LoginHandler(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
|
||||
if user == nil {
|
||||
log.Warnf("No user was found for: %s", reqBody.Email)
|
||||
renderTempl(c, templates.LoginPage(fmt.Sprintf("No user found for %s", reqBody.Email)))
|
||||
|
|
|
@ -46,12 +46,12 @@ func DashboardPage(c *gin.Context) {
|
|||
waitGroup := new(sync.WaitGroup)
|
||||
waitGroup.Add(2)
|
||||
|
||||
go func(wg *sync.WaitGroup){
|
||||
go func(wg *sync.WaitGroup) {
|
||||
vendors, errs[0] = mongo.FindAllVendorAccountsByUser(user.MongoId())
|
||||
wg.Done()
|
||||
}(waitGroup)
|
||||
|
||||
go func(wg *sync.WaitGroup){
|
||||
go func(wg *sync.WaitGroup) {
|
||||
actions, errs[1] = mongo.FindActionMappingsByUser(user.MongoId())
|
||||
wg.Done()
|
||||
}(waitGroup)
|
||||
|
@ -68,6 +68,5 @@ func DashboardPage(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
renderTempl(c, templates.DashboardPage(user, vendors, actions))
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ func RecievePCOOuath(c *gin.Context) {
|
|||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
log.Errorf("Response failed with status code: %d. Error: %s", resp.StatusCode ,string(rawBody))
|
||||
log.Errorf("Response failed with status code: %d. Error: %s", resp.StatusCode, string(rawBody))
|
||||
c.AbortWithStatus(502)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -106,12 +106,11 @@ func ReceiveYoutubeOauth(c *gin.Context) {
|
|||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
log.Errorf("Response failed with status code: %d. Error: %s", resp.StatusCode ,string(rawBody))
|
||||
log.Errorf("Response failed with status code: %d. Error: %s", resp.StatusCode, string(rawBody))
|
||||
c.AbortWithStatus(502)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
oauthResp := &models.OauthCredential{}
|
||||
err = json.Unmarshal(rawBody, oauthResp)
|
||||
if err != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
//Interface for any object that wants to take advantage of the DB package
|
||||
// Interface for any object that wants to take advantage of the DB package
|
||||
type Model interface {
|
||||
|
||||
//Should return the _id field of the object if it exits
|
||||
|
@ -35,7 +35,7 @@ func NewClient(uri string) (*DB, error) {
|
|||
return &DB{client: client}, nil
|
||||
}
|
||||
|
||||
//Upserts
|
||||
// Upserts
|
||||
func (db *DB) SaveModel(m Model) error {
|
||||
conf := config.Config()
|
||||
|
||||
|
@ -81,7 +81,7 @@ func (db *DB) SaveModels(m ...Model) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//Doesn't upsert
|
||||
// Doesn't upsert
|
||||
func (db *DB) InsertModel(m Model) error {
|
||||
conf := config.Config()
|
||||
|
||||
|
|
|
@ -50,5 +50,3 @@ func (va *VendorAccount) Token() *oauth2.Token {
|
|||
Expiry: va.OauthCredentials.ExpiresAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -90,10 +90,10 @@ func (ts *VendorTokenSource) Token() (*oauth2.Token, error) {
|
|||
return token, nil
|
||||
}
|
||||
|
||||
//Allow us to check for kind of error at the end
|
||||
// Allow us to check for kind of error at the end
|
||||
var TokenWaitExpired error = errors.New("Waiting for token to refresh took too long")
|
||||
|
||||
//Used to extract the token lock that was updated when the change stream alerts
|
||||
// Used to extract the token lock that was updated when the change stream alerts
|
||||
type tokenLockChangeEvent struct {
|
||||
TokenLock *models.TokenLock `bson:"fullDocument"`
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ func TestRefreshToken(t *testing.T) {
|
|||
wg := new(sync.WaitGroup)
|
||||
wg.Add(2)
|
||||
|
||||
go func(tkr oauth2.TokenSource, wg *sync.WaitGroup){
|
||||
go func(tkr oauth2.TokenSource, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
var err error
|
||||
tk1, err = tkr.Token()
|
||||
|
@ -84,7 +84,7 @@ func TestRefreshToken(t *testing.T) {
|
|||
}
|
||||
}(tkr1, wg)
|
||||
|
||||
go func(tkr oauth2.TokenSource, wg *sync.WaitGroup){
|
||||
go func(tkr oauth2.TokenSource, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
var err error
|
||||
tk2, err = tkr.Token()
|
||||
|
@ -92,7 +92,7 @@ func TestRefreshToken(t *testing.T) {
|
|||
t.Errorf("got err = %v; want none", err)
|
||||
return
|
||||
}
|
||||
}(tkr2,wg)
|
||||
}(tkr2, wg)
|
||||
|
||||
wg.Wait()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
//seraches for a single user by email address
|
||||
// seraches for a single user by email address
|
||||
func (db *DB) FindUserByEmail(email string) (*models.User, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
@ -34,7 +34,7 @@ func (db *DB) FindUserByEmail(email string) (*models.User, error) {
|
|||
return user, nil
|
||||
}
|
||||
|
||||
//find user by its unique id
|
||||
// find user by its unique id
|
||||
func (db *DB) FindUserById(id string) (*models.User, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
@ -44,7 +44,7 @@ func (db *DB) FindUserById(id string) (*models.User, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
res := db.client.Database(conf.Mongo.EntDb).Collection(conf.Mongo.EntCol).FindOne(context.Background(), bson.M{"_id": objId , "obj_info.ent": models.USER_TYPE}, opts)
|
||||
res := db.client.Database(conf.Mongo.EntDb).Collection(conf.Mongo.EntCol).FindOne(context.Background(), bson.M{"_id": objId, "obj_info.ent": models.USER_TYPE}, opts)
|
||||
|
||||
if res.Err() != nil {
|
||||
if res.Err() == mongo.ErrNoDocuments {
|
||||
|
@ -62,7 +62,7 @@ func (db *DB) FindUserById(id string) (*models.User, error) {
|
|||
return user, nil
|
||||
}
|
||||
|
||||
//returns all users
|
||||
// returns all users
|
||||
func (db *DB) FindAllUsers() ([]models.User, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
//return all vendor accounts for a user
|
||||
// return all vendor accounts for a user
|
||||
func (db *DB) FindAllVendorAccountsByUser(userId primitive.ObjectID) ([]models.VendorAccount, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
@ -33,7 +33,7 @@ func (db *DB) FindAllVendorAccountsByUser(userId primitive.ObjectID) ([]models.V
|
|||
return vendors, nil
|
||||
}
|
||||
|
||||
//find vendor for user by name
|
||||
// find vendor for user by name
|
||||
func (db *DB) FindVendorAccountByUser(userId primitive.ObjectID, name string) (*models.VendorAccount, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
@ -55,7 +55,7 @@ func (db *DB) FindVendorAccountByUser(userId primitive.ObjectID, name string) (*
|
|||
return vendor, nil
|
||||
}
|
||||
|
||||
//find vendoraccount by its unique id
|
||||
// find vendoraccount by its unique id
|
||||
func (db *DB) FindVendorAccountById(vendorId primitive.ObjectID) (*models.VendorAccount, error) {
|
||||
conf := config.Config()
|
||||
|
||||
|
|
Loading…
Reference in New Issue