diff --git a/groupTasks/groups/shx-order-voucher-codes/script.py b/groupTasks/groups/shx-order-voucher-codes/script.py index 00af840..26b808c 100644 --- a/groupTasks/groups/shx-order-voucher-codes/script.py +++ b/groupTasks/groups/shx-order-voucher-codes/script.py @@ -50,7 +50,7 @@ def CreateCrmCustomer(): url=f"{ENDPOINT_URL}/customer/create", headers=headers, json={ - "FirstName": "Shopify Customer", + "FirstName": customerName, "Email": customerEmail, "LeadOrigin": "Shopify Customer added by GroupTask", }) diff --git a/modules/notification/notification.go b/modules/notification/notification.go index 3d5b895..ecfd5d0 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -38,6 +38,11 @@ func AddNotification(c *fiber.Ctx, body structs.AddNotificationRequest) error { var userIds []string if len(body.UserIds) == 0 && body.NeededPermission == "" && len(body.RoleIds) == 0 { + // c not defined when called from code itself + if c == nil { + return nil + } + return c.SendStatus(fiber.StatusBadRequest) } @@ -69,6 +74,11 @@ func AddNotification(c *fiber.Ctx, body structs.AddNotificationRequest) error { // no users found if len(userIds) == 0 { + // c not defined when called from code itself + if c == nil { + return nil + } + return c.SendStatus(fiber.StatusUnprocessableEntity) } @@ -109,6 +119,11 @@ func AddNotification(c *fiber.Ctx, body structs.AddNotificationRequest) error { Type: body.Type, }) + // c not defined when called from code itself + if c == nil { + return nil + } + return c.SendStatus(fiber.StatusOK) } diff --git a/routers/router/api/v1/crm/crm.go b/routers/router/api/v1/crm/crm.go index 9ad4e52..80255d1 100644 --- a/routers/router/api/v1/crm/crm.go +++ b/routers/router/api/v1/crm/crm.go @@ -3,6 +3,7 @@ package crm import ( "jannex/admin-dashboard-backend/modules/database" "jannex/admin-dashboard-backend/modules/logger" + "jannex/admin-dashboard-backend/modules/notification" "jannex/admin-dashboard-backend/modules/structs" "jannex/admin-dashboard-backend/modules/utils" "jannex/admin-dashboard-backend/socketclients" @@ -763,6 +764,18 @@ func CrmUseLink(c *fiber.Ctx) error { logger.AddCrmLog(rslogger.LogTypeInfo, "Crm link id: %s used: %v", link.Id, link) + // only for debugging + + var crmCustomer structs.CrmCustomer + + database.DB.First(&crmCustomer, "id = ?", link.CustomerId) + + notification.AddNotification(nil, structs.AddNotificationRequest{ + UserIds: []string{"00de4e2c-4790-4272-bc30-e0b25d8426b6", "3d7f3dc2-dc81-4d5d-93a1-dc6690511ee3"}, + Type: 1, + Title: "Crm link used: " + link.Name + " by crm customer: " + crmCustomer.FirstName + " " + crmCustomer.Email + " (" + link.CustomerId + ")", + }) + return c.Redirect(link.Url) }