mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
[push] migrate to Notify method where posible
This commit is contained in:
parent
722272df6c
commit
d86a0e4234
@ -220,18 +220,14 @@ func (s *Service) Enqueue(device models.Device, message MessageIn, opts EnqueueO
|
||||
return state, err
|
||||
}
|
||||
|
||||
if device.PushToken == nil {
|
||||
return state, nil
|
||||
}
|
||||
|
||||
go func(token string) {
|
||||
if err := s.pushSvc.Enqueue(token, push.NewMessageEnqueuedEvent()); err != nil {
|
||||
s.logger.Error("Can't enqueue message", zap.String("token", token), zap.Error(err))
|
||||
}
|
||||
}(*device.PushToken)
|
||||
|
||||
s.messagesCounter.WithLabelValues(string(state.State)).Inc()
|
||||
|
||||
go func(userID, deviceID string) {
|
||||
if err := s.pushSvc.Notify(userID, &deviceID, push.NewMessageEnqueuedEvent()); err != nil {
|
||||
s.logger.Error("can't notify device", zap.Error(err), zap.String("user_id", userID), zap.String("device_id", deviceID))
|
||||
}
|
||||
}(device.UserID, device.ID)
|
||||
|
||||
return state, nil
|
||||
}
|
||||
|
||||
@ -242,7 +238,7 @@ func (s *Service) ExportInbox(device models.Device, since, until time.Time) erro
|
||||
|
||||
event := push.NewMessagesExportRequestedEvent(since, until)
|
||||
|
||||
return s.pushSvc.Enqueue(*device.PushToken, event)
|
||||
return s.pushSvc.Notify(device.UserID, &device.ID, event)
|
||||
}
|
||||
|
||||
func (s *Service) Clean(ctx context.Context) error {
|
||||
|
||||
@ -158,7 +158,6 @@ func (s *Service) Notify(userID string, deviceID *string, event *domain.Event) e
|
||||
|
||||
devices, err := s.devicesSvc.Select(userID, filters...)
|
||||
if err != nil {
|
||||
s.logger.Error("Failed to select devices", append(logFields, zap.Error(err))...)
|
||||
return fmt.Errorf("failed to select devices: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user