···
4
+
"Coves/internal/atproto/utils"
···
// Extract rkey from record URI (at://did/collection/rkey)
458
-
rkey := extractRKeyFromURI(subscription.RecordURI)
459
+
rkey := utils.ExtractRKeyFromURI(subscription.RecordURI)
return fmt.Errorf("invalid subscription record URI")
···
return nil, NewValidationError("userAccessToken", "required")
528
-
// Resolve community identifier
529
+
// Resolve community identifier (also verifies community exists)
communityDID, err := s.ResolveCommunityIdentifier(ctx, communityIdentifier)
534
-
// Verify community exists
535
-
_, err = s.repo.GetByDID(ctx, communityDID)
// CRITICAL: Collection is social.coves.community.block (RECORD TYPE)
// This record will be created in the USER's repository: at://user_did/social.coves.community.block/{tid}
···
// Fetch and return existing block from our indexed view
existingBlock, getErr := s.repo.GetBlock(ctx, userDID, communityDID)
565
+
// Block exists in our index - return it
return existingBlock, nil
572
-
// If we can't find it in our index, return the original PDS error
568
+
// Race condition: PDS has the block but Jetstream hasn't indexed it yet
569
+
// Return typed conflict error so handler can return 409 instead of 500
570
+
// This is normal in eventually-consistent systems
571
+
return nil, ErrBlockAlreadyExists
return nil, fmt.Errorf("failed to create block on PDS: %w", err)
···
// Extract rkey from record URI (at://did/collection/rkey)
611
-
rkey := extractRKeyFromURI(block.RecordURI)
610
+
rkey := utils.ExtractRKeyFromURI(block.RecordURI)
return fmt.Errorf("invalid block record URI")
···
875
-
func extractRKeyFromURI(uri string) string {
876
-
// at://did/collection/rkey -> rkey
877
-
parts := strings.Split(uri, "/")
878
-
if len(parts) >= 4 {
879
-
return parts[len(parts)-1]