Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Don't schedule monitor when it doesn't exist
Acho Arnold7ec17b3a65fd
diff --git a/api/pkg/handlers/events_handler.go b/api/pkg/handlers/events_handler.goindex b775315d..204fcc35 100644--- a/api/pkg/handlers/events_handler.go+++ b/api/pkg/handlers/events_handler.go@@ -68,9 +68,10 @@ func (h *EventsHandler) Dispatch(c *fiber.Ctx) error {return h.responseForbidden(c)}+ ctxLogger.Info(fmt.Sprintf("handling [%s] event with ID [%s]", request.Type(), request.ID()))err := h.service.DispatchSync(ctx, request)if err != nil {- msg := fmt.Sprintf("cannot dispatch event with ID [%s]", request.ID())+ msg := fmt.Sprintf("cannot dispatch [%s] event with ID [%s]", request.Type(), request.ID())ctxLogger.Error(stacktrace.Propagate(err, msg))return h.responseInternalServerError(c)}diff --git a/api/pkg/repositories/gorm_heartbeat_monitor_repository.go b/api/pkg/repositories/gorm_heartbeat_monitor_repository.goindex 716dc7e3..ae752c17 100644--- a/api/pkg/repositories/gorm_heartbeat_monitor_repository.go+++ b/api/pkg/repositories/gorm_heartbeat_monitor_repository.go@@ -123,7 +123,7 @@ func (repository *gormHeartbeatMonitorRepository) Load(ctx context.Context, user}// Exists checks of a heartbeat monitor exists for the userID and owner-func (repository *gormHeartbeatMonitorRepository) Exists(ctx context.Context, userID entities.UserID, owner string) (bool, error) {+func (repository *gormHeartbeatMonitorRepository) Exists(ctx context.Context, userID entities.UserID, monitorID uuid.UUID) (bool, error) {ctx, span := repository.tracer.Start(ctx)defer span.End()@@ -132,10 +132,10 @@ func (repository *gormHeartbeatMonitorRepository) Exists(ctx context.Context, usModel(&entities.HeartbeatMonitor{}).Select("count(*) > 0").Where("user_id = ?", userID).- Where("owner = ?", owner).+ Where("id = ?", monitorID).Find(&exists).Errorif err != nil {- msg := fmt.Sprintf("cannot check if heartbeat monitor exists with userID [%s] and owner [%s]", userID, owner)+ msg := fmt.Sprintf("cannot check if heartbeat monitor exists with userID [%s] and montiorID [%s]", userID, monitorID)return exists, repository.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))}diff --git a/api/pkg/repositories/heartbeat_monitor_repository.go b/api/pkg/repositories/heartbeat_monitor_repository.goindex 84ec1023..5c820488 100644--- a/api/pkg/repositories/heartbeat_monitor_repository.go+++ b/api/pkg/repositories/heartbeat_monitor_repository.go@@ -17,7 +17,7 @@ type HeartbeatMonitorRepository interface {Load(ctx context.Context, userID entities.UserID, phoneNumber string) (*entities.HeartbeatMonitor, error)// Exists checks if a heartbeat monitor exists for a phone number- Exists(ctx context.Context, userID entities.UserID, phoneNumber string) (bool, error)+ Exists(ctx context.Context, userID entities.UserID, monitorID uuid.UUID) (bool, error)// UpdateQueueID updates the queueID of a monitorUpdateQueueID(ctx context.Context, monitorID uuid.UUID, queueID string) errordiff --git a/api/pkg/services/event_dispatcher_service.go b/api/pkg/services/event_dispatcher_service.goindex 52967d7d..c10db5bd 100644--- a/api/pkg/services/event_dispatcher_service.go+++ b/api/pkg/services/event_dispatcher_service.go@@ -103,7 +103,7 @@ func (dispatcher *EventDispatcher) Publish(ctx context.Context, event cloudeventsubscribers, ok := dispatcher.listeners[event.Type()]if !ok {- ctxLogger.Info(fmt.Sprintf("no listener is configured for event type [%s]", event.Type()))+ ctxLogger.Info(fmt.Sprintf("no listener is configured for event type [%s] with id [%s]", event.Type(), event.ID()))return}diff --git a/api/pkg/services/google_cloud_push_queue_service.go b/api/pkg/services/google_cloud_push_queue_service.goindex c96b662c..d0abe3c0 100644--- a/api/pkg/services/google_cloud_push_queue_service.go+++ b/api/pkg/services/google_cloud_push_queue_service.go@@ -77,7 +77,7 @@ func (queue *googlePushQueue) Enqueue(ctx context.Context, task *PushQueueTask,"item added to [%s] queue with id [%s] and schedule [%s]",queue.queueConfig.Name,queueTask.Name,- queueTask.ScheduleTime,+ queueTask.GetScheduleTime().AsTime(),))return queueTask.Name, nildiff --git a/api/pkg/services/heartbeat_service.go b/api/pkg/services/heartbeat_service.goindex 5b14511a..4c10a571 100644--- a/api/pkg/services/heartbeat_service.go+++ b/api/pkg/services/heartbeat_service.go@@ -203,7 +203,7 @@ func (service *HeartbeatService) Monitor(ctx context.Context, params *HeartbeatMctxLogger := service.tracer.CtxLogger(service.logger, span)- exists, err := service.monitorRepository.Exists(ctx, params.UserID, params.Owner)+ exists, err := service.monitorRepository.Exists(ctx, params.UserID, params.MonitorID)if err != nil {msg := fmt.Sprintf("cannot check if monitor exists with userID [%s] and owner [%s]", params.UserID, params.Owner)ctxLogger.Error(stacktrace.Propagate(err, msg))@@ -217,7 +217,7 @@ func (service *HeartbeatService) Monitor(ctx context.Context, params *HeartbeatMheartbeat, err := service.repository.Last(ctx, params.UserID, params.Owner)if err != nil {- msg := fmt.Sprintf("cannot fetch last heartbeat for userID [%s] and owner [%s] removing check", params.UserID, params.Owner)+ msg := fmt.Sprintf("cannot fetch last heartbeat for userID [%s] and owner [%s] and ID [%s] removing check", params.UserID, params.Owner, params.MonitorID)ctxLogger.Error(stacktrace.Propagate(err, msg))return nil}