fix: repair notification system (broken type assertion + wrong PocketBase filter quotes)
- Add bookstore.NotificationStore interface and wire it directly to *storage.Store in Dependencies, bypassing the Asynq wrapper that caused Producer.(*storage.Store) to fail with a 500 on every notification endpoint when Redis is configured - Replace s.deps.Producer.(*storage.Store) type assertion in all 5 notification handlers with s.deps.NotificationStore (nil-safe, always works) - Fix PocketBase filter single-quote bug in ListNotifications, ClearAllNotifications, and MarkAllNotificationsRead (PocketBase requires double quotes for string values)
This commit is contained in:
@@ -773,7 +773,7 @@ func (s *Store) CreateNotification(ctx context.Context, userID, title, message,
|
||||
|
||||
// ListNotifications returns notifications for a user.
|
||||
func (s *Store) ListNotifications(ctx context.Context, userID string, limit int) ([]map[string]any, error) {
|
||||
filter := fmt.Sprintf("user_id='%s'", userID)
|
||||
filter := fmt.Sprintf(`user_id="%s"`, userID)
|
||||
items, err := s.pb.listAll(ctx, "notifications", filter, "-created")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -805,7 +805,7 @@ func (s *Store) DeleteNotification(ctx context.Context, id string) error {
|
||||
|
||||
// ClearAllNotifications deletes all notifications for a user.
|
||||
func (s *Store) ClearAllNotifications(ctx context.Context, userID string) error {
|
||||
filter := fmt.Sprintf("user_id='%s'", userID)
|
||||
filter := fmt.Sprintf(`user_id="%s"`, userID)
|
||||
items, err := s.pb.listAll(ctx, "notifications", filter, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("ClearAllNotifications list: %w", err)
|
||||
@@ -823,7 +823,7 @@ func (s *Store) ClearAllNotifications(ctx context.Context, userID string) error
|
||||
|
||||
// MarkAllNotificationsRead marks all notifications for a user as read.
|
||||
func (s *Store) MarkAllNotificationsRead(ctx context.Context, userID string) error {
|
||||
filter := fmt.Sprintf("user_id='%s'&&read=false", userID)
|
||||
filter := fmt.Sprintf(`user_id="%s"&&read=false`, userID)
|
||||
items, err := s.pb.listAll(ctx, "notifications", filter, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("MarkAllNotificationsRead list: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user