From 64ef80a21c55ee00ea8c321b2ddb2627ce70ca56 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 6 Nov 2025 12:14:30 +0000 Subject: [PATCH] style: fix linting issues - Fix SQLite GetReaction to use standard List pattern (consistent with MySQL/PostgreSQL) - Add periods to comment endings (godot linter requirement) - Simplify GetReaction implementation to avoid sql.ErrNoRows handling --- server/router/api/v1/reaction_service.go | 4 +-- store/db/sqlite/reaction.go | 37 ++++-------------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/server/router/api/v1/reaction_service.go b/server/router/api/v1/reaction_service.go index ab903a5c5..d644ad14b 100644 --- a/server/router/api/v1/reaction_service.go +++ b/server/router/api/v1/reaction_service.go @@ -68,7 +68,7 @@ func (s *APIV1Service) DeleteMemoReaction(ctx context.Context, request *v1pb.Del return nil, status.Errorf(codes.InvalidArgument, "invalid reaction name: %v", err) } - // Get reaction and check ownership + // Get reaction and check ownership. reaction, err := s.Store.GetReaction(ctx, &store.FindReaction{ ID: &reactionID, }) @@ -76,7 +76,7 @@ func (s *APIV1Service) DeleteMemoReaction(ctx context.Context, request *v1pb.Del return nil, status.Errorf(codes.Internal, "failed to get reaction") } if reaction == nil { - // Return permission denied to avoid revealing if reaction exists + // Return permission denied to avoid revealing if reaction exists. return nil, status.Errorf(codes.PermissionDenied, "permission denied") } diff --git a/store/db/sqlite/reaction.go b/store/db/sqlite/reaction.go index 63247d511..47a582716 100644 --- a/store/db/sqlite/reaction.go +++ b/store/db/sqlite/reaction.go @@ -88,40 +88,15 @@ func (d *DB) ListReactions(ctx context.Context, find *store.FindReaction) ([]*st } func (d *DB) GetReaction(ctx context.Context, find *store.FindReaction) (*store.Reaction, error) { - where, args := []string{"1 = 1"}, []any{} - - if find.ID != nil { - where, args = append(where, "id = ?"), append(args, *find.ID) - } - if find.CreatorID != nil { - where, args = append(where, "creator_id = ?"), append(args, *find.CreatorID) - } - if find.ContentID != nil { - where, args = append(where, "content_id = ?"), append(args, *find.ContentID) - } - - reaction := &store.Reaction{} - if err := d.db.QueryRowContext(ctx, ` - SELECT - id, - created_ts, - creator_id, - content_id, - reaction_type - FROM reaction - WHERE `+strings.Join(where, " AND ")+` - LIMIT 1`, - args..., - ).Scan( - &reaction.ID, - &reaction.CreatedTs, - &reaction.CreatorID, - &reaction.ContentID, - &reaction.ReactionType, - ); err != nil { + list, err := d.ListReactions(ctx, find) + if err != nil { return nil, err } + if len(list) == 0 { + return nil, nil + } + reaction := list[0] return reaction, nil }