fix: cassandra + mongo + arangodb issues with webhook

This commit is contained in:
Lakhan Samani
2022-07-12 11:48:42 +05:30
parent bfbeb6add2
commit 6b57bce6d9
19 changed files with 167 additions and 94 deletions

View File

@@ -38,8 +38,13 @@ func (user *User) AsAPIUser() *model.User {
email := user.Email
createdAt := user.CreatedAt
updatedAt := user.UpdatedAt
id := user.ID
if strings.Contains(id, Collections.WebhookLog+"/") {
id = strings.TrimPrefix(id, Collections.WebhookLog+"/")
}
return &model.User{
ID: user.ID,
ID: id,
Email: user.Email,
EmailVerified: isEmailVerified,
SignupMethods: user.SignupMethods,

View File

@@ -1,6 +1,10 @@
package models
import "github.com/authorizerdev/authorizer/server/graph/model"
import (
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// Note: any change here should be reflected in providers/casandra/provider.go as it does not have model support in collection creation
@@ -27,8 +31,13 @@ func (v *VerificationRequest) AsAPIVerificationRequest() *model.VerificationRequ
redirectURI := v.RedirectURI
expires := v.ExpiresAt
identifier := v.Identifier
id := v.ID
if strings.Contains(id, Collections.WebhookLog+"/") {
id = strings.TrimPrefix(id, Collections.WebhookLog+"/")
}
return &model.VerificationRequest{
ID: v.ID,
ID: id,
Token: &token,
Identifier: &identifier,
Expires: &expires,

View File

@@ -2,6 +2,7 @@ package models
import (
"encoding/json"
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
)
@@ -23,8 +24,13 @@ type Webhook struct {
func (w *Webhook) AsAPIWebhook() *model.Webhook {
headersMap := make(map[string]interface{})
json.Unmarshal([]byte(w.Headers), &headersMap)
id := w.ID
if strings.Contains(id, Collections.Webhook+"/") {
id = strings.TrimPrefix(id, Collections.Webhook+"/")
}
return &model.Webhook{
ID: w.ID,
ID: id,
EventName: &w.EventName,
Endpoint: &w.EndPoint,
Headers: headersMap,

View File

@@ -1,6 +1,10 @@
package models
import "github.com/authorizerdev/authorizer/server/graph/model"
import (
"strings"
"github.com/authorizerdev/authorizer/server/graph/model"
)
// Note: any change here should be reflected in providers/casandra/provider.go as it does not have model support in collection creation
@@ -17,8 +21,12 @@ type WebhookLog struct {
}
func (w *WebhookLog) AsAPIWebhookLog() *model.WebhookLog {
id := w.ID
if strings.Contains(id, Collections.WebhookLog+"/") {
id = strings.TrimPrefix(id, Collections.WebhookLog+"/")
}
return &model.WebhookLog{
ID: w.ID,
ID: id,
HTTPStatus: &w.HttpStatus,
Response: &w.Response,
Request: &w.Request,