fix: rename title -> event_description
This commit is contained in:
parent
deaf1e2ff7
commit
a38e9d4e6c
|
@ -15,15 +15,15 @@ import (
|
|||
|
||||
// Webhook model for db
|
||||
type Webhook struct {
|
||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name" dynamo:"event_name" index:"event_name,hash"`
|
||||
Title string `json:"title" bson:"title" cql:"title" dynamo:"title"`
|
||||
EndPoint string `json:"endpoint" bson:"endpoint" cql:"endpoint" dynamo:"endpoint"`
|
||||
Headers string `json:"headers" bson:"headers" cql:"headers" dynamo:"headers"`
|
||||
Enabled bool `json:"enabled" bson:"enabled" cql:"enabled" dynamo:"enabled"`
|
||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||
Key string `json:"_key,omitempty" bson:"_key,omitempty" cql:"_key,omitempty" dynamo:"key,omitempty"` // for arangodb
|
||||
ID string `gorm:"primaryKey;type:char(36)" json:"_id" bson:"_id" cql:"id" dynamo:"id,hash"`
|
||||
EventName string `gorm:"unique" json:"event_name" bson:"event_name" cql:"event_name" dynamo:"event_name" index:"event_name,hash"`
|
||||
EventDescription string `json:"event_description" bson:"event_description" cql:"event_description" dynamo:"event_description"`
|
||||
EndPoint string `json:"endpoint" bson:"endpoint" cql:"endpoint" dynamo:"endpoint"`
|
||||
Headers string `json:"headers" bson:"headers" cql:"headers" dynamo:"headers"`
|
||||
Enabled bool `json:"enabled" bson:"enabled" cql:"enabled" dynamo:"enabled"`
|
||||
CreatedAt int64 `json:"created_at" bson:"created_at" cql:"created_at" dynamo:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at" bson:"updated_at" cql:"updated_at" dynamo:"updated_at"`
|
||||
}
|
||||
|
||||
// AsAPIWebhook to return webhook as graphql response object
|
||||
|
@ -40,12 +40,12 @@ func (w *Webhook) AsAPIWebhook() *model.Webhook {
|
|||
w.EventName = splitData[0]
|
||||
}
|
||||
// set default title to event name without dot(.)
|
||||
if w.Title == "" {
|
||||
w.Title = strings.Join(strings.Split(w.EventName, "."), " ")
|
||||
if w.EventDescription == "" {
|
||||
w.EventDescription = strings.Join(strings.Split(w.EventName, "."), " ")
|
||||
}
|
||||
return &model.Webhook{
|
||||
ID: id,
|
||||
Title: refs.NewStringRef(w.Title),
|
||||
ID: id,
|
||||
// Title: refs.NewStringRef(w.EventDescription),
|
||||
EventName: refs.NewStringRef(w.EventName),
|
||||
Endpoint: refs.NewStringRef(w.EndPoint),
|
||||
Headers: headersMap,
|
||||
|
|
|
@ -20,8 +20,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
}
|
||||
webhook.Key = webhook.ID
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
|
|
@ -22,12 +22,12 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
insertQuery := fmt.Sprintf("INSERT INTO %s (id, title, event_name, endpoint, headers, enabled, created_at, updated_at) VALUES ('%s', '%s', '%s', '%s', '%s', %t, %d, %d)", KeySpace+"."+models.Collections.Webhook, webhook.ID, webhook.Title, webhook.EventName, webhook.EndPoint, webhook.Headers, webhook.Enabled, webhook.CreatedAt, webhook.UpdatedAt)
|
||||
insertQuery := fmt.Sprintf("INSERT INTO %s (id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at) VALUES ('%s', '%s', '%s', '%s', '%s', %t, %d, %d)", KeySpace+"."+models.Collections.Webhook, webhook.ID, webhook.EventDescription, webhook.EventName, webhook.EndPoint, webhook.Headers, webhook.Enabled, webhook.CreatedAt, webhook.UpdatedAt)
|
||||
err := p.db.Query(insertQuery).Exec()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -95,13 +95,13 @@ func (p *provider) ListWebhook(ctx context.Context, pagination model.Pagination)
|
|||
// there is no offset in cassandra
|
||||
// so we fetch till limit + offset
|
||||
// and return the results from offset to limit
|
||||
query := fmt.Sprintf("SELECT id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s LIMIT %d", KeySpace+"."+models.Collections.Webhook, pagination.Limit+pagination.Offset)
|
||||
query := fmt.Sprintf("SELECT id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s LIMIT %d", KeySpace+"."+models.Collections.Webhook, pagination.Limit+pagination.Offset)
|
||||
scanner := p.db.Query(query).Iter().Scanner()
|
||||
counter := int64(0)
|
||||
for scanner.Next() {
|
||||
if counter >= pagination.Offset {
|
||||
var webhook models.Webhook
|
||||
err := scanner.Scan(&webhook.ID, &webhook.Title, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
err := scanner.Scan(&webhook.ID, &webhook.EventDescription, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ func (p *provider) ListWebhook(ctx context.Context, pagination model.Pagination)
|
|||
// GetWebhookByID to get webhook by id
|
||||
func (p *provider) GetWebhookByID(ctx context.Context, webhookID string) (*model.Webhook, error) {
|
||||
var webhook models.Webhook
|
||||
query := fmt.Sprintf(`SELECT id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s WHERE id = '%s' LIMIT 1`, KeySpace+"."+models.Collections.Webhook, webhookID)
|
||||
err := p.db.Query(query).Consistency(gocql.One).Scan(&webhook.ID, &webhook.Title, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
query := fmt.Sprintf(`SELECT id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s WHERE id = '%s' LIMIT 1`, KeySpace+"."+models.Collections.Webhook, webhookID)
|
||||
err := p.db.Query(query).Consistency(gocql.One).Scan(&webhook.ID, &webhook.EventDescription, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -129,12 +129,12 @@ func (p *provider) GetWebhookByID(ctx context.Context, webhookID string) (*model
|
|||
|
||||
// GetWebhookByEventName to get webhook by event_name
|
||||
func (p *provider) GetWebhookByEventName(ctx context.Context, eventName string) ([]*model.Webhook, error) {
|
||||
query := fmt.Sprintf(`SELECT id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s WHERE event_name LIKE '%s' ALLOW FILTERING`, KeySpace+"."+models.Collections.Webhook, eventName+"%s")
|
||||
query := fmt.Sprintf(`SELECT id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s WHERE event_name LIKE '%s' ALLOW FILTERING`, KeySpace+"."+models.Collections.Webhook, eventName+"%s")
|
||||
scanner := p.db.Query(query).Iter().Scanner()
|
||||
webhooks := []*model.Webhook{}
|
||||
for scanner.Next() {
|
||||
var webhook models.Webhook
|
||||
err := scanner.Scan(&webhook.ID, &webhook.Title, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
err := scanner.Scan(&webhook.ID, &webhook.EventDescription, &webhook.EventName, &webhook.EndPoint, &webhook.Headers, &webhook.Enabled, &webhook.CreatedAt, &webhook.UpdatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
@ -82,7 +82,7 @@ func (p *provider) ListWebhook(ctx context.Context, pagination model.Pagination)
|
|||
return nil, err
|
||||
}
|
||||
paginationClone.Total = total
|
||||
query := fmt.Sprintf("SELECT _id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s OFFSET $offset LIMIT $limit", p.scopeName, models.Collections.Webhook)
|
||||
query := fmt.Sprintf("SELECT _id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s OFFSET $offset LIMIT $limit", p.scopeName, models.Collections.Webhook)
|
||||
queryResult, err := p.db.Query(query, &gocb.QueryOptions{
|
||||
Context: ctx,
|
||||
ScanConsistency: gocb.QueryScanConsistencyRequestPlus,
|
||||
|
@ -112,7 +112,7 @@ func (p *provider) GetWebhookByID(ctx context.Context, webhookID string) (*model
|
|||
var webhook models.Webhook
|
||||
params := make(map[string]interface{}, 1)
|
||||
params["_id"] = webhookID
|
||||
query := fmt.Sprintf(`SELECT _id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s WHERE _id=$_id LIMIT 1`, p.scopeName, models.Collections.Webhook)
|
||||
query := fmt.Sprintf(`SELECT _id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s WHERE _id=$_id LIMIT 1`, p.scopeName, models.Collections.Webhook)
|
||||
q, err := p.db.Query(query, &gocb.QueryOptions{
|
||||
Context: ctx,
|
||||
ScanConsistency: gocb.QueryScanConsistencyRequestPlus,
|
||||
|
@ -132,7 +132,7 @@ func (p *provider) GetWebhookByID(ctx context.Context, webhookID string) (*model
|
|||
func (p *provider) GetWebhookByEventName(ctx context.Context, eventName string) ([]*model.Webhook, error) {
|
||||
params := make(map[string]interface{}, 1)
|
||||
params["event_name"] = eventName + "%"
|
||||
query := fmt.Sprintf(`SELECT _id, title, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s WHERE event_name LIKE $event_name`, p.scopeName, models.Collections.Webhook)
|
||||
query := fmt.Sprintf(`SELECT _id, event_description, event_name, endpoint, headers, enabled, created_at, updated_at FROM %s.%s WHERE event_name LIKE $event_name`, p.scopeName, models.Collections.Webhook)
|
||||
queryResult, err := p.db.Query(query, &gocb.QueryOptions{
|
||||
Context: ctx,
|
||||
ScanConsistency: gocb.QueryScanConsistencyRequestPlus,
|
||||
|
|
|
@ -23,8 +23,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
|
|
@ -21,8 +21,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
|
|
@ -19,8 +19,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
|
|
@ -19,8 +19,8 @@ func (p *provider) AddWebhook(ctx context.Context, webhook models.Webhook) (*mod
|
|||
webhook.Key = webhook.ID
|
||||
webhook.CreatedAt = time.Now().Unix()
|
||||
webhook.UpdatedAt = time.Now().Unix()
|
||||
if webhook.Title == "" {
|
||||
webhook.Title = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
if webhook.EventDescription == "" {
|
||||
webhook.EventDescription = strings.Join(strings.Split(webhook.EventName, "."), " ")
|
||||
}
|
||||
// Add timestamp to make event name unique for legacy version
|
||||
webhook.EventName = fmt.Sprintf("%s-%d", webhook.EventName, time.Now().Unix())
|
||||
|
|
|
@ -275,14 +275,14 @@ type ComplexityRoot struct {
|
|||
}
|
||||
|
||||
Webhook struct {
|
||||
CreatedAt func(childComplexity int) int
|
||||
Enabled func(childComplexity int) int
|
||||
Endpoint func(childComplexity int) int
|
||||
EventName func(childComplexity int) int
|
||||
Headers func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
Title func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
CreatedAt func(childComplexity int) int
|
||||
Enabled func(childComplexity int) int
|
||||
Endpoint func(childComplexity int) int
|
||||
EventDescription func(childComplexity int) int
|
||||
EventName func(childComplexity int) int
|
||||
Headers func(childComplexity int) int
|
||||
ID func(childComplexity int) int
|
||||
UpdatedAt func(childComplexity int) int
|
||||
}
|
||||
|
||||
WebhookLog struct {
|
||||
|
@ -1834,6 +1834,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||
|
||||
return e.complexity.Webhook.Endpoint(childComplexity), true
|
||||
|
||||
case "Webhook.event_description":
|
||||
if e.complexity.Webhook.EventDescription == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Webhook.EventDescription(childComplexity), true
|
||||
|
||||
case "Webhook.event_name":
|
||||
if e.complexity.Webhook.EventName == nil {
|
||||
break
|
||||
|
@ -1855,13 +1862,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
|||
|
||||
return e.complexity.Webhook.ID(childComplexity), true
|
||||
|
||||
case "Webhook.title":
|
||||
if e.complexity.Webhook.Title == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.Webhook.Title(childComplexity), true
|
||||
|
||||
case "Webhook.updated_at":
|
||||
if e.complexity.Webhook.UpdatedAt == nil {
|
||||
break
|
||||
|
@ -2218,8 +2218,8 @@ type GenerateJWTKeysResponse {
|
|||
|
||||
type Webhook {
|
||||
id: ID!
|
||||
title: String
|
||||
event_name: String
|
||||
event_description: String
|
||||
endpoint: String
|
||||
enabled: Boolean
|
||||
headers: Map
|
||||
|
@ -2509,8 +2509,8 @@ input ListWebhookLogRequest {
|
|||
}
|
||||
|
||||
input AddWebhookRequest {
|
||||
title: String!
|
||||
event_name: String!
|
||||
event_description: String
|
||||
endpoint: String!
|
||||
enabled: Boolean!
|
||||
headers: Map
|
||||
|
@ -2518,8 +2518,8 @@ input AddWebhookRequest {
|
|||
|
||||
input UpdateWebhookRequest {
|
||||
id: ID!
|
||||
title: String
|
||||
event_name: String
|
||||
event_description: String
|
||||
endpoint: String
|
||||
enabled: Boolean
|
||||
headers: Map
|
||||
|
@ -10152,10 +10152,10 @@ func (ec *executionContext) fieldContext_Query__webhook(ctx context.Context, fie
|
|||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Webhook_id(ctx, field)
|
||||
case "title":
|
||||
return ec.fieldContext_Webhook_title(ctx, field)
|
||||
case "event_name":
|
||||
return ec.fieldContext_Webhook_event_name(ctx, field)
|
||||
case "event_description":
|
||||
return ec.fieldContext_Webhook_event_description(ctx, field)
|
||||
case "endpoint":
|
||||
return ec.fieldContext_Webhook_endpoint(ctx, field)
|
||||
case "enabled":
|
||||
|
@ -12173,47 +12173,6 @@ func (ec *executionContext) fieldContext_Webhook_id(ctx context.Context, field g
|
|||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Webhook_title(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Webhook_title(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.Title, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*string)
|
||||
fc.Result = res
|
||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Webhook_title(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Webhook",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type String does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Webhook_event_name(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Webhook_event_name(ctx, field)
|
||||
if err != nil {
|
||||
|
@ -12255,6 +12214,47 @@ func (ec *executionContext) fieldContext_Webhook_event_name(ctx context.Context,
|
|||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Webhook_event_description(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Webhook_event_description(ctx, field)
|
||||
if err != nil {
|
||||
return graphql.Null
|
||||
}
|
||||
ctx = graphql.WithFieldContext(ctx, fc)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
ec.Error(ctx, ec.Recover(ctx, r))
|
||||
ret = graphql.Null
|
||||
}
|
||||
}()
|
||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||
ctx = rctx // use context from middleware stack in children
|
||||
return obj.EventDescription, nil
|
||||
})
|
||||
if err != nil {
|
||||
ec.Error(ctx, err)
|
||||
return graphql.Null
|
||||
}
|
||||
if resTmp == nil {
|
||||
return graphql.Null
|
||||
}
|
||||
res := resTmp.(*string)
|
||||
fc.Result = res
|
||||
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||
}
|
||||
|
||||
func (ec *executionContext) fieldContext_Webhook_event_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
|
||||
fc = &graphql.FieldContext{
|
||||
Object: "Webhook",
|
||||
Field: field,
|
||||
IsMethod: false,
|
||||
IsResolver: false,
|
||||
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
|
||||
return nil, errors.New("field of type String does not have child fields")
|
||||
},
|
||||
}
|
||||
return fc, nil
|
||||
}
|
||||
|
||||
func (ec *executionContext) _Webhook_endpoint(ctx context.Context, field graphql.CollectedField, obj *model.Webhook) (ret graphql.Marshaler) {
|
||||
fc, err := ec.fieldContext_Webhook_endpoint(ctx, field)
|
||||
if err != nil {
|
||||
|
@ -12959,10 +12959,10 @@ func (ec *executionContext) fieldContext_Webhooks_webhooks(ctx context.Context,
|
|||
switch field.Name {
|
||||
case "id":
|
||||
return ec.fieldContext_Webhook_id(ctx, field)
|
||||
case "title":
|
||||
return ec.fieldContext_Webhook_title(ctx, field)
|
||||
case "event_name":
|
||||
return ec.fieldContext_Webhook_event_name(ctx, field)
|
||||
case "event_description":
|
||||
return ec.fieldContext_Webhook_event_description(ctx, field)
|
||||
case "endpoint":
|
||||
return ec.fieldContext_Webhook_endpoint(ctx, field)
|
||||
case "enabled":
|
||||
|
@ -14812,21 +14812,13 @@ func (ec *executionContext) unmarshalInputAddWebhookRequest(ctx context.Context,
|
|||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"title", "event_name", "endpoint", "enabled", "headers"}
|
||||
fieldsInOrder := [...]string{"event_name", "event_description", "endpoint", "enabled", "headers"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
switch k {
|
||||
case "title":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title"))
|
||||
it.Title, err = ec.unmarshalNString2string(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "event_name":
|
||||
var err error
|
||||
|
||||
|
@ -14835,6 +14827,14 @@ func (ec *executionContext) unmarshalInputAddWebhookRequest(ctx context.Context,
|
|||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "event_description":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("event_description"))
|
||||
it.EventDescription, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "endpoint":
|
||||
var err error
|
||||
|
||||
|
@ -16676,7 +16676,7 @@ func (ec *executionContext) unmarshalInputUpdateWebhookRequest(ctx context.Conte
|
|||
asMap[k] = v
|
||||
}
|
||||
|
||||
fieldsInOrder := [...]string{"id", "title", "event_name", "endpoint", "enabled", "headers"}
|
||||
fieldsInOrder := [...]string{"id", "event_name", "event_description", "endpoint", "enabled", "headers"}
|
||||
for _, k := range fieldsInOrder {
|
||||
v, ok := asMap[k]
|
||||
if !ok {
|
||||
|
@ -16691,14 +16691,6 @@ func (ec *executionContext) unmarshalInputUpdateWebhookRequest(ctx context.Conte
|
|||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "title":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("title"))
|
||||
it.Title, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "event_name":
|
||||
var err error
|
||||
|
||||
|
@ -16707,6 +16699,14 @@ func (ec *executionContext) unmarshalInputUpdateWebhookRequest(ctx context.Conte
|
|||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "event_description":
|
||||
var err error
|
||||
|
||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("event_description"))
|
||||
it.EventDescription, err = ec.unmarshalOString2ᚖstring(ctx, v)
|
||||
if err != nil {
|
||||
return it, err
|
||||
}
|
||||
case "endpoint":
|
||||
var err error
|
||||
|
||||
|
@ -18581,14 +18581,14 @@ func (ec *executionContext) _Webhook(ctx context.Context, sel ast.SelectionSet,
|
|||
if out.Values[i] == graphql.Null {
|
||||
invalids++
|
||||
}
|
||||
case "title":
|
||||
|
||||
out.Values[i] = ec._Webhook_title(ctx, field, obj)
|
||||
|
||||
case "event_name":
|
||||
|
||||
out.Values[i] = ec._Webhook_event_name(ctx, field, obj)
|
||||
|
||||
case "event_description":
|
||||
|
||||
out.Values[i] = ec._Webhook_event_description(ctx, field, obj)
|
||||
|
||||
case "endpoint":
|
||||
|
||||
out.Values[i] = ec._Webhook_endpoint(ctx, field, obj)
|
||||
|
|
|
@ -10,11 +10,11 @@ type AddEmailTemplateRequest struct {
|
|||
}
|
||||
|
||||
type AddWebhookRequest struct {
|
||||
Title string `json:"title"`
|
||||
EventName string `json:"event_name"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
EventName string `json:"event_name"`
|
||||
EventDescription *string `json:"event_description"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
}
|
||||
|
||||
type AdminLoginInput struct {
|
||||
|
@ -388,12 +388,12 @@ type UpdateUserInput struct {
|
|||
}
|
||||
|
||||
type UpdateWebhookRequest struct {
|
||||
ID string `json:"id"`
|
||||
Title *string `json:"title"`
|
||||
EventName *string `json:"event_name"`
|
||||
Endpoint *string `json:"endpoint"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
ID string `json:"id"`
|
||||
EventName *string `json:"event_name"`
|
||||
EventDescription *string `json:"event_description"`
|
||||
Endpoint *string `json:"endpoint"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
|
@ -463,14 +463,14 @@ type VerifyOTPRequest struct {
|
|||
}
|
||||
|
||||
type Webhook struct {
|
||||
ID string `json:"id"`
|
||||
Title *string `json:"title"`
|
||||
EventName *string `json:"event_name"`
|
||||
Endpoint *string `json:"endpoint"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
CreatedAt *int64 `json:"created_at"`
|
||||
UpdatedAt *int64 `json:"updated_at"`
|
||||
ID string `json:"id"`
|
||||
EventName *string `json:"event_name"`
|
||||
EventDescription *string `json:"event_description"`
|
||||
Endpoint *string `json:"endpoint"`
|
||||
Enabled *bool `json:"enabled"`
|
||||
Headers map[string]interface{} `json:"headers"`
|
||||
CreatedAt *int64 `json:"created_at"`
|
||||
UpdatedAt *int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
type WebhookLog struct {
|
||||
|
|
|
@ -168,8 +168,8 @@ type GenerateJWTKeysResponse {
|
|||
|
||||
type Webhook {
|
||||
id: ID!
|
||||
title: String
|
||||
event_name: String
|
||||
event_description: String
|
||||
endpoint: String
|
||||
enabled: Boolean
|
||||
headers: Map
|
||||
|
@ -459,8 +459,8 @@ input ListWebhookLogRequest {
|
|||
}
|
||||
|
||||
input AddWebhookRequest {
|
||||
title: String!
|
||||
event_name: String!
|
||||
event_description: String
|
||||
endpoint: String!
|
||||
enabled: Boolean!
|
||||
headers: Map
|
||||
|
@ -468,8 +468,8 @@ input AddWebhookRequest {
|
|||
|
||||
input UpdateWebhookRequest {
|
||||
id: ID!
|
||||
title: String
|
||||
event_name: String
|
||||
event_description: String
|
||||
endpoint: String
|
||||
enabled: Boolean
|
||||
headers: Map
|
||||
|
|
|
@ -2,7 +2,7 @@ package handlers
|
|||
|
||||
import (
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
graph "github.com/authorizerdev/authorizer/server/graph"
|
||||
"github.com/authorizerdev/authorizer/server/graph"
|
||||
"github.com/authorizerdev/authorizer/server/graph/generated"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/authorizerdev/authorizer/server/db"
|
||||
"github.com/authorizerdev/authorizer/server/db/models"
|
||||
"github.com/authorizerdev/authorizer/server/graph/model"
|
||||
"github.com/authorizerdev/authorizer/server/refs"
|
||||
"github.com/authorizerdev/authorizer/server/token"
|
||||
"github.com/authorizerdev/authorizer/server/utils"
|
||||
"github.com/authorizerdev/authorizer/server/validators"
|
||||
|
@ -44,10 +45,11 @@ func AddWebhookResolver(ctx context.Context, params model.AddWebhookRequest) (*m
|
|||
}
|
||||
|
||||
_, err = db.Provider.AddWebhook(ctx, models.Webhook{
|
||||
EventName: params.EventName,
|
||||
EndPoint: params.Endpoint,
|
||||
Enabled: params.Enabled,
|
||||
Headers: string(headerBytes),
|
||||
EventDescription: refs.StringValue(params.EventDescription),
|
||||
EventName: params.EventName,
|
||||
EndPoint: params.Endpoint,
|
||||
Enabled: params.Enabled,
|
||||
Headers: string(headerBytes),
|
||||
})
|
||||
if err != nil {
|
||||
log.Debug("Failed to add webhook: ", err)
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
func RegisterEvent(ctx context.Context, eventName string, authRecipe string, user models.User) error {
|
||||
webhooks, err := db.Provider.GetWebhookByEventName(ctx, eventName)
|
||||
if err != nil {
|
||||
log.Debug("Error getting webhook: %v", err)
|
||||
return err
|
||||
}
|
||||
for _, webhook := range webhooks {
|
||||
|
@ -38,6 +39,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
|
|||
}
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"webhook_id": webhook.ID,
|
||||
"event_name": eventName,
|
||||
"user": userMap,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user