Skip to content

feat: implement patch#36

Merged
mehdiasadli merged 1 commit into
mainfrom
v26-05-01
May 1, 2026
Merged

feat: implement patch#36
mehdiasadli merged 1 commit into
mainfrom
v26-05-01

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented May 1, 2026

Summary by CodeRabbit

  • New Features
    • Posts: Create and share posts with optional text and images
    • Reactions: React to posts with emoji reactions (heart, dislike, laugh, sad, angry, wow)
    • Comments: Reply directly to posts with nested comment threads
    • Home Feed: Redesigned feed featuring posts interleaved with other content
    • Trending Packs: New carousel showcasing trending packs on the home page
    • Post Composer: Quick-access floating button for authenticated users to create posts

@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xamsa-web Ready Ready Preview, Comment May 1, 2026 0:38am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Introduces a comprehensive social posting feature spanning frontend UI, backend APIs, database schema, and cloud image storage. Adds post creation/deletion/listing, reaction tracking for posts and comments, and integrates a mixed-feed layout with optimistic updates and image upload support via Cloudinary.

Changes

Cohort / File(s) Summary
Web - Post Composer & Feed
apps/web/src/components/home/home-create-post.tsx, apps/web/src/components/home/home-feed.tsx, apps/web/src/components/home/home-post-reactions.tsx, apps/web/src/components/home/home-feed-constants.ts, apps/web/src/lib/home-post-feed-query.ts
New post creation composer with image preview, infinite-scroll feed layout with sectioned post rendering, optimistic reaction state management, and query cache utilities (invalidation, comment-count adjustment, post removal).
Web - Home Page Integration
apps/web/src/routes/index.tsx
Replaces explore tiles with HomeMixedFeed for signed-in/signed-out modes; adds trending-packs carousel, floating composer with dialog, and feed prefetching via IntersectionObserver-driven visibility.
API - Post Module
packages/api/src/modules/post/router.ts, packages/api/src/modules/post/service.ts
New post CRUD endpoints (list, create, delete) with cursor pagination, slug generation, optional image upload to Cloudinary, attachment validation, and reaction aggregation per post.
API - Reaction Module
packages/api/src/modules/reaction/router.ts, packages/api/src/modules/reaction/service.ts
Protected endpoint for setting/unsetting reactions; transaction-based state toggling with user/target reaction counters and support for both post and comment targets.
API - Comment Extensions
packages/api/src/modules/comment/service.ts
Extended comment service to support optional postId target; adds post comment-count tracking and reaction aggregation for comment targets.
API Router
packages/api/src/router.ts
Aggregates new postRouter and reactionRouter into main app router.
Database Migrations
packages/db/prisma/migrations/20260501105900_posts_reactions_home_v26_05_01/migration.sql, packages/db/prisma/migrations/20260501110006/migration.sql, packages/db/prisma/migrations/20260501111500_reaction_drop_resource_dup/migration.sql, packages/db/prisma/migrations/20260502120000_post_slug/migration.sql
Creates post, post\_attachment, and reaction tables with indexes and constraints; extends comment/user tables with counters and relations; includes slug backfill and resource-enum adjustments.
Prisma Schema
packages/db/prisma/schema/post.prisma, packages/db/prisma/schema/auth.prisma, packages/db/prisma/schema/game.prisma, packages/db/prisma/schema/pack.prisma
Defines Post, PostAttachment (one-to-one with resource enum), Reaction (typed, multi-target), and ReactionType enum; extends User, Game, Topic, Pack, and Comment with relations and counters.
Validation Schemas - Enums
packages/schemas/src/db/schemas/enums/ReactionType.schema.ts, packages/schemas/src/db/schemas/enums/PostAttachmentResource.schema.ts, packages/schemas/src/db/schemas/enums/Post...FieldEnum.schema.ts, packages/schemas/src/db/schemas/enums/ReactionScalarFieldEnum.schema.ts, packages/schemas/src/db/schemas/enums/CommentScalarFieldEnum.schema.ts, packages/schemas/src/db/schemas/enums/UserScalarFieldEnum.schema.ts
New and updated Zod enum schemas for reaction types, attachment resources, and scalar field constraints; extended existing enum schemas with new model fields.
Validation Schemas - Models
packages/schemas/src/db/schemas/models/Post.schema.ts, packages/schemas/src/db/schemas/models/PostAttachment.schema.ts, packages/schemas/src/db/schemas/models/Reaction.schema.ts, packages/schemas/src/db/schemas/models/Comment.schema.ts, packages/schemas/src/db/schemas/models/User.schema.ts, packages/schemas/src/db/schemas/models/index.ts
New schemas for Post, PostAttachment, Reaction with validation rules (slug regex, image MIME/base64, date coercion); updated Comment and User schemas to include new fields; reexported from index.
Validation Schemas - API Contracts
packages/schemas/src/modules/post.ts, packages/schemas/src/modules/reaction.ts, packages/schemas/src/modules/comment.ts
New post schemas for create/delete/list operations with cursor, author, attachment input, and reaction breakdown types; new reaction set-input/output; updated comment schemas for post-target support.
Upload Utilities
packages/upload/src/cloudinary-url.ts, packages/upload/src/paths.ts, packages/upload/src/upload-post-image.ts, packages/upload/src/index.ts
New post-image upload function with 8MB limit, MIME validation (magic-number checks), Cloudinary streaming, and public-ID helpers; extended module exports.
General Utilities
packages/utils/src/post-slug.ts, packages/utils/src/app-releases.ts
New post-slug utilities for generating seeds from body text or random meaningful words; updated app-releases with v26.05.01 feature highlights and rewritten prior release descriptions.
Documentation
draft.md
Roadmap entry for v26.05.01 social feature specifying Post, Comment, Reaction entities, constraints (body/image, reaction targets), and home-page layout requirements.

Sequence Diagrams

sequenceDiagram
    actor User
    participant WebUI as Web UI<br/>(CreatePostComposer)
    participant API as API<br/>(post.create)
    participant Cloudinary
    participant Database as Database<br/>(Post, PostAttachment)
    
    User->>WebUI: Enter body text & select image
    User->>WebUI: Press Ctrl/⌘+Enter
    WebUI->>WebUI: Convert image to base64
    WebUI->>WebUI: Validate MIME type
    WebUI->>API: POST /post.create<br/>(body, imageBase64, imageMimeType)
    
    API->>Cloudinary: Upload image stream<br/>(with public_id path)
    Cloudinary-->>API: Return secure_url & public_id
    
    API->>Database: BEGIN TRANSACTION
    API->>Database: INSERT Post<br/>(slug, body, imageUrl, userId)
    API->>Database: INSERT PostAttachment<br/>(postId, imagePublicId)
    API->>Database: UPDATE User<br/>INCREMENT totalPosts
    API->>Database: COMMIT
    
    Database-->>API: Success
    API-->>WebUI: PostRow response
    
    WebUI->>WebUI: Clear inputs
    WebUI->>WebUI: Invalidate feed cache
    WebUI-->>User: Refresh feed with new post
Loading
sequenceDiagram
    actor User
    participant WebUI as Web UI<br/>(PostReactionBar)
    participant Cache as React Query<br/>Cache
    participant API as API<br/>(reaction.set)
    participant Database as Database<br/>(Reaction, counters)
    
    User->>WebUI: Click/long-press reaction button
    WebUI->>Cache: Capture snapshot<br/>(current state)
    
    WebUI->>WebUI: Update local state<br/>(optimistic)
    WebUI->>Cache: Update cached post<br/>(my reaction, totals)
    WebUI-->>User: Immediate UI feedback
    
    WebUI->>API: PUT /reaction.set<br/>(postId, type)
    
    API->>Database: BEGIN TRANSACTION
    API->>Database: Check existing reaction
    alt Reaction exists & same type
        API->>Database: DELETE reaction
        API->>Database: DECREMENT totals
    else New reaction
        API->>Database: INSERT reaction
        API->>Database: INCREMENT totals
    else Different type
        API->>Database: UPDATE reaction type
    end
    API->>Database: COMMIT
    
    alt Server error
        Database-->>API: Error
        API-->>WebUI: Error response
        WebUI->>Cache: Restore snapshot
        WebUI-->>User: Revert UI
    else Success
        Database-->>API: Success
        API-->>WebUI: Updated reaction type
        WebUI->>Cache: Invalidate home feed
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • feat: implement new patch #35: Extends comment service and validation schemas to support post targets, directly complementing post-comment integration in this PR.
  • feat: implement new patch #32: Introduces core Cloudinary utilities and image path/upload helpers that are reused and extended by the post-image upload functionality in this PR.

Suggested labels

app:web, pkg:api, database, pkg:schemas, size:xl

Poem

🐰 Hops of joy, a social spree—
Posts and reactions wild and free,
Cloudinary clouds store images bright,
Optimistic updates, keeping cache light,
Comments cascade, slugs made with care,
The home feed blooms beyond compare! 🌱✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: implement patch' is extremely vague and generic. It uses non-descriptive language that does not convey meaningful information about the substantial changeset, which implements a comprehensive social feature including posts, comments, reactions, and home feed UI. Replace with a more specific title that describes the main feature being implemented, such as 'feat: implement social posts, reactions, and home feed' or 'feat: add posts with comments, reactions, and home feed integration'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v26-05-01

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@mehdiasadli mehdiasadli merged commit 6ea92ca into main May 1, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-05-01 branch May 1, 2026 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant