Skip to content

Feat: notes - #73

Draft
khanzadimahdi wants to merge 1 commit into
mainfrom
feat/notes
Draft

Feat: notes#73
khanzadimahdi wants to merge 1 commit into
mainfrom
feat/notes

Conversation

@khanzadimahdi

Copy link
Copy Markdown
Member

A note is a short, body-only piece of content — no title, no cover image. It is multilingual the same way an article is: identity is the CorrelationUUID, and each language version is its own document keyed by (correlationUUID, languageCode).

What's here

Domaindomain/note: the Note type, its repository port, a MongoDB repository, and a mock for the use-case tests.

Public endpoints

Route Purpose
GET /api/notes/{uuid} one note, cached
GET /api/authors/{identity}/notes an author's published notes

Dashboard endpoints — full CRUD under notes.*, and the same five operations scoped to the caller's own notes under self.notes.* (/api/dashboard/my/notes). The repository takes an authorUUID that is empty for "every author" and set for the own-notes listing, so one query serves both.

Changes to existing code

These are the parts worth a careful look, since they touch code that already worked:

  • Bookmarks and comments accept notes. domain/bookmark and domain/comment each grow ObjectTypeNote and an IsValidObjectType helper. That helper replaces the r.ObjectType != ObjectTypeArticle equality check in seven request validators — same behaviour for articles, one place to extend next time.
  • getArticlesByHashtaghashtag/getContentsByHashtag. The use case moved package and now returns articles and notes side by side, so a hashtag page can tab between them. This is a rename plus a widening; the article half of the response is unchanged.
  • getArticlesByAuthor gains a totals block ({articles, notes}), so an author page can label both content tabs without a second round-trip. It takes a note.Repository for the count only.

Notes for review

  • The excludedAuthorUUIDs parameter on the hashtag queries keeps the count and the page consistent when an author keeps their notes private.
  • The OpenAPI docs are regenerated (go generate). Alongside the new note paths you'll see /dashboard/files, /dashboard/languages and /dashboard/my/bookmarks appear as removed-and-re-added — that's alphabetical repositioning from the insertion, not a change to those endpoints.

Relationship to the other PRs

Split out of one working branch alongside contact-us and block users. All three are cut from main and can be merged in any order, but each touches domain/permission/permission.go, the permissions collection, and infrastructure/ioc/providers/blog.go. Conflicts there are additive on both sides — keep both. Re-run go generate after merging to settle the OpenAPI docs.

Verification

go build ./..., go vet ./... and go test ./... all pass on this branch alone.

🤖 Generated with Claude Code

A note is a short, body-only piece of content — no title, no cover. It is
multilingual the same way an article is: identity is the CorrelationUUID
and each language version is its own document keyed by
(correlationUUID, languageCode).

- domain/note with its repository port, MongoDB repository, and a mock
- GET /api/notes/{uuid} and GET /api/authors/{identity}/notes
- Dashboard CRUD under notes.*, plus the same operations scoped to the
  caller's own notes under self.notes.*
- Notes can be bookmarked and commented on: both domains grow an
  ObjectTypeNote and an IsValidObjectType, replacing the equality checks
  against ObjectTypeArticle that were spread across seven request validators
- getArticlesByHashtag becomes hashtag/getContentsByHashtag and returns
  articles and notes side by side, so a hashtag page can tab between them
- getArticlesByAuthor gains a totals block (articles, notes) so an author
  page can label both tabs without a second round-trip

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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