Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Generate code
run: |
docker run --rm -v ${GITHUB_WORKSPACE}:/local openapitools/openapi-generator:cli-5.3.x generate -i /local/api/notification-service.yaml -g go-server -o /local/ -p sourceFolder=internal/server -p packageName=server --git-user-id=commitdev --git-repo-id=zero-notification-service
docker run --rm -v ${GITHUB_WORKSPACE}:/local openapitools/openapi-generator-cli:v7.0.0 generate -i /local/api/notification-service.yaml -g go-server -o /local/ -p sourceFolder=internal/server -p packageName=server --git-user-id=commitdev --git-repo-id=zero-notification-service
sudo chmod -R a+rw ${GITHUB_WORKSPACE}
go install golang.org/x/tools/cmd/goimports@latest
goimports -w ${GITHUB_WORKSPACE}/internal/server/
Expand Down
2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.6.0
7.0.0
8 changes: 4 additions & 4 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ func main() {
go heartbeat()

EmailApiService := service.NewEmailApiService(config)
EmailApiController := server.NewEmailApiController(EmailApiService)
EmailApiController := server.NewEmailAPIController(EmailApiService)

SmsApiService := service.NewSmsApiService(config)
SmsApiController := server.NewSmsApiController(SmsApiService)
SmsApiController := server.NewSmsAPIController(SmsApiService)

HealthApiService := service.NewHealthApiService(config)
HealthApiController := server.NewHealthApiController(HealthApiService)
HealthApiController := server.NewHealthAPIController(HealthApiService)

NotificationApiService := service.NewNotificationApiService(config)
NotificationApiController := server.NewNotificationApiController(NotificationApiService)
NotificationApiController := server.NewNotificationAPIController(NotificationApiService)

router := server.NewRouter(EmailApiController, SmsApiController, HealthApiController, NotificationApiController)

Expand Down
12 changes: 6 additions & 6 deletions internal/service/api_email_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type EmailApiService struct {
}

// NewEmailApiService creates a default api service
func NewEmailApiService(c *config.Config) server.EmailApiServicer {
func NewEmailApiService(c *config.Config) server.EmailAPIServicer {
return &EmailApiService{c}
}

Expand Down Expand Up @@ -82,19 +82,19 @@ func (s *EmailApiService) SendBulk(ctx context.Context, sendBulkMailRequest serv

mail.SendBulkMail(sendBulkMailRequest.ToAddresses, sendBulkMailRequest.FromAddress, sendBulkMailRequest.CcAddresses, sendBulkMailRequest.BccAddresses, sendBulkMailRequest.Headers, sendBulkMailRequest.Message, client, responseChannel)

var successful []server.SendBulkMailResponseSuccessful
var failed []server.SendBulkMailResponseFailed
var successful []server.SendBulkMailResponseSuccessfulInner
var failed []server.SendBulkMailResponseFailedInner

// Read all the responses from the channel. This will block if responses aren't ready and the channel is not yet closed
for r := range responseChannel {
if r.Error != nil {
zap.S().Errorf("Error sending bulk mail: %v", r.Error)
failed = append(failed, server.SendBulkMailResponseFailed{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v\n", r.Error)})
failed = append(failed, server.SendBulkMailResponseFailedInner{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v\n", r.Error)})
} else if !(r.Response.StatusCode >= 200 && r.Response.StatusCode <= 299) {
zap.S().Errorf("Failure from Sendgrid when sending bulk mail: %v", r.Response)
failed = append(failed, server.SendBulkMailResponseFailed{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v from mail provider: %v\n", r.Response.StatusCode, r.Response.Body)})
failed = append(failed, server.SendBulkMailResponseFailedInner{EmailAddress: r.EmailAddress, Error: fmt.Sprintf("Unable to send email: %v from mail provider: %v\n", r.Response.StatusCode, r.Response.Body)})
} else {
successful = append(successful, server.SendBulkMailResponseSuccessful{EmailAddress: r.EmailAddress, TrackingId: r.Response.Headers["X-Message-Id"][0]})
successful = append(successful, server.SendBulkMailResponseSuccessfulInner{EmailAddress: r.EmailAddress, TrackingId: r.Response.Headers["X-Message-Id"][0]})
}
}
responseCode := http.StatusOK
Expand Down
2 changes: 1 addition & 1 deletion internal/service/api_health_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type HealthApiService struct {
}

// NewHealthApiService creates a default api service
func NewHealthApiService(c *config.Config) server.HealthApiServicer {
func NewHealthApiService(c *config.Config) server.HealthAPIServicer {
return &HealthApiService{c}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/service/api_notification_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type NotificationApiService struct {
}

// NewNotificationApiService creates a default api service
func NewNotificationApiService(c *config.Config) server.NotificationApiServicer {
func NewNotificationApiService(c *config.Config) server.NotificationAPIServicer {
return &NotificationApiService{c}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/service/api_sms_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type SmsApiService struct {
}

// NewSmsApiService creates a default api service
func NewSmsApiService(c *config.Config) server.SmsApiServicer {
func NewSmsApiService(c *config.Config) server.SmsAPIServicer {
return &SmsApiService{c}
}

Expand Down