MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / SendAPIKeyRotatedEmail

Method SendAPIKeyRotatedEmail

api/pkg/services/user_service.go:331–350  ·  view source on GitHub ↗

SendAPIKeyRotatedEmail sends an email to an entities.User when the API key is rotated

(ctx context.Context, payload *events.UserAPIKeyRotatedPayload)

Source from the content-addressed store, hash-verified

329
330// SendAPIKeyRotatedEmail sends an email to an entities.User when the API key is rotated
331func (service *UserService) SendAPIKeyRotatedEmail(ctx context.Context, payload *events.UserAPIKeyRotatedPayload) error {
332 ctx, span := service.tracer.Start(ctx)
333 defer span.End()
334
335 ctxLogger := service.tracer.CtxLogger(service.logger, span)
336
337 email, err := service.emailFactory.APIKeyRotated(payload.Email, payload.Timestamp, payload.Timezone)
338 if err != nil {
339 msg := fmt.Sprintf("cannot create api key rotated email for user [%s]", payload.UserID)
340 return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
341 }
342
343 if err = service.mailer.Send(ctx, email); err != nil {
344 msg := fmt.Sprintf("canot create api key rotated email to user [%s]", payload.UserID)
345 return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
346 }
347
348 ctxLogger.Info(fmt.Sprintf("api key rotated email sent successfully to [%s] with user ID [%s]", payload.Email, payload.UserID))
349 return nil
350}
351
352// UserSendPhoneDeadEmailParams are parameters for notifying a user when a phone is dead
353type UserSendPhoneDeadEmailParams struct {

Callers 1

onUserAPIKeyRotatedMethod · 0.80

Calls 6

StartMethod · 0.65
CtxLoggerMethod · 0.65
APIKeyRotatedMethod · 0.65
WrapErrorSpanMethod · 0.65
SendMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected