Southclaws / storyden

With a fresh new take on traditional bulletin board forum software, Storyden is a modern, secure and extensible platform for building communities.
https://www.storyden.org/
Mozilla Public License 2.0
93 stars 11 forks source link

Post-thread-reply-domain-refactor #170

Closed Southclaws closed 3 months ago

Southclaws commented 3 months ago

A "Post" is just a piece of content, and Storyden will soon have Newsletters, Blogs and generic pages outside of the Library tree. Earlier in development however, after spinning out from the open.mp Forum codebase, there existed just Post and Thread (a Thread contains one or more Posts where the first Post is also the Thread itself.)

Because of this history, the schema reflected this in APIs under /posts and schema resources named Post*. However, the internal code has evolved a lot and settled on Post being higher in the information heirarchy with a Thread now being a kind of Post and Posts within a Thread being referred to as "Replies", which are just another kind of Post object.

This mental model is vastly simpler to both reason about and implement/structure. Post has been a top-level resource in the codebase structure for a while now, with Thread and Reply being descendants of this type. This change furthers that by providing a proper Post struct from which Threads and Replies can embed in their structs in order to contribute additional information for their specific use-cases.

In the cases of other resources that can reference Posts, these were originally (hackily) limited to Reply objects (which, confusingly could also represent Threads themselves, or at least the first Post within a Thread, which is the Thread's "root" post.) Collections, Links and Nodes can all reference Posts in various ways and building on the Datagraph rework (parent commit) this settles into a better abstraction for those data structures.

For example, a Collection can contain Library Nodes and Posts, and it does not need to hold any specific information about whether or not those Posts are Threads or Replies, they are just Posts. Post objects can more easily express whether they are roots or not but also, conveniently, simply provide their Root's ID, Title and Slug which is necessary for Collections and other aggregations to provide users with URLs and names to refer to them.

More work is required to properly differentiate between these for the UI and API levels, but this PR lays the groundwork. For example, a frontend implementation may want to provide a URL to a specific Post within a Thread, and for that we'd need to provide this information so that the frontend implementation can construct a URL that correctly leads to that specific post within a thread (a URL fragment will likely be the most common approach.)

However, this also plays into additional challenges I'd like to tackle around identifying resources. URN/URI strings could be useful here to express identities and also provide a universal abstraction over IDs, slugs, handles, etc. (frequently referred to as "Marks" in the codebase, such as ThreadMark to identify the combination of the Thread's slug and ID which provides a URL-friendly string that's both unique and also contains a slugified version of the Thread's title)

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
storyden βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Aug 10, 2024 10:57am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **storyden-homepage** | ⬜️ Ignored ([Inspect](https://vercel.com/southclaws-projects/storyden-homepage/H9tyyiRGGHq6zHWL1MMGdBvcvWW1)) | [Visit Preview](https://storyden-homepage-git-post-thread-re-873c8b-southclaws-projects.vercel.app) | | Aug 10, 2024 10:57am |
coderabbitai[bot] commented 3 months ago
Walkthrough ## Walkthrough The recent changes enhance the application's structure by transitioning from a focus on posts to a more comprehensive handling of replies. This includes modifications to data models, API endpoints, and serialization processes. The integration of new features streamlines interactions, improves error handling, and introduces more robust interfaces that enrich the user experience while managing threaded discussions. ## Changes | Files | Change Summary | |----------------------------------------------------------------|----------------| | `app/resources/collection/db.go`, `app/resources/collection/dto.go` | Added `WithRoot` filter for hierarchical data retrieval; updated mapping logic to use `post` package. | | `app/resources/link/link_graph/link.go`, `app/resources/post/post.go` | Simplified data structures by consolidating posts; enhanced the `Post` struct with new metadata fields. | | `app/resources/post/post_search/db.go`, `app/resources/post/post_search/repo.go` | Updated methods to return `post.Post` instead of `reply.Reply`; streamlined data handling processes. | | `app/resources/post/thread_querier/querier.go`, `app/resources/post/thread_writer/writer.go` | Introduced interfaces for managing threads and replies with new methods for creation, updating, and deletion. | | `app/transports/http/bindings/posts.go`, `app/transports/http/bindings/replies.go` | Removed `PostCreate` method; added `Replies` struct to handle reply creation. | | `web/src/api/openapi/posts.ts`, `web/src/api/openapi/replies.ts` | Removed functions related to post creation; added functions and types for managing replies. | | `web/src/api/openapi/schemas/*` | Restructured schemas to clarify distinctions between posts and replies, enhancing overall API clarity. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant API participant Service participant Database User->>API: Create Reply API->>Service: Validate and Process Service->>Database: Save Reply Database-->>Service: Reply ID Service-->>API: Reply Created API-->>User: Reply Success ``` > πŸ‡βœ¨ In fields so green, where changes bloom, > A rabbit hops, dispelling gloom. > With whispers soft and leaps so bright, > New features sprout, a wondrous sight! > Rejoice in code, let joy take flight! πŸ‡πŸŒΌ

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
Southclaws commented 3 months ago

@coderabbitai review

coderabbitai[bot] commented 3 months ago
Actions performed Review triggered. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.