From 73824e6fb2a34a60b242613ddc99e23316dfb00d Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 27 May 2024 19:38:14 +0200 Subject: [PATCH] telegram notification --- .../api/v1/customerfeedback/customerfeedback.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/routers/router/api/v1/customerfeedback/customerfeedback.go b/routers/router/api/v1/customerfeedback/customerfeedback.go index 068e4ab..a0f3b30 100644 --- a/routers/router/api/v1/customerfeedback/customerfeedback.go +++ b/routers/router/api/v1/customerfeedback/customerfeedback.go @@ -1,8 +1,11 @@ package customerfeedback import ( + "encoding/json" + "jannex/admin-dashboard-backend/modules/config" "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" @@ -56,7 +59,17 @@ func CreateCustomerFeedback(c *fiber.Ctx) error { }}, ) - logger.AddSystemLog(rslogger.LogTypeInfo, "Received customer feedback origin: %s data: %s", query.Origin, body.Data) + jsonData, err := json.MarshalIndent(customerFeedback.Data, "", " ") + + if err == nil { + notification.AddNotification(nil, structs.AddNotificationRequest{ + UserIds: config.Cfg.NotificationUserIds, + Type: 1, + Title: "New customer feedback\n\norigin: " + query.Origin + "\ndata: " + string(jsonData), + }) + } + + logger.AddSystemLog(rslogger.LogTypeInfo, "New customer feedback origin: %s data: %s", query.Origin, body.Data) return c.SendStatus(fiber.StatusOK) }