Skip to content

feat(post): embed a quoted post in a post - #239

Closed
aquie00t wants to merge 1 commit into
mainfrom
feature/post-quotes
Closed

feat(post): embed a quoted post in a post#239
aquie00t wants to merge 1 commit into
mainfrom
feature/post-quotes

Conversation

@aquie00t

Copy link
Copy Markdown
Collaborator

Alıntı özelliğinin 4 PR'a bölünmüş hâlinin ilki: veri modeli, alıntı oluşturma ve alıntının yanıtta görünmesi.

Ne değişti

  • ŞemaPost'a quotedPostId + self-relation (PostQuotes, ON DELETE CASCADE) ve index. Migration elle yazıldı ve gerekçelendirildi.
  • OluşturmaPOST /posts gövdesine opsiyonel quotedPostId. Ayrı endpoint yok, tek oluşturma yolu korundu.
  • Yanıt — her post yanıtı artık quotedPost taşıyor: yalın kart (yazar, içerik, medya, tarih) ya da null. PostItemSchema ortak olduğu için feed, kullanıcı postları, post detayı, create yanıtı ve bookmark listesi tek düzenlemeden yararlanıyor.
  • Doğrulama — alıntılanan post yazmadan önce çözülüyor; olmayan bir id 404 döner, FK ihlali değil.
  • Cache — feed cache'inde iç içe quotedPost.createdAt elle canlandırılıyor; olmasa aynı istek cache miss'te Date, sonraki 60 saniye string dönerdi.

Kararlar

  • Cascade: orijinal silinince onu alıntılayan postlar da silinir. SET NULL alternatifi, "hiç alıntılamadı" ile "alıntıladığı silindi" ayrımı için ikinci bir kolon isterdi; ileride istenirse tek migration'lık iş.
  • Tek seviye: include ve kart özyinelemiyor — alıntının alıntısı, alıntıladığı postu taşır, arkasındaki zinciri değil.
  • Kartta sayaç yok: likeCount/isLiked taşınmadığı için gömme ekstra join getirmiyor.
  • postInclude() yardımcı fonksiyonu yerine POST_AUTHOR_SELECT / QUOTED_POST_INCLUDE sabitleri kullanıldı: dönüş tipini Prisma.PostInclude yapmak payload çıkarımını genişletip mevcut cast'leri 4 yerde TS2352 ile bozuyordu.

Doğrulama

  • pnpm test:unit → 877/877 geçti (mapper +6, create-post +4, get-posts cache +2 yeni test).
  • pnpm lint, pnpm format:check, tsc --noEmit temiz.
  • Migration test DB'sine uygulandı; migrate diff sıfır drift.
  • Gerçek DB'ye karşı smoke: quotedPostId yazımı, kartın create/findById/findAll'da dönmesi, tek seviye gömme ve cascade silmenin iki seviyeye ulaşması doğrulandı.
  • Integration (+4) ve E2E (+6) testleri eklendi; lokalde migrate reset çalışmadığı için CI'da koşacaklar.

Sonraki PR'lar

  • PR 2quoteCount sayacı + CreatePostUseCase'in TransactionPort'a taşınması
  • PR 3NotificationType.QUOTE + realtime bildirim
  • PR 4GET /posts/:id/quotes + metinsiz alıntı (saf repost)

🤖 Generated with Claude Code

https://claude.ai/code/session_015JC6UgjwRSJ3KHToPYqBPC

A post can now quote another post, the way a quote tweet does: POST /posts
takes an optional quotedPostId and every post response carries a quotedPost
card, or null.

The relation is self-referential on Post and cascades, so deleting a post
deletes every post that quotes it and a card can never point at content that
is gone. The card is deliberately lean - author, content, media and date, no
counters and no viewer-specific flags - so embedding one costs no extra joins,
and the include stops at one level, so a quote of a quote carries the post it
quotes and nothing behind it.

The quoted post is resolved before the write, so quoting an id that is already
gone answers 404 rather than a constraint violation. The feed cache revives the
nested date by hand: without it the same request would answer with a Date on a
miss and a string for the next 60 seconds.

Counters, notifications and a list of quoters follow in their own changes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015JC6UgjwRSJ3KHToPYqBPC
@aquie00t

Copy link
Copy Markdown
Collaborator Author

Kodu #242'nin squash merge'ü ile main'e girdi (faa97c7) — zincirin tamamı tek commit olarak birleşti. İncelenecek bir fark kalmadığı için kapatıyorum; tartışma bu PR'da okunabilir kalıyor.

@aquie00t aquie00t closed this Aug 30, 2026
@aquie00t
aquie00t deleted the feature/post-quotes branch August 30, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant