From 06d4f4b0fd453d75e3507890f1a3f162bac10c0a Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Fri, 16 Aug 2024 15:57:08 +0530 Subject: [PATCH 1/2] sending contact us email and details in discord channel --- apps/auth/internal/app/app.go | 10 +- apps/auth/internal/domain/domain.go | 1 - .../email-templates/contact-us/email.html | 182 ++++++++++++++++++ .../email-templates/contact-us/email.mjml | 35 ++++ .../email-templates/contact-us/email.txt | 10 + apps/comms/internal/app/grpc-server.go | 30 +++ apps/comms/internal/domain/mail-parser.go | 7 + apps/webhook/Taskfile.yml | 7 + apps/webhook/internal/app/app.go | 13 ++ apps/webhook/internal/app/git-webhook.go | 50 ++++- apps/webhook/internal/domain/api.go | 18 ++ apps/webhook/internal/domain/domain.go | 42 ++++ apps/webhook/internal/env/env.go | 3 + apps/webhook/internal/framework/main.go | 6 + go.mod | 1 - go.sum | 9 - grpc-interfaces/comms.proto | 10 + .../kloudlite.io/rpc/comms/comms.pb.go | 153 +++++++++++++-- .../kloudlite.io/rpc/comms/comms_grpc.pb.go | 37 ++++ 19 files changed, 588 insertions(+), 36 deletions(-) create mode 100644 apps/comms/email-templates/contact-us/email.html create mode 100644 apps/comms/email-templates/contact-us/email.mjml create mode 100644 apps/comms/email-templates/contact-us/email.txt create mode 100644 apps/webhook/internal/domain/api.go create mode 100644 apps/webhook/internal/domain/domain.go diff --git a/apps/auth/internal/app/app.go b/apps/auth/internal/app/app.go index a73d828f4..6a1efe60e 100644 --- a/apps/auth/internal/app/app.go +++ b/apps/auth/internal/app/app.go @@ -2,17 +2,12 @@ package app import ( "context" - "github.com/kloudlite/api/apps/auth/internal/entities" - "github.com/99designs/gqlgen/graphql" "github.com/gofiber/fiber/v2" - "github.com/kloudlite/api/pkg/nats" - "go.uber.org/fx" - "google.golang.org/grpc" - "github.com/kloudlite/api/apps/auth/internal/app/graph" "github.com/kloudlite/api/apps/auth/internal/app/graph/generated" "github.com/kloudlite/api/apps/auth/internal/domain" + "github.com/kloudlite/api/apps/auth/internal/entities" "github.com/kloudlite/api/apps/auth/internal/env" "github.com/kloudlite/api/common" "github.com/kloudlite/api/constants" @@ -20,7 +15,10 @@ import ( "github.com/kloudlite/api/grpc-interfaces/kloudlite.io/rpc/comms" httpServer "github.com/kloudlite/api/pkg/http-server" "github.com/kloudlite/api/pkg/kv" + "github.com/kloudlite/api/pkg/nats" "github.com/kloudlite/api/pkg/repos" + "go.uber.org/fx" + "google.golang.org/grpc" ) type CommsClientConnection *grpc.ClientConn diff --git a/apps/auth/internal/domain/domain.go b/apps/auth/internal/domain/domain.go index 7419a7bab..b752dd56a 100644 --- a/apps/auth/internal/domain/domain.go +++ b/apps/auth/internal/domain/domain.go @@ -3,7 +3,6 @@ package domain import ( "context" "github.com/kloudlite/api/apps/auth/internal/entities" - "github.com/kloudlite/api/common" "github.com/kloudlite/api/pkg/repos" ) diff --git a/apps/comms/email-templates/contact-us/email.html b/apps/comms/email-templates/contact-us/email.html new file mode 100644 index 000000000..a4a7b7c79 --- /dev/null +++ b/apps/comms/email-templates/contact-us/email.html @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + +
+ +
+ + + + + + + +
+ + + + + + +
+ +
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
+
Hello {{.Name}},
+
+
I’m Karthik, the founder of Kloudlite Inc and I’d like to personally thank you for contacting us.
+
+
We have received your details and our team will get back to you shortly.
+
+
I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help!
+
+
Best Regards,
+
+
Karthik
+
+
+ +
+
+ +
+ + + diff --git a/apps/comms/email-templates/contact-us/email.mjml b/apps/comms/email-templates/contact-us/email.mjml new file mode 100644 index 000000000..adaca51e4 --- /dev/null +++ b/apps/comms/email-templates/contact-us/email.mjml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + Hello {{.Name}}, + + + I’m Karthik, the founder of Kloudlite Inc and I’d like to personally thank you for contacting us. + + + We have received your details and our team will get back to you shortly. + + + I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help! + + + Best Regards, + + + Karthik + + + + + + diff --git a/apps/comms/email-templates/contact-us/email.txt b/apps/comms/email-templates/contact-us/email.txt new file mode 100644 index 000000000..ddd45ac84 --- /dev/null +++ b/apps/comms/email-templates/contact-us/email.txt @@ -0,0 +1,10 @@ +Hello {{.Name}}, + +I’m Karthik, the founder of Kloudlite Inc and I’d like to personally thank you for contacting us. + +We have received your details and our team will get back to you shortly. + +I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help! + +Best Regards, +Karthik diff --git a/apps/comms/internal/app/grpc-server.go b/apps/comms/internal/app/grpc-server.go index 9e9a88e64..c861d553c 100644 --- a/apps/comms/internal/app/grpc-server.go +++ b/apps/comms/internal/app/grpc-server.go @@ -206,6 +206,36 @@ func (r *commsSvc) SendVerificationEmail(ctx context.Context, input *comms.Verif } return &comms.Void{}, nil } + +func (r *commsSvc) SendContactUsEmail(ctx context.Context, input *comms.SendContactUsEmailInput) (*comms.Void, error) { + plainText := new(bytes.Buffer) + args := map[string]any{ + "Name": func() string { + if input.Name != "" { + return input.Name + } + return "there" + }(), + "CompanyName": input.CompanyName, + "Country": input.Country, + "Message": input.Message, + } + + if err := r.eTemplattes.ContactUsEmail.PlainText.Execute(plainText, args); err != nil { + return nil, errors.NewEf(err, "failed to execute plain text template") + } + + html := new(bytes.Buffer) + if err := r.eTemplattes.ContactUsEmail.Html.Execute(html, args); err != nil { + return nil, errors.NewEf(err, "failed to execute html template") + } + + if err := r.sendSupportEmail(ctx, r.eTemplattes.ContactUsEmail.Subject, input.Email, input.Name, plainText.String(), html.String()); err != nil { + return nil, errors.NewE(err) + } + return &comms.Void{}, nil +} + func newCommsSvc(mailer mail.Mailer, ev *env.Env, et *domain.EmailTemplates) comms.CommsServer { return &commsSvc{ mailer: mailer, diff --git a/apps/comms/internal/domain/mail-parser.go b/apps/comms/internal/domain/mail-parser.go index 5f4ad5a18..9a2deaa4f 100644 --- a/apps/comms/internal/domain/mail-parser.go +++ b/apps/comms/internal/domain/mail-parser.go @@ -26,6 +26,7 @@ type EmailTemplates struct { WelcomeEmail *EmailTemplate WaitingEmail *EmailTemplate AlertEmail *EmailTemplate + ContactUsEmail *EmailTemplate } func parseMailTemplate(et EmailTemplatesDir, templateName string, subject string) (*EmailTemplate, error) { @@ -85,6 +86,11 @@ func GetEmailTemplates(et EmailTemplatesDir) (*EmailTemplates, error) { return nil, err } + contactUs, err := parseMailTemplate(et, "contact-us", "[Kloudlite] Contact Us") + if err != nil { + return nil, err + } + alert, err := parseMailTemplate(et, "alert", "[Kloudlite] Console Notification") return &EmailTemplates{ @@ -94,6 +100,7 @@ func GetEmailTemplates(et EmailTemplatesDir) (*EmailTemplates, error) { UserVerificationEmail: userVerification, WelcomeEmail: welcome, WaitingEmail: waiting, + ContactUsEmail: contactUs, AlertEmail: alert, }, nil } diff --git a/apps/webhook/Taskfile.yml b/apps/webhook/Taskfile.yml index ff19ddbd8..d1f49b09b 100644 --- a/apps/webhook/Taskfile.yml +++ b/apps/webhook/Taskfile.yml @@ -24,6 +24,13 @@ tasks: out: "{{.binary}}-{{.GOARCH}}" GOARCH: "{{.GOARCH}}" + webhook:run: + dotenv: + - .secrets/env + cmds: + - go build -o bin/webhook . + - ./bin/webhook --dev + container:build-and-push: requires: vars: diff --git a/apps/webhook/internal/app/app.go b/apps/webhook/internal/app/app.go index 9e74243b0..fc053d5e4 100644 --- a/apps/webhook/internal/app/app.go +++ b/apps/webhook/internal/app/app.go @@ -1,17 +1,30 @@ package app import ( + "github.com/kloudlite/api/apps/webhook/internal/domain" + "github.com/kloudlite/api/grpc-interfaces/kloudlite.io/rpc/comms" + "github.com/kloudlite/api/pkg/grpc" "github.com/kloudlite/api/pkg/messaging" msgnats "github.com/kloudlite/api/pkg/messaging/nats" "github.com/kloudlite/api/pkg/nats" "go.uber.org/fx" ) +type CommsGrpcClient grpc.Client + var Module = fx.Module( "app", fx.Provide(func(client *nats.JetstreamClient) messaging.Producer { return msgnats.NewJetstreamProducer(client) }), + fx.Provide( + func(conn CommsGrpcClient) comms.CommsClient { + return comms.NewCommsClient(conn) + }, + ), + + domain.Module, + LoadGitWebhook(), ) diff --git a/apps/webhook/internal/app/git-webhook.go b/apps/webhook/internal/app/git-webhook.go index d4d8c9fac..67c9b8383 100644 --- a/apps/webhook/internal/app/git-webhook.go +++ b/apps/webhook/internal/app/git-webhook.go @@ -1,11 +1,13 @@ package app import ( + "bytes" "crypto/hmac" "crypto/sha256" "encoding/hex" "encoding/json" "fmt" + "github.com/kloudlite/api/apps/webhook/internal/domain" "github.com/kloudlite/api/common" "github.com/kloudlite/api/constants" httpServer "github.com/kloudlite/api/pkg/http-server" @@ -102,8 +104,54 @@ func gitRepoUrl(provider string, hookBody []byte) (string, error) { func LoadGitWebhook() fx.Option { return fx.Invoke( - func(server httpServer.Server, envVars *env.Env, producer messaging.Producer, logr logging.Logger) error { + func(server httpServer.Server, envVars *env.Env, producer messaging.Producer, logr logging.Logger, d domain.Domain) error { app := server.Raw() + + app.Get("/healthy", func(c *fiber.Ctx) error { + return c.SendString("OK") + }) + + app.Post("/contact-us", func(ctx *fiber.Ctx) error { + var data *domain.ContactUsData + + if err := ctx.BodyParser(&data); err != nil { + return ctx.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "Invalid request payload"}) + } + + err := d.SendContactUsEmail(ctx.Context(), data) + if err != nil { + return errors.NewE(err) + } + + discordMessage := fmt.Sprintf( + ""+ + "🚨 **NEW CONTACT US SUBMISSION** 🚨\n**Name:** %s\n**Email:** %s\n**Mobile:** %d\n**Company:** %s\n**Country:** %s\n**Message:** %s\n", + data.Name, data.Email, data.MobileNumber, data.CompanyName, data.Country, data.Message, + ) + + payload := map[string]string{ + "content": discordMessage, + } + + payloadBytes, err := json.Marshal(payload) + if err != nil { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to marshal Discord payload"}) + } + + discordWebhookURL := envVars.DiscordWebhookUrl + resp, err := http.Post(discordWebhookURL, "application/json", bytes.NewBuffer(payloadBytes)) + if err != nil { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to send message to Discord"}) + } + defer resp.Body.Close() + + if resp.StatusCode != http.StatusNoContent { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Discord API returned an error"}) + } + + return ctx.Status(fiber.StatusOK).JSON(fiber.Map{"success": true}) + }) + app.Post( "/git/:provider", func(ctx *fiber.Ctx) error { logger := logr.WithName("git-webhook") diff --git a/apps/webhook/internal/domain/api.go b/apps/webhook/internal/domain/api.go new file mode 100644 index 000000000..88d703de2 --- /dev/null +++ b/apps/webhook/internal/domain/api.go @@ -0,0 +1,18 @@ +package domain + +import ( + "context" +) + +type ContactUsData struct { + Name string `json:"name"` + Email string `json:"email"` + MobileNumber int64 `json:"mobileNumber"` + CompanyName string `json:"CompanyName"` + Country string `json:"country"` + Message string `json:"message"` +} + +type Domain interface { + SendContactUsEmail(ctx context.Context, contactUsData *ContactUsData) error +} diff --git a/apps/webhook/internal/domain/domain.go b/apps/webhook/internal/domain/domain.go new file mode 100644 index 000000000..00fca3321 --- /dev/null +++ b/apps/webhook/internal/domain/domain.go @@ -0,0 +1,42 @@ +package domain + +import ( + "context" + "github.com/kloudlite/api/apps/webhook/internal/env" + "github.com/kloudlite/api/grpc-interfaces/kloudlite.io/rpc/comms" + "github.com/kloudlite/api/pkg/errors" + "go.uber.org/fx" +) + +type domain struct { + env *env.Env + commsClient comms.CommsClient +} + +func (d *domain) SendContactUsEmail(ctx context.Context, contactUsData *ContactUsData) error { + _, err := d.commsClient.SendContactUsEmail(ctx, &comms.SendContactUsEmailInput{ + Email: contactUsData.Email, + Name: contactUsData.Name, + CompanyName: contactUsData.CompanyName, + Country: contactUsData.Country, + Message: contactUsData.Message, + MobileNumber: contactUsData.MobileNumber, + }) + if err != nil { + return errors.NewE(err) + } + + return nil +} + +var Module = fx.Module("domain", + fx.Provide(func( + env *env.Env, + commsClient comms.CommsClient, + ) (Domain, error) { + return &domain{ + env: env, + commsClient: commsClient, + }, nil + }), +) diff --git a/apps/webhook/internal/env/env.go b/apps/webhook/internal/env/env.go index 190c34bf0..a3ee6688b 100644 --- a/apps/webhook/internal/env/env.go +++ b/apps/webhook/internal/env/env.go @@ -9,4 +9,7 @@ type Env struct { GithubAuthzSecret string `env:"GITHUB_AUTHZ_SECRET" required:"false"` GitlabAuthzSecret string `env:"GITLAB_AUTHZ_SECRET" required:"false"` NatsURL string `env:"NATS_URL" required:"false"` + + CommsService string `env:"COMMS_SERVICE" required:"true"` + DiscordWebhookUrl string `env:"DISCORD_WEBHOOK_URL" required:"false"` } diff --git a/apps/webhook/internal/framework/main.go b/apps/webhook/internal/framework/main.go index 3dbe45dec..3627c7730 100644 --- a/apps/webhook/internal/framework/main.go +++ b/apps/webhook/internal/framework/main.go @@ -3,6 +3,7 @@ package framework import ( "context" "fmt" + "github.com/kloudlite/api/pkg/grpc" "log/slog" "github.com/kloudlite/api/apps/webhook/internal/app" @@ -61,5 +62,10 @@ var Module = fx.Module( }, }) }), + + fx.Provide(func(ev *env.Env) (app.CommsGrpcClient, error) { + return grpc.NewGrpcClient(ev.CommsService) + }), + app.Module, ) diff --git a/go.mod b/go.mod index 291c7ebe9..9098e4b8e 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,6 @@ require ( github.com/kloudlite/operator v0.0.0-20240725140628-a3dbbc898710 github.com/matoous/go-nanoid/v2 v2.0.0 github.com/pkg/errors v0.9.1 - github.com/rs/zerolog v1.29.1 github.com/sendgrid/sendgrid-go v3.11.1+incompatible github.com/vektah/gqlparser/v2 v2.5.16 github.com/xanzy/go-gitlab v0.63.0 diff --git a/go.sum b/go.sum index 13efacb0d..1e170c254 100644 --- a/go.sum +++ b/go.sum @@ -46,7 +46,6 @@ github.com/charmbracelet/log v0.4.0 h1:G9bQAcx8rWA2T3pWvx7YtPTPwgqpk7D68BX21IRW8 github.com/charmbracelet/log v0.4.0/go.mod h1:63bXt/djrizTec0l11H20t8FDSvA4CRZJ1KH22MdptM= github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482 h1:5/aEFreBh9hH/0G+33xtczJCvMaulqsm9nDuu2BZUEo= github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482/go.mod h1:TM9ug+H/2cI3EjyIDr5xKCkFGyNE59URgH1wu5NyU8E= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -94,7 +93,6 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/adaptor/v2 v2.1.23 h1:VG0yAPnB2EJZjxy4Ul+Ra9e92PnqwXE97SUVuPGuoAA= github.com/gofiber/adaptor/v2 v2.1.23/go.mod h1:hnYEQBPF2x1JaBHygutJJF5d0+J2eYnKKsUMCSsfxKk= github.com/gofiber/fiber/v2 v2.32.0/go.mod h1:CMy5ZLiXkn6qwthrl03YMyW1NLfj0rhxz2LKl4t7ZTY= @@ -194,10 +192,8 @@ github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJ github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U= github.com/matoous/go-nanoid/v2 v2.0.0 h1:d19kur2QuLeHmJBkvYkFdhFBzLoo1XVm2GgTpL+9Tj0= github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjtM7Ej/So3hR0g= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= @@ -262,9 +258,6 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= @@ -407,8 +400,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/grpc-interfaces/comms.proto b/grpc-interfaces/comms.proto index 7ee2785ea..e678b0629 100644 --- a/grpc-interfaces/comms.proto +++ b/grpc-interfaces/comms.proto @@ -9,6 +9,7 @@ service Comms { rpc SendProjectMemberInviteEmail(ProjectMemberInviteEmailInput) returns (Void); rpc SendWelcomeEmail(WelcomeEmailInput) returns (Void); rpc SendWaitingEmail(WelcomeEmailInput) returns (Void); + rpc SendContactUsEmail(SendContactUsEmailInput) returns (Void); } message VerificationEmailInput{ @@ -44,5 +45,14 @@ message ProjectMemberInviteEmailInput{ string name = 5; } +message SendContactUsEmailInput{ + string email = 1; + string name = 2; + string companyName = 3; + string country = 4; + int64 mobileNumber = 5; + string message = 6; +} + message Void{ } diff --git a/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go b/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go index cde4c60ca..2fcdace2b 100644 --- a/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go +++ b/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go @@ -359,6 +359,93 @@ func (x *ProjectMemberInviteEmailInput) GetName() string { return "" } +type SendContactUsEmailInput struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + CompanyName string `protobuf:"bytes,3,opt,name=companyName,proto3" json:"companyName,omitempty"` + Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` + MobileNumber int64 `protobuf:"varint,5,opt,name=mobileNumber,proto3" json:"mobileNumber,omitempty"` + Message string `protobuf:"bytes,6,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *SendContactUsEmailInput) Reset() { + *x = SendContactUsEmailInput{} + if protoimpl.UnsafeEnabled { + mi := &file_comms_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SendContactUsEmailInput) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SendContactUsEmailInput) ProtoMessage() {} + +func (x *SendContactUsEmailInput) ProtoReflect() protoreflect.Message { + mi := &file_comms_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SendContactUsEmailInput.ProtoReflect.Descriptor instead. +func (*SendContactUsEmailInput) Descriptor() ([]byte, []int) { + return file_comms_proto_rawDescGZIP(), []int{5} +} + +func (x *SendContactUsEmailInput) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *SendContactUsEmailInput) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SendContactUsEmailInput) GetCompanyName() string { + if x != nil { + return x.CompanyName + } + return "" +} + +func (x *SendContactUsEmailInput) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + +func (x *SendContactUsEmailInput) GetMobileNumber() int64 { + if x != nil { + return x.MobileNumber + } + return 0 +} + +func (x *SendContactUsEmailInput) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + type Void struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -368,7 +455,7 @@ type Void struct { func (x *Void) Reset() { *x = Void{} if protoimpl.UnsafeEnabled { - mi := &file_comms_proto_msgTypes[5] + mi := &file_comms_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -381,7 +468,7 @@ func (x *Void) String() string { func (*Void) ProtoMessage() {} func (x *Void) ProtoReflect() protoreflect.Message { - mi := &file_comms_proto_msgTypes[5] + mi := &file_comms_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -394,7 +481,7 @@ func (x *Void) ProtoReflect() protoreflect.Message { // Deprecated: Use Void.ProtoReflect.Descriptor instead. func (*Void) Descriptor() ([]byte, []int) { - return file_comms_proto_rawDescGZIP(), []int{5} + return file_comms_proto_rawDescGZIP(), []int{6} } var File_comms_proto protoreflect.FileDescriptor @@ -441,7 +528,19 @@ var file_comms_proto_rawDesc = []byte{ 0x74, 0x65, 0x64, 0x42, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, - 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, 0x64, 0x32, 0xe7, 0x02, 0x0a, 0x05, 0x43, 0x6f, 0x6d, 0x6d, + 0xbd, 0x01, 0x0a, 0x17, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, 0x55, + 0x73, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x6e, 0x79, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x70, + 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x4e, + 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, + 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, 0x64, 0x32, 0x9e, 0x03, 0x0a, 0x05, 0x43, 0x6f, 0x6d, 0x6d, 0x73, 0x12, 0x37, 0x0a, 0x15, 0x53, 0x65, 0x6e, 0x64, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, @@ -464,9 +563,12 @@ var file_comms_proto_rawDesc = []byte{ 0x69, 0x64, 0x12, 0x2d, 0x0a, 0x10, 0x53, 0x65, 0x6e, 0x64, 0x57, 0x61, 0x69, 0x74, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x12, 0x2e, 0x57, 0x65, 0x6c, 0x63, 0x6f, 0x6d, 0x65, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x1a, 0x05, 0x2e, 0x56, 0x6f, 0x69, - 0x64, 0x42, 0x18, 0x5a, 0x16, 0x6b, 0x6c, 0x6f, 0x75, 0x64, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x69, - 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x64, 0x12, 0x35, 0x0a, 0x12, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x63, 0x74, + 0x55, 0x73, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x18, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x43, 0x6f, + 0x6e, 0x74, 0x61, 0x63, 0x74, 0x55, 0x73, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x6e, 0x70, 0x75, + 0x74, 0x1a, 0x05, 0x2e, 0x56, 0x6f, 0x69, 0x64, 0x42, 0x18, 0x5a, 0x16, 0x6b, 0x6c, 0x6f, 0x75, + 0x64, 0x6c, 0x69, 0x74, 0x65, 0x2e, 0x69, 0x6f, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6d, + 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -481,14 +583,15 @@ func file_comms_proto_rawDescGZIP() []byte { return file_comms_proto_rawDescData } -var file_comms_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_comms_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_comms_proto_goTypes = []interface{}{ (*VerificationEmailInput)(nil), // 0: VerificationEmailInput (*WelcomeEmailInput)(nil), // 1: WelcomeEmailInput (*PasswordResetEmailInput)(nil), // 2: PasswordResetEmailInput (*AccountMemberInviteEmailInput)(nil), // 3: AccountMemberInviteEmailInput (*ProjectMemberInviteEmailInput)(nil), // 4: ProjectMemberInviteEmailInput - (*Void)(nil), // 5: Void + (*SendContactUsEmailInput)(nil), // 5: SendContactUsEmailInput + (*Void)(nil), // 6: Void } var file_comms_proto_depIdxs = []int32{ 0, // 0: Comms.SendVerificationEmail:input_type -> VerificationEmailInput @@ -497,14 +600,16 @@ var file_comms_proto_depIdxs = []int32{ 4, // 3: Comms.SendProjectMemberInviteEmail:input_type -> ProjectMemberInviteEmailInput 1, // 4: Comms.SendWelcomeEmail:input_type -> WelcomeEmailInput 1, // 5: Comms.SendWaitingEmail:input_type -> WelcomeEmailInput - 5, // 6: Comms.SendVerificationEmail:output_type -> Void - 5, // 7: Comms.SendPasswordResetEmail:output_type -> Void - 5, // 8: Comms.SendAccountMemberInviteEmail:output_type -> Void - 5, // 9: Comms.SendProjectMemberInviteEmail:output_type -> Void - 5, // 10: Comms.SendWelcomeEmail:output_type -> Void - 5, // 11: Comms.SendWaitingEmail:output_type -> Void - 6, // [6:12] is the sub-list for method output_type - 0, // [0:6] is the sub-list for method input_type + 5, // 6: Comms.SendContactUsEmail:input_type -> SendContactUsEmailInput + 6, // 7: Comms.SendVerificationEmail:output_type -> Void + 6, // 8: Comms.SendPasswordResetEmail:output_type -> Void + 6, // 9: Comms.SendAccountMemberInviteEmail:output_type -> Void + 6, // 10: Comms.SendProjectMemberInviteEmail:output_type -> Void + 6, // 11: Comms.SendWelcomeEmail:output_type -> Void + 6, // 12: Comms.SendWaitingEmail:output_type -> Void + 6, // 13: Comms.SendContactUsEmail:output_type -> Void + 7, // [7:14] is the sub-list for method output_type + 0, // [0:7] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -577,6 +682,18 @@ func file_comms_proto_init() { } } file_comms_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SendContactUsEmailInput); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_comms_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Void); i { case 0: return &v.state @@ -595,7 +712,7 @@ func file_comms_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_comms_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 7, NumExtensions: 0, NumServices: 1, }, diff --git a/grpc-interfaces/kloudlite.io/rpc/comms/comms_grpc.pb.go b/grpc-interfaces/kloudlite.io/rpc/comms/comms_grpc.pb.go index a8a8a4083..2105b41ad 100644 --- a/grpc-interfaces/kloudlite.io/rpc/comms/comms_grpc.pb.go +++ b/grpc-interfaces/kloudlite.io/rpc/comms/comms_grpc.pb.go @@ -25,6 +25,7 @@ const ( Comms_SendProjectMemberInviteEmail_FullMethodName = "/Comms/SendProjectMemberInviteEmail" Comms_SendWelcomeEmail_FullMethodName = "/Comms/SendWelcomeEmail" Comms_SendWaitingEmail_FullMethodName = "/Comms/SendWaitingEmail" + Comms_SendContactUsEmail_FullMethodName = "/Comms/SendContactUsEmail" ) // CommsClient is the client API for Comms service. @@ -37,6 +38,7 @@ type CommsClient interface { SendProjectMemberInviteEmail(ctx context.Context, in *ProjectMemberInviteEmailInput, opts ...grpc.CallOption) (*Void, error) SendWelcomeEmail(ctx context.Context, in *WelcomeEmailInput, opts ...grpc.CallOption) (*Void, error) SendWaitingEmail(ctx context.Context, in *WelcomeEmailInput, opts ...grpc.CallOption) (*Void, error) + SendContactUsEmail(ctx context.Context, in *SendContactUsEmailInput, opts ...grpc.CallOption) (*Void, error) } type commsClient struct { @@ -101,6 +103,15 @@ func (c *commsClient) SendWaitingEmail(ctx context.Context, in *WelcomeEmailInpu return out, nil } +func (c *commsClient) SendContactUsEmail(ctx context.Context, in *SendContactUsEmailInput, opts ...grpc.CallOption) (*Void, error) { + out := new(Void) + err := c.cc.Invoke(ctx, Comms_SendContactUsEmail_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // CommsServer is the server API for Comms service. // All implementations must embed UnimplementedCommsServer // for forward compatibility @@ -111,6 +122,7 @@ type CommsServer interface { SendProjectMemberInviteEmail(context.Context, *ProjectMemberInviteEmailInput) (*Void, error) SendWelcomeEmail(context.Context, *WelcomeEmailInput) (*Void, error) SendWaitingEmail(context.Context, *WelcomeEmailInput) (*Void, error) + SendContactUsEmail(context.Context, *SendContactUsEmailInput) (*Void, error) mustEmbedUnimplementedCommsServer() } @@ -136,6 +148,9 @@ func (UnimplementedCommsServer) SendWelcomeEmail(context.Context, *WelcomeEmailI func (UnimplementedCommsServer) SendWaitingEmail(context.Context, *WelcomeEmailInput) (*Void, error) { return nil, status.Errorf(codes.Unimplemented, "method SendWaitingEmail not implemented") } +func (UnimplementedCommsServer) SendContactUsEmail(context.Context, *SendContactUsEmailInput) (*Void, error) { + return nil, status.Errorf(codes.Unimplemented, "method SendContactUsEmail not implemented") +} func (UnimplementedCommsServer) mustEmbedUnimplementedCommsServer() {} // UnsafeCommsServer may be embedded to opt out of forward compatibility for this service. @@ -257,6 +272,24 @@ func _Comms_SendWaitingEmail_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Comms_SendContactUsEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SendContactUsEmailInput) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CommsServer).SendContactUsEmail(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Comms_SendContactUsEmail_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CommsServer).SendContactUsEmail(ctx, req.(*SendContactUsEmailInput)) + } + return interceptor(ctx, in, info, handler) +} + // Comms_ServiceDesc is the grpc.ServiceDesc for Comms service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -288,6 +321,10 @@ var Comms_ServiceDesc = grpc.ServiceDesc{ MethodName: "SendWaitingEmail", Handler: _Comms_SendWaitingEmail_Handler, }, + { + MethodName: "SendContactUsEmail", + Handler: _Comms_SendContactUsEmail_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "comms.proto", From ebd6b6dd5c1e2e2687cd469457d45f2f82f28822 Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Wed, 21 Aug 2024 16:58:57 +0530 Subject: [PATCH 2/2] modified email template for contact us --- .../email-templates/contact-us/email.html | 5 --- .../email-templates/contact-us/email.mjml | 3 -- .../email-templates/contact-us/email.txt | 2 - apps/webhook/internal/app/git-webhook.go | 44 ++++++++++--------- apps/webhook/internal/domain/api.go | 2 +- grpc-interfaces/comms.proto | 2 +- .../kloudlite.io/rpc/comms/comms.pb.go | 8 ++-- 7 files changed, 29 insertions(+), 37 deletions(-) diff --git a/apps/comms/email-templates/contact-us/email.html b/apps/comms/email-templates/contact-us/email.html index a4a7b7c79..3a32602a4 100644 --- a/apps/comms/email-templates/contact-us/email.html +++ b/apps/comms/email-templates/contact-us/email.html @@ -151,11 +151,6 @@
We have received your details and our team will get back to you shortly.
- - -
I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help!
- -
Best Regards,
diff --git a/apps/comms/email-templates/contact-us/email.mjml b/apps/comms/email-templates/contact-us/email.mjml index adaca51e4..1083e32fb 100644 --- a/apps/comms/email-templates/contact-us/email.mjml +++ b/apps/comms/email-templates/contact-us/email.mjml @@ -19,9 +19,6 @@ We have received your details and our team will get back to you shortly. - - I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help! - Best Regards, diff --git a/apps/comms/email-templates/contact-us/email.txt b/apps/comms/email-templates/contact-us/email.txt index ddd45ac84..adb60115d 100644 --- a/apps/comms/email-templates/contact-us/email.txt +++ b/apps/comms/email-templates/contact-us/email.txt @@ -4,7 +4,5 @@ I’m Karthik, the founder of Kloudlite Inc and I’d like to personally thank y We have received your details and our team will get back to you shortly. -I’d love to hear what you think of our product and if there is anything we can improve. If you have any questions, please reply to this email. I’m always happy to help! - Best Regards, Karthik diff --git a/apps/webhook/internal/app/git-webhook.go b/apps/webhook/internal/app/git-webhook.go index 67c9b8383..269990ddd 100644 --- a/apps/webhook/internal/app/git-webhook.go +++ b/apps/webhook/internal/app/git-webhook.go @@ -123,30 +123,32 @@ func LoadGitWebhook() fx.Option { return errors.NewE(err) } - discordMessage := fmt.Sprintf( - ""+ - "🚨 **NEW CONTACT US SUBMISSION** 🚨\n**Name:** %s\n**Email:** %s\n**Mobile:** %d\n**Company:** %s\n**Country:** %s\n**Message:** %s\n", - data.Name, data.Email, data.MobileNumber, data.CompanyName, data.Country, data.Message, - ) - - payload := map[string]string{ - "content": discordMessage, - } + discordWebhookURL := envVars.DiscordWebhookUrl + if discordWebhookURL != "" { + discordMessage := fmt.Sprintf( + ""+ + "🚨 **NEW CONTACT US SUBMISSION** 🚨\n**Name:** %s\n**Email:** %s\n**Mobile:** %s\n**Company:** %s\n**Country:** %s\n**Message:** %s\n", + data.Name, data.Email, data.MobileNumber, data.CompanyName, data.Country, data.Message, + ) + + payload := map[string]string{ + "content": discordMessage, + } - payloadBytes, err := json.Marshal(payload) - if err != nil { - return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to marshal Discord payload"}) - } + payloadBytes, err := json.Marshal(payload) + if err != nil { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to marshal Discord payload"}) + } - discordWebhookURL := envVars.DiscordWebhookUrl - resp, err := http.Post(discordWebhookURL, "application/json", bytes.NewBuffer(payloadBytes)) - if err != nil { - return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to send message to Discord"}) - } - defer resp.Body.Close() + resp, err := http.Post(discordWebhookURL, "application/json", bytes.NewBuffer(payloadBytes)) + if err != nil { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to send message to Discord"}) + } + defer resp.Body.Close() - if resp.StatusCode != http.StatusNoContent { - return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Discord API returned an error"}) + if resp.StatusCode != http.StatusNoContent { + return ctx.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "Discord API returned an error"}) + } } return ctx.Status(fiber.StatusOK).JSON(fiber.Map{"success": true}) diff --git a/apps/webhook/internal/domain/api.go b/apps/webhook/internal/domain/api.go index 88d703de2..e561c8239 100644 --- a/apps/webhook/internal/domain/api.go +++ b/apps/webhook/internal/domain/api.go @@ -7,7 +7,7 @@ import ( type ContactUsData struct { Name string `json:"name"` Email string `json:"email"` - MobileNumber int64 `json:"mobileNumber"` + MobileNumber string `json:"mobileNumber"` CompanyName string `json:"CompanyName"` Country string `json:"country"` Message string `json:"message"` diff --git a/grpc-interfaces/comms.proto b/grpc-interfaces/comms.proto index e678b0629..9734c26b0 100644 --- a/grpc-interfaces/comms.proto +++ b/grpc-interfaces/comms.proto @@ -50,7 +50,7 @@ message SendContactUsEmailInput{ string name = 2; string companyName = 3; string country = 4; - int64 mobileNumber = 5; + string mobileNumber = 5; string message = 6; } diff --git a/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go b/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go index 2fcdace2b..35c93117b 100644 --- a/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go +++ b/grpc-interfaces/kloudlite.io/rpc/comms/comms.pb.go @@ -368,7 +368,7 @@ type SendContactUsEmailInput struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` CompanyName string `protobuf:"bytes,3,opt,name=companyName,proto3" json:"companyName,omitempty"` Country string `protobuf:"bytes,4,opt,name=country,proto3" json:"country,omitempty"` - MobileNumber int64 `protobuf:"varint,5,opt,name=mobileNumber,proto3" json:"mobileNumber,omitempty"` + MobileNumber string `protobuf:"bytes,5,opt,name=mobileNumber,proto3" json:"mobileNumber,omitempty"` Message string `protobuf:"bytes,6,opt,name=message,proto3" json:"message,omitempty"` } @@ -432,11 +432,11 @@ func (x *SendContactUsEmailInput) GetCountry() string { return "" } -func (x *SendContactUsEmailInput) GetMobileNumber() int64 { +func (x *SendContactUsEmailInput) GetMobileNumber() string { if x != nil { return x.MobileNumber } - return 0 + return "" } func (x *SendContactUsEmailInput) GetMessage() string { @@ -537,7 +537,7 @@ var file_comms_proto_rawDesc = []byte{ 0x61, 0x6e, 0x79, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, - 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x4e, + 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x06, 0x0a, 0x04, 0x56, 0x6f, 0x69, 0x64, 0x32, 0x9e, 0x03, 0x0a, 0x05, 0x43, 0x6f, 0x6d, 0x6d,