fix: queries for webhooks + improve tests

This commit is contained in:
Lakhan Samani
2023-03-29 07:06:33 +05:30
parent a38e9d4e6c
commit e822b6f31a
45 changed files with 213 additions and 138 deletions

View File

@@ -34,18 +34,12 @@ func (w *Webhook) AsAPIWebhook() *model.Webhook {
if strings.Contains(id, Collections.Webhook+"/") {
id = strings.TrimPrefix(id, Collections.Webhook+"/")
}
// If event name contains timestamp trim that part
if strings.Contains(w.EventName, "-") {
splitData := strings.Split(w.EventName, "-")
w.EventName = splitData[0]
}
// set default title to event name without dot(.)
if w.EventDescription == "" {
w.EventDescription = strings.Join(strings.Split(w.EventName, "."), " ")
}
return &model.Webhook{
ID: id,
// Title: refs.NewStringRef(w.EventDescription),
ID: id,
EventName: refs.NewStringRef(w.EventName),
Endpoint: refs.NewStringRef(w.EndPoint),
Headers: headersMap,