diff --git a/cmd/server/main.go b/cmd/server/main.go index 6b39ed0..5697ab2 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,6 +1,18 @@ package main import ( + "bytes" + "context" + "database/sql" + "encoding/json" + "fmt" + "io" + "log" + "net/http" + "os" + "strings" + "time" + "Coves/internal/api/middleware" "Coves/internal/api/routes" "Coves/internal/atproto/auth" @@ -14,17 +26,6 @@ import ( "Coves/internal/core/posts" "Coves/internal/core/timeline" "Coves/internal/core/users" - "bytes" - "context" - "database/sql" - "encoding/json" - "fmt" - "io" - "log" - "net/http" - "os" - "strings" - "time" "github.com/go-chi/chi/v5" chiMiddleware "github.com/go-chi/chi/v5/middleware" diff --git a/internal/api/handlers/aggregator/errors.go b/internal/api/handlers/aggregator/errors.go index 10d7340..dc26053 100644 --- a/internal/api/handlers/aggregator/errors.go +++ b/internal/api/handlers/aggregator/errors.go @@ -1,10 +1,11 @@ package aggregator import ( - "Coves/internal/core/aggregators" "encoding/json" "log" "net/http" + + "Coves/internal/core/aggregators" ) // ErrorResponse represents an XRPC error response diff --git a/internal/api/handlers/aggregator/get_authorizations.go b/internal/api/handlers/aggregator/get_authorizations.go index 85b2171..dadf44a 100644 --- a/internal/api/handlers/aggregator/get_authorizations.go +++ b/internal/api/handlers/aggregator/get_authorizations.go @@ -1,11 +1,12 @@ package aggregator import ( - "Coves/internal/core/aggregators" "encoding/json" "log" "net/http" "strconv" + + "Coves/internal/core/aggregators" ) // GetAuthorizationsHandler handles listing authorizations for an aggregator diff --git a/internal/api/handlers/aggregator/get_services.go b/internal/api/handlers/aggregator/get_services.go index eb01ba6..5b5c22b 100644 --- a/internal/api/handlers/aggregator/get_services.go +++ b/internal/api/handlers/aggregator/get_services.go @@ -1,11 +1,12 @@ package aggregator import ( - "Coves/internal/core/aggregators" "encoding/json" "log" "net/http" "strings" + + "Coves/internal/core/aggregators" ) // GetServicesHandler handles aggregator service details retrieval diff --git a/internal/api/handlers/aggregator/list_for_community.go b/internal/api/handlers/aggregator/list_for_community.go index d899ffb..284945c 100644 --- a/internal/api/handlers/aggregator/list_for_community.go +++ b/internal/api/handlers/aggregator/list_for_community.go @@ -1,11 +1,12 @@ package aggregator import ( - "Coves/internal/core/aggregators" "encoding/json" "log" "net/http" "strconv" + + "Coves/internal/core/aggregators" ) // ListForCommunityHandler handles listing aggregators for a community diff --git a/internal/api/handlers/comments/errors.go b/internal/api/handlers/comments/errors.go index 8038eb4..1ab9ed5 100644 --- a/internal/api/handlers/comments/errors.go +++ b/internal/api/handlers/comments/errors.go @@ -1,10 +1,11 @@ package comments import ( - "Coves/internal/core/comments" "encoding/json" "log" "net/http" + + "Coves/internal/core/comments" ) // errorResponse represents a standardized JSON error response diff --git a/internal/api/handlers/comments/get_comments.go b/internal/api/handlers/comments/get_comments.go index cd8cec3..80ea037 100644 --- a/internal/api/handlers/comments/get_comments.go +++ b/internal/api/handlers/comments/get_comments.go @@ -3,12 +3,13 @@ package comments import ( - "Coves/internal/api/middleware" - "Coves/internal/core/comments" "encoding/json" "log" "net/http" "strconv" + + "Coves/internal/api/middleware" + "Coves/internal/core/comments" ) // GetCommentsHandler handles comment retrieval for posts diff --git a/internal/api/handlers/comments/middleware.go b/internal/api/handlers/comments/middleware.go index afad433..106a68b 100644 --- a/internal/api/handlers/comments/middleware.go +++ b/internal/api/handlers/comments/middleware.go @@ -1,8 +1,9 @@ package comments import ( - "Coves/internal/api/middleware" "net/http" + + "Coves/internal/api/middleware" ) // OptionalAuthMiddleware wraps the existing OptionalAuth middleware from the middleware package. diff --git a/internal/api/handlers/comments/service_adapter.go b/internal/api/handlers/comments/service_adapter.go index 92c315d..904161f 100644 --- a/internal/api/handlers/comments/service_adapter.go +++ b/internal/api/handlers/comments/service_adapter.go @@ -1,8 +1,9 @@ package comments import ( - "Coves/internal/core/comments" "net/http" + + "Coves/internal/core/comments" ) // ServiceAdapter adapts the core comments.Service to the handler's Service interface diff --git a/internal/api/handlers/community/block.go b/internal/api/handlers/community/block.go index 57b6860..51c47f8 100644 --- a/internal/api/handlers/community/block.go +++ b/internal/api/handlers/community/block.go @@ -1,13 +1,14 @@ package community import ( - "Coves/internal/api/middleware" - "Coves/internal/core/communities" "encoding/json" "log" "net/http" "regexp" "strings" + + "Coves/internal/api/middleware" + "Coves/internal/core/communities" ) // Package-level compiled regex for DID validation (compiled once at startup) diff --git a/internal/api/handlers/community/create.go b/internal/api/handlers/community/create.go index 1283b2b..bcfb472 100644 --- a/internal/api/handlers/community/create.go +++ b/internal/api/handlers/community/create.go @@ -1,10 +1,11 @@ package community import ( - "Coves/internal/api/middleware" - "Coves/internal/core/communities" "encoding/json" "net/http" + + "Coves/internal/api/middleware" + "Coves/internal/core/communities" ) // CreateHandler handles community creation diff --git a/internal/api/handlers/community/errors.go b/internal/api/handlers/community/errors.go index 07fa75d..25f73e8 100644 --- a/internal/api/handlers/community/errors.go +++ b/internal/api/handlers/community/errors.go @@ -1,10 +1,11 @@ package community import ( - "Coves/internal/core/communities" "encoding/json" "log" "net/http" + + "Coves/internal/core/communities" ) // XRPCError represents an XRPC error response diff --git a/internal/api/handlers/community/get.go b/internal/api/handlers/community/get.go index 7649385..c96ee2a 100644 --- a/internal/api/handlers/community/get.go +++ b/internal/api/handlers/community/get.go @@ -1,9 +1,10 @@ package community import ( - "Coves/internal/core/communities" "encoding/json" "net/http" + + "Coves/internal/core/communities" ) // GetHandler handles community retrieval diff --git a/internal/api/handlers/community/list.go b/internal/api/handlers/community/list.go index cde230a..8799f6e 100644 --- a/internal/api/handlers/community/list.go +++ b/internal/api/handlers/community/list.go @@ -1,10 +1,11 @@ package community import ( - "Coves/internal/core/communities" "encoding/json" "net/http" "strconv" + + "Coves/internal/core/communities" ) // ListHandler handles listing communities diff --git a/internal/api/handlers/community/search.go b/internal/api/handlers/community/search.go index 3490b0a..2292ab2 100644 --- a/internal/api/handlers/community/search.go +++ b/internal/api/handlers/community/search.go @@ -1,10 +1,11 @@ package community import ( - "Coves/internal/core/communities" "encoding/json" "net/http" "strconv" + + "Coves/internal/core/communities" ) // SearchHandler handles community search diff --git a/internal/api/handlers/community/subscribe.go b/internal/api/handlers/community/subscribe.go index 68cdbd3..0372fa9 100644 --- a/internal/api/handlers/community/subscribe.go +++ b/internal/api/handlers/community/subscribe.go @@ -1,12 +1,13 @@ package community import ( - "Coves/internal/api/middleware" - "Coves/internal/core/communities" "encoding/json" "log" "net/http" "strings" + + "Coves/internal/api/middleware" + "Coves/internal/core/communities" ) // SubscribeHandler handles community subscriptions diff --git a/internal/api/handlers/community/update.go b/internal/api/handlers/community/update.go index 728b9f8..32ce15a 100644 --- a/internal/api/handlers/community/update.go +++ b/internal/api/handlers/community/update.go @@ -1,10 +1,11 @@ package community import ( - "Coves/internal/api/middleware" - "Coves/internal/core/communities" "encoding/json" "net/http" + + "Coves/internal/api/middleware" + "Coves/internal/core/communities" ) // UpdateHandler handles community updates diff --git a/internal/api/handlers/communityFeed/errors.go b/internal/api/handlers/communityFeed/errors.go index d51bd4e..2eeb8c1 100644 --- a/internal/api/handlers/communityFeed/errors.go +++ b/internal/api/handlers/communityFeed/errors.go @@ -1,11 +1,12 @@ package communityFeed import ( - "Coves/internal/core/communityFeeds" "encoding/json" "errors" "log" "net/http" + + "Coves/internal/core/communityFeeds" ) // ErrorResponse represents an XRPC error response diff --git a/internal/api/handlers/communityFeed/get_community.go b/internal/api/handlers/communityFeed/get_community.go index f81562e..28ab149 100644 --- a/internal/api/handlers/communityFeed/get_community.go +++ b/internal/api/handlers/communityFeed/get_community.go @@ -1,11 +1,12 @@ package communityFeed import ( - "Coves/internal/core/communityFeeds" "encoding/json" "log" "net/http" "strconv" + + "Coves/internal/core/communityFeeds" ) // GetCommunityHandler handles community feed retrieval diff --git a/internal/api/handlers/discover/errors.go b/internal/api/handlers/discover/errors.go index 01c26f3..76ecba1 100644 --- a/internal/api/handlers/discover/errors.go +++ b/internal/api/handlers/discover/errors.go @@ -1,11 +1,12 @@ package discover import ( - "Coves/internal/core/discover" "encoding/json" "errors" "log" "net/http" + + "Coves/internal/core/discover" ) // XRPCError represents an XRPC error response diff --git a/internal/api/handlers/discover/get_discover.go b/internal/api/handlers/discover/get_discover.go index eea484b..4b4fbe3 100644 --- a/internal/api/handlers/discover/get_discover.go +++ b/internal/api/handlers/discover/get_discover.go @@ -1,11 +1,12 @@ package discover import ( - "Coves/internal/core/discover" "encoding/json" "log" "net/http" "strconv" + + "Coves/internal/core/discover" ) // GetDiscoverHandler handles discover feed retrieval diff --git a/internal/api/handlers/post/create.go b/internal/api/handlers/post/create.go index 06f77fa..ba44c08 100644 --- a/internal/api/handlers/post/create.go +++ b/internal/api/handlers/post/create.go @@ -1,12 +1,13 @@ package post import ( - "Coves/internal/api/middleware" - "Coves/internal/core/posts" "encoding/json" "log" "net/http" "strings" + + "Coves/internal/api/middleware" + "Coves/internal/core/posts" ) // CreateHandler handles post creation requests diff --git a/internal/api/handlers/post/errors.go b/internal/api/handlers/post/errors.go index cebade5..8aadb83 100644 --- a/internal/api/handlers/post/errors.go +++ b/internal/api/handlers/post/errors.go @@ -1,11 +1,12 @@ package post import ( - "Coves/internal/core/aggregators" - "Coves/internal/core/posts" "encoding/json" "log" "net/http" + + "Coves/internal/core/aggregators" + "Coves/internal/core/posts" ) type errorResponse struct { diff --git a/internal/api/handlers/timeline/errors.go b/internal/api/handlers/timeline/errors.go index c91f039..a8f9e29 100644 --- a/internal/api/handlers/timeline/errors.go +++ b/internal/api/handlers/timeline/errors.go @@ -1,11 +1,12 @@ package timeline import ( - "Coves/internal/core/timeline" "encoding/json" "errors" "log" "net/http" + + "Coves/internal/core/timeline" ) // XRPCError represents an XRPC error response diff --git a/internal/api/handlers/timeline/get_timeline.go b/internal/api/handlers/timeline/get_timeline.go index af23e76..60bd36f 100644 --- a/internal/api/handlers/timeline/get_timeline.go +++ b/internal/api/handlers/timeline/get_timeline.go @@ -1,13 +1,14 @@ package timeline import ( - "Coves/internal/api/middleware" - "Coves/internal/core/timeline" "encoding/json" "log" "net/http" "strconv" "strings" + + "Coves/internal/api/middleware" + "Coves/internal/core/timeline" ) // GetTimelineHandler handles timeline feed retrieval diff --git a/internal/api/middleware/auth.go b/internal/api/middleware/auth.go index f273532..99b57db 100644 --- a/internal/api/middleware/auth.go +++ b/internal/api/middleware/auth.go @@ -1,11 +1,12 @@ package middleware import ( - "Coves/internal/atproto/auth" "context" "log" "net/http" "strings" + + "Coves/internal/atproto/auth" ) // Context keys for storing user information diff --git a/internal/api/routes/user.go b/internal/api/routes/user.go index e0f942c..3a17ddf 100644 --- a/internal/api/routes/user.go +++ b/internal/api/routes/user.go @@ -1,13 +1,14 @@ package routes import ( - "Coves/internal/core/users" "encoding/json" "errors" "log" "net/http" "time" + "Coves/internal/core/users" + "github.com/go-chi/chi/v5" ) diff --git a/internal/atproto/jetstream/aggregator_consumer.go b/internal/atproto/jetstream/aggregator_consumer.go index 49afd77..d4438a9 100644 --- a/internal/atproto/jetstream/aggregator_consumer.go +++ b/internal/atproto/jetstream/aggregator_consumer.go @@ -1,12 +1,13 @@ package jetstream import ( - "Coves/internal/core/aggregators" "context" "encoding/json" "fmt" "log" "time" + + "Coves/internal/core/aggregators" ) // AggregatorEventConsumer consumes aggregator-related events from Jetstream diff --git a/internal/atproto/jetstream/comment_consumer.go b/internal/atproto/jetstream/comment_consumer.go index 6ecb2a8..0760dff 100644 --- a/internal/atproto/jetstream/comment_consumer.go +++ b/internal/atproto/jetstream/comment_consumer.go @@ -1,8 +1,6 @@ package jetstream import ( - "Coves/internal/atproto/utils" - "Coves/internal/core/comments" "context" "database/sql" "encoding/json" @@ -11,6 +9,9 @@ import ( "strings" "time" + "Coves/internal/atproto/utils" + "Coves/internal/core/comments" + "github.com/lib/pq" ) diff --git a/internal/atproto/jetstream/community_consumer.go b/internal/atproto/jetstream/community_consumer.go index 3a94d3c..5dd4f7a 100644 --- a/internal/atproto/jetstream/community_consumer.go +++ b/internal/atproto/jetstream/community_consumer.go @@ -1,9 +1,6 @@ package jetstream import ( - "Coves/internal/atproto/identity" - "Coves/internal/atproto/utils" - "Coves/internal/core/communities" "context" "encoding/json" "fmt" @@ -12,6 +9,10 @@ import ( "strings" "time" + "Coves/internal/atproto/identity" + "Coves/internal/atproto/utils" + "Coves/internal/core/communities" + lru "github.com/hashicorp/golang-lru/v2" "golang.org/x/net/publicsuffix" "golang.org/x/time/rate" diff --git a/internal/atproto/jetstream/post_consumer.go b/internal/atproto/jetstream/post_consumer.go index 0ac373e..aa4fa3b 100644 --- a/internal/atproto/jetstream/post_consumer.go +++ b/internal/atproto/jetstream/post_consumer.go @@ -1,9 +1,6 @@ package jetstream import ( - "Coves/internal/core/communities" - "Coves/internal/core/posts" - "Coves/internal/core/users" "context" "database/sql" "encoding/json" @@ -11,6 +8,10 @@ import ( "log" "strings" "time" + + "Coves/internal/core/communities" + "Coves/internal/core/posts" + "Coves/internal/core/users" ) // PostEventConsumer consumes post-related events from Jetstream diff --git a/internal/atproto/jetstream/user_consumer.go b/internal/atproto/jetstream/user_consumer.go index ee1be2f..07166f0 100644 --- a/internal/atproto/jetstream/user_consumer.go +++ b/internal/atproto/jetstream/user_consumer.go @@ -1,8 +1,6 @@ package jetstream import ( - "Coves/internal/atproto/identity" - "Coves/internal/core/users" "context" "encoding/json" "fmt" @@ -10,6 +8,9 @@ import ( "sync" "time" + "Coves/internal/atproto/identity" + "Coves/internal/core/users" + "github.com/gorilla/websocket" ) diff --git a/internal/atproto/jetstream/vote_consumer.go b/internal/atproto/jetstream/vote_consumer.go index 3f97fbb..078fc87 100644 --- a/internal/atproto/jetstream/vote_consumer.go +++ b/internal/atproto/jetstream/vote_consumer.go @@ -1,15 +1,16 @@ package jetstream import ( - "Coves/internal/atproto/utils" - "Coves/internal/core/users" - "Coves/internal/core/votes" "context" "database/sql" "fmt" "log" "strings" "time" + + "Coves/internal/atproto/utils" + "Coves/internal/core/users" + "Coves/internal/core/votes" ) // VoteEventConsumer consumes vote-related events from Jetstream diff --git a/internal/core/aggregators/service.go b/internal/core/aggregators/service.go index 5864eec..f19aa55 100644 --- a/internal/core/aggregators/service.go +++ b/internal/core/aggregators/service.go @@ -1,12 +1,13 @@ package aggregators import ( - "Coves/internal/core/communities" "context" "encoding/json" "fmt" "time" + "Coves/internal/core/communities" + "github.com/xeipuuv/gojsonschema" ) diff --git a/internal/core/communities/service.go b/internal/core/communities/service.go index 2d74c4f..91da264 100644 --- a/internal/core/communities/service.go +++ b/internal/core/communities/service.go @@ -1,7 +1,6 @@ package communities import ( - "Coves/internal/atproto/utils" "bytes" "context" "encoding/json" @@ -14,6 +13,8 @@ import ( "strings" "sync" "time" + + "Coves/internal/atproto/utils" ) // Community handle validation regex (DNS-valid handle: name.community.instance.com) diff --git a/internal/core/communityFeeds/service.go b/internal/core/communityFeeds/service.go index fa5ccd2..b9b21d3 100644 --- a/internal/core/communityFeeds/service.go +++ b/internal/core/communityFeeds/service.go @@ -1,9 +1,10 @@ package communityFeeds import ( - "Coves/internal/core/communities" "context" "fmt" + + "Coves/internal/core/communities" ) type feedService struct { diff --git a/internal/core/communityFeeds/types.go b/internal/core/communityFeeds/types.go index d046847..e3ab14b 100644 --- a/internal/core/communityFeeds/types.go +++ b/internal/core/communityFeeds/types.go @@ -1,8 +1,9 @@ package communityFeeds import ( - "Coves/internal/core/posts" "time" + + "Coves/internal/core/posts" ) // GetCommunityFeedRequest represents input for fetching a community feed diff --git a/internal/core/discover/types.go b/internal/core/discover/types.go index aa03b8f..73ab1be 100644 --- a/internal/core/discover/types.go +++ b/internal/core/discover/types.go @@ -1,9 +1,10 @@ package discover import ( - "Coves/internal/core/posts" "context" "errors" + + "Coves/internal/core/posts" ) // Repository defines discover data access interface diff --git a/internal/core/posts/service.go b/internal/core/posts/service.go index ff698ec..8550109 100644 --- a/internal/core/posts/service.go +++ b/internal/core/posts/service.go @@ -1,9 +1,6 @@ package posts import ( - "Coves/internal/api/middleware" - "Coves/internal/core/aggregators" - "Coves/internal/core/communities" "bytes" "context" "encoding/json" @@ -12,6 +9,10 @@ import ( "log" "net/http" "time" + + "Coves/internal/api/middleware" + "Coves/internal/core/aggregators" + "Coves/internal/core/communities" ) type postService struct { diff --git a/internal/core/timeline/types.go b/internal/core/timeline/types.go index 557293f..fa007fb 100644 --- a/internal/core/timeline/types.go +++ b/internal/core/timeline/types.go @@ -1,10 +1,11 @@ package timeline import ( - "Coves/internal/core/posts" "context" "errors" "time" + + "Coves/internal/core/posts" ) // Repository defines timeline data access interface diff --git a/internal/core/users/service.go b/internal/core/users/service.go index b8ec49b..3273df2 100644 --- a/internal/core/users/service.go +++ b/internal/core/users/service.go @@ -1,7 +1,6 @@ package users import ( - "Coves/internal/atproto/identity" "bytes" "context" "encoding/json" @@ -12,6 +11,8 @@ import ( "regexp" "strings" "time" + + "Coves/internal/atproto/identity" ) // atProto handle validation regex (per official atProto spec: https://atproto.com/specs/handle) diff --git a/internal/db/postgres/aggregator_repo.go b/internal/db/postgres/aggregator_repo.go index ae5c731..fd49a73 100644 --- a/internal/db/postgres/aggregator_repo.go +++ b/internal/db/postgres/aggregator_repo.go @@ -1,12 +1,13 @@ package postgres import ( - "Coves/internal/core/aggregators" "context" "database/sql" "fmt" "strings" "time" + + "Coves/internal/core/aggregators" ) type postgresAggregatorRepo struct { diff --git a/internal/db/postgres/comment_repo.go b/internal/db/postgres/comment_repo.go index 52c3b8c..45b7cf8 100644 --- a/internal/db/postgres/comment_repo.go +++ b/internal/db/postgres/comment_repo.go @@ -1,7 +1,6 @@ package postgres import ( - "Coves/internal/core/comments" "context" "database/sql" "encoding/base64" @@ -9,6 +8,8 @@ import ( "log" "strings" + "Coves/internal/core/comments" + "github.com/lib/pq" ) diff --git a/internal/db/postgres/community_repo.go b/internal/db/postgres/community_repo.go index 31f3685..4a243d5 100644 --- a/internal/db/postgres/community_repo.go +++ b/internal/db/postgres/community_repo.go @@ -1,13 +1,14 @@ package postgres import ( - "Coves/internal/core/communities" "context" "database/sql" "fmt" "log" "strings" + "Coves/internal/core/communities" + "github.com/lib/pq" ) diff --git a/internal/db/postgres/community_repo_blocks.go b/internal/db/postgres/community_repo_blocks.go index f1b172d..0f17790 100644 --- a/internal/db/postgres/community_repo_blocks.go +++ b/internal/db/postgres/community_repo_blocks.go @@ -1,11 +1,12 @@ package postgres import ( - "Coves/internal/core/communities" "context" "database/sql" "fmt" "log" + + "Coves/internal/core/communities" ) // BlockCommunity creates a new block record (idempotent) diff --git a/internal/db/postgres/community_repo_memberships.go b/internal/db/postgres/community_repo_memberships.go index 562c9db..c6cf564 100644 --- a/internal/db/postgres/community_repo_memberships.go +++ b/internal/db/postgres/community_repo_memberships.go @@ -1,12 +1,13 @@ package postgres import ( - "Coves/internal/core/communities" "context" "database/sql" "fmt" "log" "strings" + + "Coves/internal/core/communities" ) // CreateMembership creates a new membership record diff --git a/internal/db/postgres/community_repo_subscriptions.go b/internal/db/postgres/community_repo_subscriptions.go index 3763d7b..465c948 100644 --- a/internal/db/postgres/community_repo_subscriptions.go +++ b/internal/db/postgres/community_repo_subscriptions.go @@ -1,12 +1,13 @@ package postgres import ( - "Coves/internal/core/communities" "context" "database/sql" "fmt" "log" "strings" + + "Coves/internal/core/communities" ) // Subscribe creates a new subscription record diff --git a/internal/db/postgres/discover_repo.go b/internal/db/postgres/discover_repo.go index ea933eb..8e7d3c1 100644 --- a/internal/db/postgres/discover_repo.go +++ b/internal/db/postgres/discover_repo.go @@ -1,10 +1,11 @@ package postgres import ( - "Coves/internal/core/discover" "context" "database/sql" "fmt" + + "Coves/internal/core/discover" ) type postgresDiscoverRepo struct { diff --git a/internal/db/postgres/feed_repo.go b/internal/db/postgres/feed_repo.go index 7587f9d..7c3584d 100644 --- a/internal/db/postgres/feed_repo.go +++ b/internal/db/postgres/feed_repo.go @@ -1,8 +1,6 @@ package postgres import ( - "Coves/internal/core/communityFeeds" - "Coves/internal/core/posts" "context" "database/sql" "encoding/base64" @@ -11,6 +9,9 @@ import ( "strconv" "strings" "time" + + "Coves/internal/core/communityFeeds" + "Coves/internal/core/posts" ) type postgresFeedRepo struct { diff --git a/internal/db/postgres/feed_repo_base.go b/internal/db/postgres/feed_repo_base.go index 874b5a3..e2923e3 100644 --- a/internal/db/postgres/feed_repo_base.go +++ b/internal/db/postgres/feed_repo_base.go @@ -1,7 +1,6 @@ package postgres import ( - "Coves/internal/core/posts" "crypto/hmac" "crypto/sha256" "database/sql" @@ -12,6 +11,8 @@ import ( "strconv" "strings" "time" + + "Coves/internal/core/posts" ) // feedRepoBase contains shared logic for timeline and discover feed repositories diff --git a/internal/db/postgres/post_repo.go b/internal/db/postgres/post_repo.go index 6363ea9..6493047 100644 --- a/internal/db/postgres/post_repo.go +++ b/internal/db/postgres/post_repo.go @@ -1,11 +1,12 @@ package postgres import ( - "Coves/internal/core/posts" "context" "database/sql" "fmt" "strings" + + "Coves/internal/core/posts" ) type postgresPostRepo struct { diff --git a/internal/db/postgres/timeline_repo.go b/internal/db/postgres/timeline_repo.go index 83435f7..28b797e 100644 --- a/internal/db/postgres/timeline_repo.go +++ b/internal/db/postgres/timeline_repo.go @@ -1,10 +1,11 @@ package postgres import ( - "Coves/internal/core/timeline" "context" "database/sql" "fmt" + + "Coves/internal/core/timeline" ) type postgresTimelineRepo struct { diff --git a/internal/db/postgres/user_repo.go b/internal/db/postgres/user_repo.go index 9a0e760..01ef54d 100644 --- a/internal/db/postgres/user_repo.go +++ b/internal/db/postgres/user_repo.go @@ -1,12 +1,14 @@ package postgres import ( - "Coves/internal/core/users" "context" "database/sql" "fmt" + "log" "strings" + "Coves/internal/core/users" + "github.com/lib/pq" ) @@ -137,7 +139,11 @@ func (r *postgresUserRepo) GetByDIDs(ctx context.Context, dids []string) (map[st if err != nil { return nil, fmt.Errorf("failed to query users by DIDs: %w", err) } - defer rows.Close() + defer func() { + if closeErr := rows.Close(); closeErr != nil { + log.Printf("Warning: Failed to close rows: %v", closeErr) + } + }() // Build map of results result := make(map[string]*users.User, len(dids)) diff --git a/internal/db/postgres/vote_repo.go b/internal/db/postgres/vote_repo.go index 166c8ae..e6cfb75 100644 --- a/internal/db/postgres/vote_repo.go +++ b/internal/db/postgres/vote_repo.go @@ -1,11 +1,12 @@ package postgres import ( - "Coves/internal/core/votes" "context" "database/sql" "fmt" "strings" + + "Coves/internal/core/votes" ) type postgresVoteRepo struct { diff --git a/internal/db/postgres/vote_repo_test.go b/internal/db/postgres/vote_repo_test.go index 69d2249..fb8f332 100644 --- a/internal/db/postgres/vote_repo_test.go +++ b/internal/db/postgres/vote_repo_test.go @@ -1,13 +1,14 @@ package postgres import ( - "Coves/internal/core/votes" "context" "database/sql" "os" "testing" "time" + "Coves/internal/core/votes" + _ "github.com/lib/pq" "github.com/pressly/goose/v3" "github.com/stretchr/testify/assert" diff --git a/tests/e2e/user_signup_test.go b/tests/e2e/user_signup_test.go index 3f6ac9b..9a6ff31 100644 --- a/tests/e2e/user_signup_test.go +++ b/tests/e2e/user_signup_test.go @@ -1,10 +1,6 @@ package e2e import ( - "Coves/internal/atproto/identity" - "Coves/internal/atproto/jetstream" - "Coves/internal/core/users" - "Coves/internal/db/postgres" "bytes" "context" "database/sql" @@ -15,6 +11,11 @@ import ( "testing" "time" + "Coves/internal/atproto/identity" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/users" + "Coves/internal/db/postgres" + _ "github.com/lib/pq" "github.com/pressly/goose/v3" ) diff --git a/tests/integration/aggregator_e2e_test.go b/tests/integration/aggregator_e2e_test.go index ed427e1..ef36940 100644 --- a/tests/integration/aggregator_e2e_test.go +++ b/tests/integration/aggregator_e2e_test.go @@ -1,16 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/aggregator" - "Coves/internal/api/handlers/post" - "Coves/internal/api/middleware" - "Coves/internal/atproto/identity" - "Coves/internal/atproto/jetstream" - "Coves/internal/core/aggregators" - "Coves/internal/core/communities" - "Coves/internal/core/posts" - "Coves/internal/core/users" - "Coves/internal/db/postgres" "bytes" "context" "database/sql" @@ -23,6 +13,17 @@ import ( "testing" "time" + "Coves/internal/api/handlers/aggregator" + "Coves/internal/api/handlers/post" + "Coves/internal/api/middleware" + "Coves/internal/atproto/identity" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/aggregators" + "Coves/internal/core/communities" + "Coves/internal/core/posts" + "Coves/internal/core/users" + "Coves/internal/db/postgres" + _ "github.com/lib/pq" "github.com/pressly/goose/v3" "github.com/stretchr/testify/assert" diff --git a/tests/integration/aggregator_test.go b/tests/integration/aggregator_test.go index ea0af30..0bb7116 100644 --- a/tests/integration/aggregator_test.go +++ b/tests/integration/aggregator_test.go @@ -1,14 +1,15 @@ package integration import ( - "Coves/internal/core/aggregators" - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "encoding/json" "fmt" "testing" "time" + + "Coves/internal/core/aggregators" + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestAggregatorRepository_Create tests basic aggregator creation diff --git a/tests/integration/comment_consumer_test.go b/tests/integration/comment_consumer_test.go index 9fda772..37329ea 100644 --- a/tests/integration/comment_consumer_test.go +++ b/tests/integration/comment_consumer_test.go @@ -1,13 +1,14 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/core/comments" - "Coves/internal/db/postgres" "context" "fmt" "testing" "time" + + "Coves/internal/atproto/jetstream" + "Coves/internal/core/comments" + "Coves/internal/db/postgres" ) func TestCommentConsumer_CreateComment(t *testing.T) { diff --git a/tests/integration/comment_query_test.go b/tests/integration/comment_query_test.go index a0d53c5..4f084bc 100644 --- a/tests/integration/comment_query_test.go +++ b/tests/integration/comment_query_test.go @@ -1,9 +1,6 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/core/comments" - "Coves/internal/db/postgres" "context" "database/sql" "encoding/json" @@ -14,6 +11,10 @@ import ( "testing" "time" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/comments" + "Coves/internal/db/postgres" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/tests/integration/community_blocking_test.go b/tests/integration/community_blocking_test.go index ea2e188..abdbba5 100644 --- a/tests/integration/community_blocking_test.go +++ b/tests/integration/community_blocking_test.go @@ -1,14 +1,15 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/core/communities" "context" "database/sql" "fmt" "testing" "time" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/communities" + postgresRepo "Coves/internal/db/postgres" ) diff --git a/tests/integration/community_consumer_test.go b/tests/integration/community_consumer_test.go index 5039918..a6c8dbd 100644 --- a/tests/integration/community_consumer_test.go +++ b/tests/integration/community_consumer_test.go @@ -1,15 +1,16 @@ package integration import ( - "Coves/internal/atproto/identity" - "Coves/internal/atproto/jetstream" - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "errors" "fmt" "testing" "time" + + "Coves/internal/atproto/identity" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) func TestCommunityConsumer_HandleCommunityProfile(t *testing.T) { diff --git a/tests/integration/community_credentials_test.go b/tests/integration/community_credentials_test.go index fa39c03..e39c2d6 100644 --- a/tests/integration/community_credentials_test.go +++ b/tests/integration/community_credentials_test.go @@ -1,12 +1,13 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "fmt" "testing" "time" + + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestCommunityRepository_CredentialPersistence tests that PDS credentials are properly persisted diff --git a/tests/integration/community_e2e_test.go b/tests/integration/community_e2e_test.go index 986da13..d0ca3f2 100644 --- a/tests/integration/community_e2e_test.go +++ b/tests/integration/community_e2e_test.go @@ -1,14 +1,6 @@ package integration import ( - "Coves/internal/api/middleware" - "Coves/internal/api/routes" - "Coves/internal/atproto/identity" - "Coves/internal/atproto/jetstream" - "Coves/internal/atproto/utils" - "Coves/internal/core/communities" - "Coves/internal/core/users" - "Coves/internal/db/postgres" "bytes" "context" "database/sql" @@ -23,6 +15,15 @@ import ( "testing" "time" + "Coves/internal/api/middleware" + "Coves/internal/api/routes" + "Coves/internal/atproto/identity" + "Coves/internal/atproto/jetstream" + "Coves/internal/atproto/utils" + "Coves/internal/core/communities" + "Coves/internal/core/users" + "Coves/internal/db/postgres" + "github.com/go-chi/chi/v5" "github.com/gorilla/websocket" _ "github.com/lib/pq" diff --git a/tests/integration/community_hostedby_security_test.go b/tests/integration/community_hostedby_security_test.go index fd87043..d34c808 100644 --- a/tests/integration/community_hostedby_security_test.go +++ b/tests/integration/community_hostedby_security_test.go @@ -1,12 +1,13 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/db/postgres" "context" "fmt" "testing" "time" + + "Coves/internal/atproto/jetstream" + "Coves/internal/db/postgres" ) // TestHostedByVerification_DomainMatching tests that hostedBy domain must match handle domain diff --git a/tests/integration/community_identifier_resolution_test.go b/tests/integration/community_identifier_resolution_test.go index 6571fb1..9f254a4 100644 --- a/tests/integration/community_identifier_resolution_test.go +++ b/tests/integration/community_identifier_resolution_test.go @@ -1,8 +1,6 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "fmt" "os" @@ -10,6 +8,9 @@ import ( "testing" "time" + "Coves/internal/core/communities" + "Coves/internal/db/postgres" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/tests/integration/community_provisioning_test.go b/tests/integration/community_provisioning_test.go index c67c9d6..c6a61e9 100644 --- a/tests/integration/community_provisioning_test.go +++ b/tests/integration/community_provisioning_test.go @@ -1,13 +1,14 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "fmt" "strings" "testing" "time" + + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestCommunityRepository_PasswordEncryption verifies P0 fix: diff --git a/tests/integration/community_repo_test.go b/tests/integration/community_repo_test.go index 5c094ae..e7537f8 100644 --- a/tests/integration/community_repo_test.go +++ b/tests/integration/community_repo_test.go @@ -1,12 +1,13 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "fmt" "testing" "time" + + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) func TestCommunityRepository_Create(t *testing.T) { diff --git a/tests/integration/community_service_integration_test.go b/tests/integration/community_service_integration_test.go index 34cb13f..abfd4ac 100644 --- a/tests/integration/community_service_integration_test.go +++ b/tests/integration/community_service_integration_test.go @@ -1,8 +1,6 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "bytes" "context" "encoding/json" @@ -12,6 +10,9 @@ import ( "strings" "testing" "time" + + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestCommunityService_CreateWithRealPDS tests the complete service layer flow diff --git a/tests/integration/community_v2_validation_test.go b/tests/integration/community_v2_validation_test.go index 126fdee..0f771d5 100644 --- a/tests/integration/community_v2_validation_test.go +++ b/tests/integration/community_v2_validation_test.go @@ -1,13 +1,14 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "fmt" "testing" "time" + + "Coves/internal/atproto/jetstream" + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestCommunityConsumer_V2RKeyValidation tests that only V2 communities (rkey="self") are accepted diff --git a/tests/integration/discover_test.go b/tests/integration/discover_test.go index 2da1c4d..2af579f 100644 --- a/tests/integration/discover_test.go +++ b/tests/integration/discover_test.go @@ -1,8 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/discover" - "Coves/internal/db/postgres" "context" "encoding/json" "fmt" @@ -11,6 +9,9 @@ import ( "testing" "time" + "Coves/internal/api/handlers/discover" + "Coves/internal/db/postgres" + discoverCore "Coves/internal/core/discover" "github.com/stretchr/testify/assert" diff --git a/tests/integration/feed_test.go b/tests/integration/feed_test.go index a4051de..c74951d 100644 --- a/tests/integration/feed_test.go +++ b/tests/integration/feed_test.go @@ -1,10 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/communityFeed" - "Coves/internal/core/communities" - "Coves/internal/core/communityFeeds" - "Coves/internal/db/postgres" "context" "encoding/json" "fmt" @@ -13,6 +9,11 @@ import ( "testing" "time" + "Coves/internal/api/handlers/communityFeed" + "Coves/internal/core/communities" + "Coves/internal/core/communityFeeds" + "Coves/internal/db/postgres" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/tests/integration/helpers.go b/tests/integration/helpers.go index 717b41c..e806bbb 100644 --- a/tests/integration/helpers.go +++ b/tests/integration/helpers.go @@ -1,8 +1,6 @@ package integration import ( - "Coves/internal/atproto/auth" - "Coves/internal/core/users" "bytes" "context" "database/sql" @@ -15,6 +13,9 @@ import ( "testing" "time" + "Coves/internal/atproto/auth" + "Coves/internal/core/users" + "github.com/golang-jwt/jwt/v5" ) diff --git a/tests/integration/identity_resolution_test.go b/tests/integration/identity_resolution_test.go index fc7fd9b..494dc12 100644 --- a/tests/integration/identity_resolution_test.go +++ b/tests/integration/identity_resolution_test.go @@ -1,12 +1,13 @@ package integration import ( - "Coves/internal/atproto/identity" "context" "fmt" "os" "testing" "time" + + "Coves/internal/atproto/identity" ) // uniqueID generates a unique identifier for test isolation diff --git a/tests/integration/jetstream_consumer_test.go b/tests/integration/jetstream_consumer_test.go index 16d76c9..8dfdd9f 100644 --- a/tests/integration/jetstream_consumer_test.go +++ b/tests/integration/jetstream_consumer_test.go @@ -1,13 +1,14 @@ package integration import ( + "context" + "testing" + "time" + "Coves/internal/atproto/identity" "Coves/internal/atproto/jetstream" "Coves/internal/core/users" "Coves/internal/db/postgres" - "context" - "testing" - "time" ) func TestUserIndexingFromJetstream(t *testing.T) { diff --git a/tests/integration/post_creation_test.go b/tests/integration/post_creation_test.go index c8db667..dd7faf3 100644 --- a/tests/integration/post_creation_test.go +++ b/tests/integration/post_creation_test.go @@ -1,16 +1,17 @@ package integration import ( + "context" + "fmt" + "strings" + "testing" + "Coves/internal/api/middleware" "Coves/internal/atproto/identity" "Coves/internal/core/communities" "Coves/internal/core/posts" "Coves/internal/core/users" "Coves/internal/db/postgres" - "context" - "fmt" - "strings" - "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/tests/integration/post_e2e_test.go b/tests/integration/post_e2e_test.go index 33f8cc0..8946dd0 100644 --- a/tests/integration/post_e2e_test.go +++ b/tests/integration/post_e2e_test.go @@ -1,14 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/post" - "Coves/internal/api/middleware" - "Coves/internal/atproto/identity" - "Coves/internal/atproto/jetstream" - "Coves/internal/core/communities" - "Coves/internal/core/posts" - "Coves/internal/core/users" - "Coves/internal/db/postgres" "bytes" "context" "database/sql" @@ -22,6 +14,15 @@ import ( "testing" "time" + "Coves/internal/api/handlers/post" + "Coves/internal/api/middleware" + "Coves/internal/atproto/identity" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/communities" + "Coves/internal/core/posts" + "Coves/internal/core/users" + "Coves/internal/db/postgres" + "github.com/gorilla/websocket" _ "github.com/lib/pq" "github.com/pressly/goose/v3" diff --git a/tests/integration/post_handler_test.go b/tests/integration/post_handler_test.go index 71819f6..f135401 100644 --- a/tests/integration/post_handler_test.go +++ b/tests/integration/post_handler_test.go @@ -1,11 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/post" - "Coves/internal/api/middleware" - "Coves/internal/core/communities" - "Coves/internal/core/posts" - "Coves/internal/db/postgres" "bytes" "encoding/json" "net/http" @@ -13,6 +8,12 @@ import ( "strings" "testing" + "Coves/internal/api/handlers/post" + "Coves/internal/api/middleware" + "Coves/internal/core/communities" + "Coves/internal/core/posts" + "Coves/internal/db/postgres" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/tests/integration/subscription_indexing_test.go b/tests/integration/subscription_indexing_test.go index 532a592..9b3d827 100644 --- a/tests/integration/subscription_indexing_test.go +++ b/tests/integration/subscription_indexing_test.go @@ -1,14 +1,15 @@ package integration import ( - "Coves/internal/atproto/jetstream" - "Coves/internal/core/communities" "context" "database/sql" "fmt" "testing" "time" + "Coves/internal/atproto/jetstream" + "Coves/internal/core/communities" + postgresRepo "Coves/internal/db/postgres" ) diff --git a/tests/integration/timeline_test.go b/tests/integration/timeline_test.go index a24982c..21a3edf 100644 --- a/tests/integration/timeline_test.go +++ b/tests/integration/timeline_test.go @@ -1,9 +1,6 @@ package integration import ( - "Coves/internal/api/handlers/timeline" - "Coves/internal/api/middleware" - "Coves/internal/db/postgres" "context" "encoding/json" "fmt" @@ -12,6 +9,10 @@ import ( "testing" "time" + "Coves/internal/api/handlers/timeline" + "Coves/internal/api/middleware" + "Coves/internal/db/postgres" + timelineCore "Coves/internal/core/timeline" "github.com/stretchr/testify/assert" diff --git a/tests/integration/token_refresh_test.go b/tests/integration/token_refresh_test.go index 984925b..e24f130 100644 --- a/tests/integration/token_refresh_test.go +++ b/tests/integration/token_refresh_test.go @@ -1,14 +1,15 @@ package integration import ( - "Coves/internal/core/communities" - "Coves/internal/db/postgres" "context" "encoding/base64" "encoding/json" "fmt" "testing" "time" + + "Coves/internal/core/communities" + "Coves/internal/db/postgres" ) // TestTokenRefresh_ExpirationDetection tests the NeedsRefresh function with various token states diff --git a/tests/integration/user_test.go b/tests/integration/user_test.go index 19ca4c1..ae26249 100644 --- a/tests/integration/user_test.go +++ b/tests/integration/user_test.go @@ -1,10 +1,6 @@ package integration import ( - "Coves/internal/api/routes" - "Coves/internal/atproto/identity" - "Coves/internal/core/users" - "Coves/internal/db/postgres" "context" "database/sql" "encoding/json" @@ -15,6 +11,11 @@ import ( "strings" "testing" + "Coves/internal/api/routes" + "Coves/internal/atproto/identity" + "Coves/internal/core/users" + "Coves/internal/db/postgres" + "github.com/go-chi/chi/v5" _ "github.com/lib/pq" "github.com/pressly/goose/v3" diff --git a/tests/unit/community_service_test.go b/tests/unit/community_service_test.go index 06da2e6..ac71022 100644 --- a/tests/unit/community_service_test.go +++ b/tests/unit/community_service_test.go @@ -1,7 +1,6 @@ package unit import ( - "Coves/internal/core/communities" "context" "fmt" "net/http" @@ -10,6 +9,8 @@ import ( "sync/atomic" "testing" "time" + + "Coves/internal/core/communities" ) // mockCommunityRepo is a minimal mock for testing service layer