sojorn/go-backend/cmd/verify/main.go
Patrick Britton 3c4680bdd7 Initial commit: Complete threaded conversation system with inline replies
**Major Features Added:**
- **Inline Reply System**: Replace compose screen with inline reply boxes
- **Thread Navigation**: Parent/child navigation with jump functionality
- **Chain Flow UI**: Reply counts, expand/collapse animations, visual hierarchy
- **Enhanced Animations**: Smooth transitions, hover effects, micro-interactions

 **Frontend Changes:**
- **ThreadedCommentWidget**: Complete rewrite with animations and navigation
- **ThreadNode Model**: Added parent references and descendant counting
- **ThreadedConversationScreen**: Integrated navigation handlers
- **PostDetailScreen**: Replaced with threaded conversation view
- **ComposeScreen**: Added reply indicators and context
- **PostActions**: Fixed visibility checks for chain buttons

 **Backend Changes:**
- **API Route**: Added /posts/:id/thread endpoint
- **Post Repository**: Include allow_chain and visibility fields in feed
- **Thread Handler**: Support for fetching post chains

 **UI/UX Improvements:**
- **Reply Context**: Clear indication when replying to specific posts
- **Character Counting**: 500 character limit with live counter
- **Visual Hierarchy**: Depth-based indentation and styling
- **Smooth Animations**: SizeTransition, FadeTransition, hover states
- **Chain Navigation**: Parent/child buttons with visual feedback

 **Technical Enhancements:**
- **Animation Controllers**: Proper lifecycle management
- **State Management**: Clean separation of concerns
- **Navigation Callbacks**: Reusable navigation system
- **Error Handling**: Graceful fallbacks and user feedback

This creates a Reddit-style threaded conversation experience with smooth
animations, inline replies, and intuitive navigation between posts in a chain.
2026-01-30 07:40:19 -06:00

99 lines
2.6 KiB
Go

package main
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/google/uuid"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/joho/godotenv"
"github.com/patbritton/sojorn-backend/internal/models"
"github.com/patbritton/sojorn-backend/internal/repository"
)
func main() {
if err := godotenv.Load(); err != nil {
log.Println("No .env file found, relying on env vars")
}
dbURL := os.Getenv("DATABASE_URL")
if dbURL == "" {
log.Fatal("DATABASE_URL required")
}
pool, err := pgxpool.New(context.Background(), dbURL)
if err != nil {
log.Fatalf("Unable to connect to database: %v", err)
}
defer pool.Close()
repo := repository.NewCategoryRepository(pool)
userRepo := repository.NewUserRepository(pool)
ctx := context.Background()
// 1. Create a Test User
email := fmt.Sprintf("test_verify_%d@example.com", time.Now().Unix())
log.Printf("Creating test user: %s", email)
user := &models.User{
ID: uuid.New(),
Email: email,
PasswordHash: "hashedpass",
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if err := userRepo.CreateUser(ctx, user); err != nil {
log.Fatalf("Failed to create user: %v", err)
}
// Create Profile for user (triggers needed for follows?)
// Basic profile creation
_, err = pool.Exec(ctx, "INSERT INTO profiles (id, handle, display_name) VALUES ($1, $2, $3)", user.ID, "h"+user.ID.String()[:8], "Test User")
if err != nil {
log.Fatalf("Failed to create profile: %v", err)
}
// 2. Get a Category
cats, err := repo.GetAllCategories(ctx)
if err != nil {
log.Fatalf("Failed to get categories: %v", err)
}
if len(cats) == 0 {
log.Fatalf("No categories found! Seeder failed?")
}
targetCat := cats[0]
log.Printf("Testing with category: %s (Official: %v)", targetCat.Name, targetCat.OfficialAccountID)
if targetCat.OfficialAccountID == nil {
log.Fatalf("Category %s has no official account!", targetCat.Name)
}
// 3. Enable Category
log.Println("Enabling category...")
err = repo.SetUserCategorySettings(ctx, user.ID.String(), []repository.CategorySettingInput{
{CategoryID: targetCat.ID, Enabled: true},
})
if err != nil {
log.Fatalf("Failed to set settings: %v", err)
}
// 4. Verify Follow
log.Println("Verifying follow...")
isFollowing, err := userRepo.IsFollowing(ctx, user.ID.String(), *targetCat.OfficialAccountID)
if err != nil {
log.Fatalf("Failed to check follow: %v", err)
}
if isFollowing {
log.Println("SUCCESS: User is following official account!")
} else {
log.Fatal("FAILURE: User is NOT following official account.")
}
// Cleanup
pool.Exec(ctx, "DELETE FROM users WHERE id = $1", user.ID)
}