From 6e7b957551f318befb83ce25bcc07a097a789bfc Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Wed, 4 Mar 2026 10:53:01 -0800 Subject: [PATCH] Afro SMS integration fix --- internal/config/config.go | 10 +++++----- internal/services/messenger/sms.go | 2 +- internal/services/notification/service.go | 4 ++-- internal/web_server/handlers/notification_handler.go | 3 ++- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 5977ff6..733e3f6 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -111,7 +111,7 @@ type Config struct { AFRO_SMS_API_KEY string AFRO_SMS_SENDER_NAME string AFRO_SMS_RECEIVER_PHONE_NUMBER string - ADRO_SMS_HOST_URL string + AFRO_SMS_HOST_URL string CHAPA_WEBHOOK_SECRET string CHAPA_TRANSFER_TYPE string CHAPA_PAYMENT_TYPE string @@ -367,14 +367,14 @@ func (c *Config) loadEnv() error { c.AFRO_SMS_SENDER_NAME = os.Getenv("AFRO_SMS_SENDER_NAME") if c.AFRO_SMS_SENDER_NAME == "" { - c.AFRO_SMS_SENDER_NAME = "Yimaru" + c.AFRO_SMS_SENDER_NAME = "Yimaru Acad" } c.AFRO_SMS_RECEIVER_PHONE_NUMBER = os.Getenv("AFRO_SMS_RECEIVER_PHONE_NUMBER") - c.ADRO_SMS_HOST_URL = os.Getenv("ADRO_SMS_HOST_URL") - if c.ADRO_SMS_HOST_URL == "" { - c.ADRO_SMS_HOST_URL = "https://api.afromessage.com" + c.AFRO_SMS_HOST_URL = os.Getenv("AFRO_SMS_HOST_URL") + if c.AFRO_SMS_HOST_URL == "" { + c.AFRO_SMS_HOST_URL = "https://api.afromessage.com" } //Atlas diff --git a/internal/services/messenger/sms.go b/internal/services/messenger/sms.go index c1767d0..595c513 100644 --- a/internal/services/messenger/sms.go +++ b/internal/services/messenger/sms.go @@ -38,7 +38,7 @@ func (s *Service) SendSMS(ctx context.Context, receiverPhone, message string) er func (s *Service) SendAfroMessageSMS(ctx context.Context, receiverPhone, message string) error { apiKey := s.config.AFRO_SMS_API_KEY senderName := s.config.AFRO_SMS_SENDER_NAME - hostURL := s.config.ADRO_SMS_HOST_URL + hostURL := s.config.AFRO_SMS_HOST_URL endpoint := "/api/send" // API endpoint has been updated diff --git a/internal/services/notification/service.go b/internal/services/notification/service.go index 2ff4f20..ddd5c54 100644 --- a/internal/services/notification/service.go +++ b/internal/services/notification/service.go @@ -169,7 +169,7 @@ func (s *Service) SendAfroMessageSMSTemp( } // Construct full URL - reqURL := fmt.Sprintf("%s?%s", baseURL, params.Encode()) + reqURL := fmt.Sprintf("%s/api/send?%s", baseURL, params.Encode()) req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil { @@ -413,7 +413,7 @@ func (s *Service) DisconnectWebSocket(recipientID int64) { // apiKey := s.config.AFRO_SMS_API_KEY // senderName := s.config.AFRO_SMS_SENDER_NAME // receiverPhone := s.config.AFRO_SMS_RECEIVER_PHONE_NUMBER -// hostURL := s.config.ADRO_SMS_HOST_URL +// hostURL := s.config.AFRO_SMS_HOST_URL // endpoint := "/api/send" // request := afro.GetRequest(apiKey, endpoint, hostURL) diff --git a/internal/web_server/handlers/notification_handler.go b/internal/web_server/handlers/notification_handler.go index 0425785..a764688 100644 --- a/internal/web_server/handlers/notification_handler.go +++ b/internal/web_server/handlers/notification_handler.go @@ -618,10 +618,11 @@ func (h *Handler) SendSingleAfroSMS(c *fiber.Ctx) error { } // Send SMS via service - if err := h.notificationSvc.SendAfroMessageSMS( + if err := h.notificationSvc.SendAfroMessageSMSTemp( c.Context(), req.Recipient, req.Message, + nil, ); err != nil { h.mongoLoggerSvc.Error("Failed to send AfroMessage SMS",