├── 0000-template.md ├── 0005-private-communities.md ├── 0008-plugins.md ├── README.md ├── 0004-post-tags.md └── LICENSE /0000-template.md: -------------------------------------------------------------------------------- 1 | - Feature Name: (fill me in with a unique ident, `my_awesome_feature`) 2 | - Start Date: (fill me in with today's date, YYYY-MM-DD) 3 | - RFC PR: [LemmyNet/rfcs#0000](https://github.com/LemmyNet/rfcs/pull/0000) 4 | - Lemmy Issue: [LemmyNet/lemmy#0000](https://github.com/LemmyNet/lemmy/issues/0000) 5 | 6 | # Summary 7 | 8 | One paragraph explanation of the feature. 9 | 10 | # Motivation 11 | 12 | Why are we doing this? What use cases does it support? What is the expected outcome? 13 | 14 | # Guide-level explanation 15 | 16 | Explain the proposal as if it was already included in Lemmy and you were teaching it to another user. That generally means: 17 | 18 | - Explaining the feature largely in terms of examples. 19 | - Explaining how Lemmy users should *think* about the feature, and how it should impact the way they use Lemmy. It should explain the impact as concretely as possible. 20 | - For policy RFCs, this section should provide an example-driven introduction to the policy, and explain its impact in concrete terms. 21 | 22 | # Reference-level explanation 23 | 24 | This is the technical portion of the RFC. Explain the design in sufficient detail that: 25 | 26 | - Its interaction with other features is clear. 27 | - It is reasonably clear how the feature would be implemented. 28 | - Corner cases are dissected by example. 29 | 30 | The section should return to the examples given in the previous section, and explain more fully how the detailed proposal makes those examples work. 31 | 32 | In particular explain the following, if applicable: 33 | 34 | - Which database changes are necessary? 35 | - How does the HTTP API change? 36 | - How does the new feature work over federation? Are there similar features in other Fediverse platforms which should be compatible? Also see the [federation docs](https://join-lemmy.org/docs/contributors/05-federation.html). 37 | 38 | # Drawbacks 39 | 40 | Why should we *not* do this? 41 | 42 | # Rationale and alternatives 43 | 44 | - Why is this design the best in the space of possible designs? 45 | - What other designs have been considered and what is the rationale for not choosing them? 46 | - What is the impact of not doing this? 47 | - Could this change be implemented in an external project instead? How much complexity does it add? 48 | 49 | # Prior art 50 | 51 | Discuss prior art, both the good and the bad, in relation to this proposal. 52 | A few examples of what this can include are: 53 | 54 | - Does this feature exist in other social media platforms and what experience have their community had? 55 | - Papers: Are there any published papers or great posts that discuss this? If you have some relevant papers to refer to, this can serve as a more detailed theoretical background. 56 | 57 | This section is intended to encourage you as an author to think about the lessons from other social networks, provide readers of your RFC with a fuller picture. 58 | If there is no prior art, that is fine - your ideas are interesting to us whether they are brand new or if it is an adaptation from other languages. 59 | 60 | Note that while precedent set by other social networks is some motivation, it does not on its own motivate an RFC. 61 | 62 | # Unresolved questions 63 | 64 | - What parts of the design do you expect to resolve through the RFC process before this gets merged? 65 | - What parts of the design do you expect to resolve through the implementation of this feature before stabilization? 66 | - What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC? 67 | 68 | # Future possibilities 69 | 70 | Think about what the natural extension and evolution of your proposal would 71 | be and how it would affect the language and project as a whole in a holistic 72 | way. Try to use this section as a tool to more fully consider all possible 73 | interactions with the project in your proposal. 74 | 75 | This is also a good place to "dump ideas", if they are out of scope for the 76 | RFC you are writing but otherwise related. 77 | 78 | If you have tried and cannot think of any future possibilities, 79 | you may simply state that you cannot think of anything. 80 | 81 | Note that having something written down in the future-possibilities section 82 | is not a reason to accept the current or a future RFC; such notes should be 83 | in the section on motivation or rationale in this or subsequent RFCs. 84 | The section merely provides additional information. 85 | -------------------------------------------------------------------------------- /0005-private-communities.md: -------------------------------------------------------------------------------- 1 | - Feature Name: Private Communities 2 | - Start Date: 2024-02-15 3 | - RFC PR: [LemmyNet/rfcs#0005](https://github.com/LemmyNet/rfcs/pull/5) 4 | - Lemmy Issue: [LemmyNet/lemmy#187](https://github.com/LemmyNet/lemmy/issues/187) 5 | 6 | ## Summary 7 | 8 | Lemmy is currently limited to public communities with public content. This RFC proposes a way to implement private, federated communities where only approved users can read and write. 9 | 10 | ## Motivation 11 | 12 | Private spaces are a fundamental aspect of human communication. They allow discussing sensitive topics without interruption from outsiders. Supporting private communities in Lemmy gives a major new use case for talking among friends or within organizations. This use case is currently not covered by major Fediverse projects. 13 | 14 | ## Detailed design 15 | 16 | The functionality requires only minor changes to the existing community implementation. The community profile with sidebar, icon etc remains public, so that anyone can follow the community. When a follow request is received, it needs to be manually approved by a moderator, using an interface similar to the existing registration applications. Posts and comments inside a private community are only visible to approved followers. 17 | 18 | This change is in some ways similar to [Local-only communities](https://github.com/LemmyNet/lemmy/pull/4350). That PR can be used as a reference for parts of code which need to be changed. 19 | 20 | ## Database 21 | 22 | The `CommunityVisibility` enum used in `community.visibility` gets a new variant `Private`. Queries in `post_view.rs` and `comment_view.rs` need to be adjusted so that content in communities set to private is only shown to followers. This also needs to be covered by unit tests. 23 | 24 | ## API 25 | 26 | When a new follow request for a local private community is made, it needs to set `pending = true`. Moderators can review and approve/reject pending follows with the following endpoints: 27 | - `GET /api/v3/community/pending_follows/count` 28 | - `GET /api/v3/community/pending_follows/list` 29 | - `POST /api/v3/community/pending_follows/approve` 30 | 31 | The follow_request list for each item should contain a boolean value `is_new_instance`. This value should be true if the community has no followers from the user's instance yet, and allows showing a warning when content will be federated to a new server. 32 | 33 | Once the approve endpoint is called, the follow request can be deleted. If the request was approved, write the follow relation to `community_follower`. If it was rejected, we could notify the user about this (optional). 34 | 35 | Users who don't follow the private community need to be prevented from posting or making other actions in it. This can be done by adding a check in [check_community_user_action()](https://github.com/LemmyNet/lemmy/blob/main/crates/api_common/src/utils.rs#L171). 36 | 37 | When [processing mentions](https://github.com/LemmyNet/lemmy/blob/main/crates/utils/src/utils/mention.rs#L24), the code needs to check if it is inside a private community, and in that case ignore mentions of users which don't follow it. 38 | 39 | The new endpoints should be covered by [Typescript API tests](https://github.com/LemmyNet/lemmy/tree/main/api_tests). 40 | 41 | ## Federation 42 | 43 | When a `Follow` activity is received, Lemmy currently automatically responds with an `Accept`. This needs to be changed so that private communities only store the pending follow in the database, without sending an `Accept`. Once a moderator approves the request, send an `Accept` to the user. Note that only moderators registered on the same instance as the community will see follow requests. 44 | 45 | The `Group` actor for private communities remains public and can be fetched without restrictions, so that remote users can fetch it and follow it. It needs a new attribute to indicate that the group is not public. We can use `manuallyApprovesFollowers: true` which is supported by many existing platforms including Mastodon. 46 | 47 | With Activitypub federation there are two ways instances can communicate with each other: Fetch data via HTTP GET, or POST an activity to the inbox. Activities are only sent to approved followers, so we don't need to worry about leaking any private data. However the fetching needs adjustments. For this we can use authorized fetch, which is already [implemented behind a setting](https://github.com/LemmyNet/lemmy/blob/main/src/lib.rs#L182). The simplest solution here is to remove the setting and sign all all outgoing requests, so we don't have to track which specific objects require auth or not. 48 | 49 | On the server side we need to verify the signature when an object gets fetched in a private community. The code for this is [here](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/http/post.rs), [here](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/http/comment.rs) and [here](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/http/community.rs#L76). The logic for signature verification is [implemented in the activitypub-federation crate](https://github.com/LemmyNet/activitypub-federation-rust/blob/main/src/http_signatures.rs#L146), but not yet part of the public API. 50 | 51 | Like in the API code we need to ensure that only followers can perform actions in private communities. Here a check needs to be added to [verify_person_in_community()](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/activities/mod.rs#L77). 52 | 53 | [Objects](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/objects/post.rs#L127) and [activities](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/activities/create_or_update/post.rs#L53) are currently marked as public, we need to get rid of this in private communities. Additionally, the method [verify_is_public()](https://github.com/LemmyNet/lemmy/blob/main/crates/apub/src/activities/mod.rs#L127) needs to take community visibility into account. If the community is public, reject any non-public content (just like now). if it is private, reject any public content. 54 | 55 | ## RSS 56 | 57 | The community RSS feed needs to be adjusted to avoid leaking private content. The easiest solution is to disable it for private communities, but it would also be possible to serve private community feeds with authentication, similar to the existing subscribed feed. 58 | 59 | Other feed types need to exclude any content from private communities. This should already be handled by changes to `post_view.rs` 60 | 61 | ## Frontends and Apps 62 | 63 | Community moderators need to get access to the new `community.visibility` setting in the sidebar. Community visibility should also be indicated to users. 64 | 65 | Frontends need to show an interface for moderators to approve new followers. This can likely reuse much of the code from registration applications, and use the endpoints described under "API". When `is_new_instance` is true on a given application, show a warning similar to the following before approving: 66 | 67 | > Warning: This is the first follower from example.com. After approval, the admin of example.com is technically able to access all past and future content in this community. It is also possible that the instance at example.com makes community posts publicly available. If the community has sensitive content, make sure to only approve followers from trusted instances. 68 | 69 | ## Alternatives 70 | 71 | The only alternative would be not to implement this feature in Lemmy, and rely on different platforms for private communities instead. Considering that Lemmy already has a large number of users and many important features, it is better to provide this feature directly. 72 | 73 | ## Unresolved questions 74 | 75 | Images in private communities are publicly available for anyone who knows the url. This is probably fine as image URLs are long and randomized, so they are impossible to guess. 76 | 77 | When setting an existing community to private, this setting will generally also federate to other instances. However it is possible that some instances don't refetch the community, and old content remains public. And of course old content can be stored in external archives. This problem could be avoided by preventing existing, public communities to be marked as private. 78 | 79 | In a public community, old content missing from your instance can be fetched by visiting the community on its home instance and copying the URL of individual posts and comments into your own instance's search field to fetch them. This is not easily possible with a private community, as it cannot be viewed publicly. However this is a general problem with Lemmy communities and can be handled separately. 80 | 81 | ## Further Work 82 | 83 | In addition to the described private communities, we can implement semi-private communities. These would require the same approval process for joining and posting, however all content in semi-private communities would be public. It would be useful to allow public conversations between trusted users. 84 | -------------------------------------------------------------------------------- /0008-plugins.md: -------------------------------------------------------------------------------- 1 | - Feature Name: plugins 2 | - Start Date: 2024-12-02 3 | - RFC PR: [LemmyNet/rfcs#0008](https://github.com/LemmyNet/rfcs/pull/0008) 4 | - Lemmy Issue: [LemmyNet/lemmy#3562](https://github.com/LemmyNet/lemmy/issues/3562) 5 | 6 | # Summary 7 | 8 | Implement a plugin system for Lemmy based on Webassembly. 9 | 10 | # Motivation 11 | 12 | Plugins will make Lemmy more flexible, and allow implementing features which are too niche for merging into Lemmy core. It will allow Lemmy to focus on core features, while allowing outside developers to contribute new features without using Rust. 13 | 14 | # Guide-level explanation 15 | 16 | ## Extism 17 | 18 | [Extism](https://extism.org/) is an open source framework to develop plugins for Rust projects. It supports numerous different languages by compiling them to webassembly which gets called from Rust. 19 | 20 | # Reference-level explanation 21 | 22 | ## File Structure 23 | 24 | Each plugin consists of two files, a [manifest](https://extism.org/docs/concepts/manifest) and the actual wasm binary. The manifest specifies how to load the binary, and provides various configuration options. Plugins are loaded at startup from `./plugins/` or `LEMMY_PLUGIN_PATH`. Each plugin must have a `metadata` hook returning data in the format below, which is listed in a new field `active_plugins` under `/api/v4/site`. 25 | 26 | ```json 27 | { 28 | "name": "My Plugin", 29 | "url": "http://example.com/plugin-info", 30 | "description": "Plugin which does the thing" 31 | } 32 | ``` 33 | 34 | ## Plugin Hooks 35 | 36 | Lemmy will have hooks for specific actions which can then be used by plugins. In general there are two types of hooks: before an action is written to the database, so it can be rejected or altered. And after it is written to the database, mainly for different types of notifications. 37 | 38 | Whenever a plugin hook is called, Lemmy blocks the API call until the plugin returns. This means that slow plugins can result in slow API actions for users, or delays for incoming federation. To avoid such problems, plugin developers should optimize their code to return as fast as possible, and perform expensive operations or network calls in a background thread. 39 | 40 | Data is passed to plugins using the existing structs linked below, serialized to JSON. Additionally plugins can retrieve [config values](https://github.com/extism/go-pdk?tab=readme-ov-file#configs) `lemmy_version` (e.g. `0.19.8`) and `lemmy_url` (e.g. `http://localhost:8536/`), in order to retrieve data or perform further actions via Lemmy API. 41 | 42 | For the initial implementation, the following hooks will be available: 43 | 44 | ### Before writing to Database 45 | 46 | These hooks can be used to reject or alter user actions based on different criteria. 47 | 48 | - Post 49 | - `before_create_local_post` (with [PostInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L101)) 50 | - `before_update_local_post` (with [PostUpdateForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L150)) 51 | - `before_receive_federated_post` (with [PostInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L101)) 52 | - Comment 53 | - `before_create_local_comment` (with [CommentInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L68)) 54 | - `before_update_local_comment` (with [CommentUpdateForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L93)) 55 | - `before_receive_federated_comment` (with [CommentInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L68)) 56 | - Votes 57 | - `before_post_vote` (with [PostLikeForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L215)) 58 | - `before_comment_vote` (with [CommentLikeForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L133)) 59 | - Private Message 60 | - `before_create_local_private_message` (with [PrivateMessageInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L116)) 61 | - `before_update_local_private_message` (with [PrivateMessageUpdateForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/private_message.rs#L63)) 62 | - `before_receive_federated_private_message` (with [PrivateMessageInsertForm](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L116)) 63 | 64 | ### After writing to Database 65 | 66 | These are mainly useful to generate notifications. 67 | 68 | - Post (all with [Post](https://github.com/LemmyNet/lemmy/blob/0.19.7/crates/db_schema/src/source/post.rs#L18)) 69 | - `after_create_local_post` 70 | - `after_update_local_post` 71 | - `after_receive_federated_comment` 72 | - Comment (all with [Comment](https://github.com/LemmyNet/lemmy/blob/0.19.7/crates/db_schema/src/source/comment.rs#L26)) 73 | - `after_create_local_comment` 74 | - `after_update_local_comment` 75 | - `after_receive_federated_post` 76 | - Votes 77 | - `after_post_vote` (with [PostActions](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/post.rs#L185)) 78 | - `after_comment_vote` (with [CommentActions](https://github.com/LemmyNet/lemmy/blob/main/crates/db_schema/src/source/comment.rs#L116)) 79 | - Private Message (all with [PrivateMessage](https://github.com/LemmyNet/lemmy/blob/0.19.7/crates/db_schema/src/source/private_message.rs#L25)) 80 | - `after_create_local_private_message` 81 | - `after_update_local_private_message` 82 | - `after_receive_federated_private_message` 83 | 84 | ## Example 85 | 86 | Below is a simple Go plugin which uses the `before_create_local_post` hook to replace `Rust` in post body with `Go`, and reject posts which mention `Java`. 87 | 88 | Also checkout the documentation for Extism's [Go Plugin Development Kit](https://github.com/extism/go-pdk). 89 | 90 | ```golang 91 | package main 92 | 93 | import ( 94 | "github.com/extism/go-pdk" 95 | "errors" 96 | "strings" 97 | ) 98 | 99 | type Metadata struct { 100 | Name string `json:"name"` 101 | Url string `json:"url"` 102 | Description string `json:"description"` 103 | } 104 | 105 | // Returns info about the plugin which gets included in /api/v4/site 106 | //go:wasmexport metadata 107 | func metadata() int32 { 108 | metadata := Metadata { 109 | Name: "Test Plugin", 110 | Url: "https://example.com", 111 | Description: "Plugin to test Lemmy feature", 112 | } 113 | err := pdk.OutputJSON(metadata) 114 | if err != nil { 115 | pdk.SetError(err) 116 | return 1 117 | } 118 | return 0 119 | } 120 | 121 | // This hook gets called when a local user creates a new post 122 | //go:wasmexport before_create_local_post 123 | func create_local_post() int32 { 124 | // Load user parameters into a map, to make sure we return all the same fields later 125 | // and dont drop anything 126 | params := make(map[string]interface{}) 127 | err := pdk.InputJSON(¶ms) 128 | if err != nil { 129 | pdk.SetError(err) 130 | return 1 131 | } 132 | 133 | // Dont allow any posts mentioning Java in title 134 | // (these will throw an API error and not be written to the database) 135 | name := params["name"].(string) 136 | if strings.Contains(name, "Java") { 137 | // Throw error to reject post 138 | pdk.SetError(errors.New("We dont talk about Java")) 139 | return 1 140 | } 141 | 142 | // Replace all occurences of "Rust" in post title with "Go" 143 | params["name"] = strings.Replace(name, "Rust", "Go", -1); 144 | 145 | err = pdk.OutputJSON(params) 146 | if err != nil { 147 | pdk.SetError(err) 148 | return 1 149 | } 150 | return 0 151 | } 152 | ``` 153 | 154 | You can see more examples in different languages in the [lemmy-plugins](https://github.com/LemmyNet/lemmy-plugins) repo. 155 | 156 | ## Licensing 157 | 158 | Plugins can use any [OSI-approved open source licenses](https://opensource.org/licenses). Unlike Lemmy's AGPL license, most of them don't require sharing the source code with people who use it over a network, so the source code only needs to be made available to server admins. This also allows for for paid plugins. 159 | 160 | # Drawbacks 161 | 162 | Plugins may have a performance impact as described above. It is up to plugin developers and instance admins to ensure that plugins run adequately. In any case plugins are only called for POST actions but not for GET. This means slow plugins might result in longer waiting time to submit posts, but passive browsing will be unaffected. 163 | 164 | # Rationale and alternatives 165 | 166 | The alternative would be to implement all possible functionality directly in the Lemmy backend. This is not always desirable because features may only be desired by a small fraction of users. Additionally Lemmy code can only be written in Rust, while plugins can use many different languages. 167 | 168 | # Prior art 169 | 170 | Plugins for other Fediverse platforms: 171 | 172 | - https://docs.joinpeertube.org/contribute/plugins 173 | - https://github.com/friendica/friendica-addons 174 | - https://codeberg.org/hubzilla/hubzilla-addons 175 | - https://nextcloud.github.io/news/features/plugins/ 176 | - https://developer.wordpress.org/plugins/ 177 | 178 | # Unresolved questions 179 | 180 | # Future possibilities 181 | 182 | In the future we can add hooks for other user actions, such as voting or uploading images. We could also support implementing new post ranking algorithms in plugins. 183 | 184 | Additionally it should be possible for plugins to define new API routes for additional functionality. 185 | 186 | We may also consider to move some existing features into plugins. This applies to features which are mostly separate from core functionality, and which are only used by few instances. For example: 187 | 188 | - Slur filter 189 | - Custom emojis 190 | - Taglines 191 | 192 | In the opposite way, popular plugins may be shipped as part of Lemmy releases, or reimplemented as part of Lemmy core. 193 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lemmy RFCs 2 | 3 | The "RFC" (request for comments) process is intended to provide a consistent 4 | and controlled path for changes to Lemmy (such as new features) so that all 5 | stakeholders can be confident about the direction of the project. 6 | 7 | Many changes, including bug fixes and documentation improvements can be 8 | implemented and reviewed via the normal GitHub pull request workflow. 9 | 10 | Some changes though are "substantial", and we ask that these be put through a 11 | bit of a design process and produce a consensus among the Lemmy community. 12 | 13 | ## Table of Contents 14 | 15 | - [When you need to follow this process] 16 | - [Before creating an RFC] 17 | - [What the process is] 18 | - [The RFC life-cycle] 19 | - [Reviewing RFCs] 20 | - [Implementing an RFC] 21 | - [RFC Postponement] 22 | - [Help this is all too informal!] 23 | - [License] 24 | 25 | 26 | ## When you need to follow this process 27 | [When you need to follow this process]: #when-you-need-to-follow-this-process 28 | 29 | You need to follow this process if you intend to make "substantial" changes to 30 | the Lemmy backend, or the RFC process itself. What constitutes a 31 | "substantial" change is evolving based on community norms and varies depending 32 | on what part of the ecosystem you are proposing to change, but may include the 33 | following. 34 | 35 | - Complex new features which cannot be specified adequately in an issue. 36 | 37 | Some changes do not require an RFC: 38 | 39 | - Rephrasing, reorganizing, refactoring, or otherwise "changing shape does 40 | not change meaning". 41 | - Additions that strictly improve objective, numerical quality criteria 42 | (warning removal, speedup, better platform coverage, more parallelism, trap 43 | more errors, etc.) 44 | 45 | If you submit a pull request to implement a major new feature without going through 46 | the RFC process, it may be closed with a polite request to submit an RFC first. 47 | 48 | ## Before creating an RFC 49 | [Before creating an RFC]: #before-creating-an-rfc 50 | 51 | A hastily-proposed RFC can hurt its chances of acceptance. Low quality 52 | proposals, proposals for previously-rejected features, or those that don't fit 53 | into the near-term roadmap, may be quickly rejected, which can be demotivating 54 | for the unprepared contributor. Laying some groundwork ahead of the RFC can 55 | make the process smoother. 56 | 57 | Although there is no single way to prepare for submitting an RFC, it is 58 | generally a good idea to pursue feedback from other project developers 59 | beforehand, to ascertain that the RFC may be desirable; having a consistent 60 | impact on the project requires concerted effort toward consensus-building. 61 | 62 | The most common preparations for writing and submitting an RFC include talking 63 | the idea over on our [official Zulip server], discussing the topic on our 64 | [developer discussion forum], and occasionally posting "pre-RFCs" on the 65 | developer forum. You may file issues on this repo for discussion, but these are 66 | not actively looked at by the teams. 67 | 68 | As a rule of thumb, receiving encouraging feedback from long-standing project 69 | developers is a good indication that the RFC is worth pursuing. 70 | 71 | 72 | ## What the process is 73 | [What the process is]: #what-the-process-is 74 | 75 | In short, to get a major feature added to Lemmy, one must first get the RFC 76 | merged into the RFC repository as a markdown file. At that point the RFC is 77 | "active" and may be implemented with the goal of eventual inclusion into Lemmy. 78 | 79 | - Fork the RFC repo [RFC repository] 80 | - Copy `0000-template.md` to `text/0000-my-feature.md` (where "my-feature" is 81 | descriptive). Don't assign an RFC number yet; This is going to be the PR 82 | number and we'll rename the file accordingly if the RFC is accepted. 83 | - Fill in the RFC. Put care into the details: RFCs that do not present 84 | convincing motivation, demonstrate lack of understanding of the design's 85 | impact, or are disingenuous about the drawbacks or alternatives tend to 86 | be poorly-received. 87 | - Submit a pull request. As a pull request the RFC will receive design 88 | feedback from the larger community, and the author should be prepared to 89 | revise it in response. 90 | - Now that your RFC has an open pull request, use the issue number of the PR 91 | to update your `0000-` prefix to that number. 92 | - Build consensus and integrate feedback. RFCs that have broad support are 93 | much more likely to make progress than those that don't receive any 94 | comments. Feel free to reach out to the RFC assignee in particular to get 95 | help identifying stakeholders and obstacles. 96 | - Maintainers will discuss the RFC pull request, as much as possible in the 97 | comment thread of the pull request itself. Offline discussion will be 98 | summarized on the pull request comment thread. 99 | - RFCs rarely go through this process unchanged, especially as alternatives 100 | and drawbacks are shown. You can make edits, big and small, to the RFC to 101 | clarify or change the design, but make changes as new commits to the pull 102 | request, and leave a comment on the pull request explaining your changes. 103 | Specifically, do not squash or rebase commits after they are visible on the 104 | pull request. 105 | - At some point, a maintainer will propose a "motion for final 106 | comment period" (FCP), along with a *disposition* for the RFC (merge, close, 107 | or postpone). 108 | - This step is taken when enough of the tradeoffs have been discussed that 109 | maintainers are in a position to make a decision. That does not require 110 | consensus amongst all participants in the RFC thread (which is usually 111 | impossible). However, the argument supporting the disposition on the RFC 112 | needs to have already been clearly articulated, and there should not be a 113 | strong consensus *against* that position. Maintainers use their best judgment 114 | in taking this step, and the FCP itself ensures there is ample time and 115 | notification for stakeholders to push back if it is made prematurely. 116 | - For RFCs with lengthy discussion, the motion to FCP is usually preceded by 117 | a *summary comment* trying to lay out the current state of the discussion 118 | and major tradeoffs/points of disagreement. 119 | - Before actually entering FCP, *all* maintainers must sign off; 120 | this is often the point at which many maintainers first review the 121 | RFC in full depth. 122 | - The FCP lasts ten calendar days, so that it is open for at least 5 business 123 | days. It is also advertised widely, 124 | e.g. in [/c/lemmy](https://lemmy.ml/c/lemmy). This way all 125 | stakeholders have a chance to lodge any final objections before a decision 126 | is reached. 127 | - In most cases, the FCP period is quiet, and the RFC is either merged or 128 | closed. However, sometimes substantial new arguments or ideas are raised, 129 | the FCP is canceled, and the RFC goes back into development mode. 130 | 131 | ## The RFC life-cycle 132 | [The RFC life-cycle]: #the-rfc-life-cycle 133 | 134 | Once an RFC becomes "active" then authors may implement it and submit the 135 | feature as a pull request to the Lemmy repo. Being "active" is not a rubber 136 | stamp, and in particular still does not mean the feature will ultimately be 137 | merged; it does mean that in principle all the major stakeholders have agreed 138 | to the feature and are amenable to merging it. 139 | 140 | Furthermore, the fact that a given RFC has been accepted and is "active" 141 | implies nothing about what priority is assigned to its implementation, nor does 142 | it imply anything about whether a Lemmy developer has been assigned the task of 143 | implementing the feature. While it is not *necessary* that the author of the 144 | RFC also write the implementation, it is by far the most effective way to see 145 | an RFC through to completion: authors should not expect that other project 146 | developers will take on responsibility for implementing their accepted feature. 147 | 148 | Modifications to "active" RFCs can be done in follow-up pull requests. We 149 | strive to write each RFC in a manner that it will reflect the final design of 150 | the feature; but the nature of the process means that we cannot expect every 151 | merged RFC to actually reflect what the end result will be at the time of the 152 | next major release. 153 | 154 | In general, once accepted, RFCs should not be substantially changed. Only very 155 | minor changes should be submitted as amendments. More substantial changes 156 | should be new RFCs, with a note added to the original RFC. Exactly what counts 157 | as a "very minor change" is up to the maintainers to decide. 158 | 159 | 160 | ## Reviewing RFCs 161 | [Reviewing RFCs]: #reviewing-rfcs 162 | 163 | While the RFC pull request is up, maintainers may schedule meetings with the 164 | author and/or relevant stakeholders to discuss the issues in greater detail, 165 | and in some cases the topic may be discussed in maintainer chat. In either 166 | case a summary from the meeting will be posted back to the RFC pull request. 167 | 168 | Maintainers make a final decisions about RFCs after the benefits and drawbacks 169 | are well understood. These decisions can be made at any time, but the maintainers 170 | will regularly issue decisions. When a decision is made, the RFC pull request 171 | will either be merged or closed. In either case, if the reasoning is not clear 172 | from the discussion in thread, the maintainers will add a comment describing the 173 | rationale for the decision. 174 | 175 | 176 | ## Implementing an RFC 177 | [Implementing an RFC]: #implementing-an-rfc 178 | 179 | Some accepted RFCs represent vital features that need to be implemented right 180 | away. Other accepted RFCs can represent features that can wait until some 181 | arbitrary developer feels like doing the work. Every accepted RFC has an 182 | associated issue tracking its implementation in the Lemmy repository; thus that 183 | associated issue can be assigned a priority via the triage process that the 184 | team uses for all issues in the Lemmy repository. 185 | 186 | The author of an RFC is not obligated to implement it. Of course, the RFC 187 | author (like any other developer) is welcome to post an implementation for 188 | review after the RFC has been accepted. 189 | 190 | If you are interested in working on the implementation for an "active" RFC, but 191 | cannot determine if someone else is already working on it, feel free to ask 192 | (e.g. by leaving a comment on the associated issue). 193 | 194 | 195 | ## RFC Postponement 196 | [RFC Postponement]: #rfc-postponement 197 | 198 | Some RFC pull requests are tagged with the "postponed" label when they are 199 | closed (as part of the rejection process). An RFC closed with "postponed" is 200 | marked as such because we want neither to think about evaluating the proposal 201 | nor about implementing the described feature until some time in the future, and 202 | we believe that we can afford to wait until then to do so. Historically, 203 | "postponed" was used to postpone features until after 1.0. Postponed pull 204 | requests may be re-opened when the time is right. We don't have any formal 205 | process for that, you should ask the maintainers. 206 | 207 | Usually an RFC pull request marked as "postponed" has already passed an 208 | informal first round of evaluation, namely the round of "do we think we would 209 | ever possibly consider making this change, as outlined in the RFC pull request, 210 | or some semi-obvious variation of it." (When the answer to the latter question 211 | is "no", then the appropriate response is to close the RFC, not postpone it.) 212 | 213 | 214 | ### Help this is all too informal! 215 | [Help this is all too informal!]: #help-this-is-all-too-informal 216 | 217 | The process is intended to be as lightweight as reasonable for the present 218 | circumstances. As usual, we are trying to let the process be driven by 219 | consensus and community norms, not impose more structure than necessary. 220 | 221 | 222 | ## License 223 | [License]: #license 224 | 225 | This repository is licensed under [AGPL](LICENSE). 226 | -------------------------------------------------------------------------------- /0004-post-tags.md: -------------------------------------------------------------------------------- 1 | - Feature Name: Post Tags 2 | - Start Date: 2023-11-04 3 | - RFC PR: [LemmyNet/rfcs#0004](https://github.com/LemmyNet/rfcs/pull/4) 4 | - Lemmy Issue: [LemmyNet/lemmy#317](https://github.com/LemmyNet/lemmy/issues/317) 5 | 6 | # Summary 7 | 8 | Ability to add descriptive tags to Posts similar to Reddit's Flair system primarily on a per-community basis. 9 | 10 | # Motivation 11 | 12 | Post Tags would allow for vastly improved content filtering (and to a lesser extent searching) both for Users and Admins/Moderators. 13 | 14 | # Guide-level explanation 15 | 16 | Tags grant you more fine grained control over the content you see on Lemmy. Certain users do not want to see certain content and tags allow you to do exactly that. 17 | 18 | For example a lot of communities offer mixed content such as Memes, News and Discussions. Some people would like to only see News or Discussions. In such a case they could blocklist (filter out) the "Meme" tag, going forward they would not be presented with any Memes in that community. 19 | 20 | Another use for tags is better handling of how posts are displayed. For example some people would like the content of a post to stay hidden for all users. This could be the case in a community focused on release discussions of Books, Movies, TV Shows or communities with content some users might find offensive but which is not neccesarily NSFW (for example jokes about certain topics). 21 | 22 | In order to ensure this consistency while filtering tags can only be created by privileged users, initially that is intended to be Admins and Community moderators. 23 | 24 | Essentially the tags serve as an easier way to message what is _inside_ the post. Combining multiple tags allows for even finer control. Made a post about news in poland? Add the "News" and "Poland" tags to it and people interested exclusively in polish news can find it easily or people not interested can avoid it just as easily. 25 | 26 | # Reference-level explanation 27 | 28 | ## Protocol: 29 | 30 | The [ActivityStreams vocabulary](https://www.w3.org/TR/activitystreams-vocabulary/#dfn-tags) defines that any object can have a list of tags associated with it. Tags in AS can be of any type, so we define our own type `CommunityPostTag`: 31 | 32 | ```jsonc 33 | { 34 | "type": "lemmy:CommunityPostTag", 35 | "id": "community-url/tag/tag-id", // e.g. https://example.org/c/example/tag/News 36 | "name": "Readable Name of Tag", 37 | } 38 | ``` 39 | 40 | In JSON-LD terms, this type will live in the lemmy namespace as `https://join-lemmy.org/ns#CommunityPostTag`), which in objects lemmy sends out is always imported from https://join-lemmy.org/context.json as the prefix `lemmy:`, so we can refer to it as `lemmy:CommunityPostTag`. For example, a lemmy post object (Page in AP terms) would look like this: 41 | 42 | ```json 43 | { 44 | "@context": [ 45 | "https://www.w3.org/ns/activitystreams", 46 | "https://join-lemmy.org/context.json" 47 | ], 48 | "id": "https://enterprise.lemmy.ml/post/55143", 49 | "type": "Page", 50 | "audience": "https://enterprise.lemmy.ml/c/tenforward", 51 | "name": "Post title", 52 | "content": "
This is a post in the /c/tenforward community
\n", 53 | "tag": [ 54 | { 55 | "type": "lemmy:CommunityPostTag", 56 | "id": "https://enterprise.lemmy.ml/c/tenforward/tag/news", 57 | "name": "News" 58 | } 59 | ] 60 | // ... more required props 61 | } 62 | ``` 63 | 64 | Entirely unmoderated tags are not an option for lemmy as the moderation workload would be too much. Additionally users being able to type out tags themselves introduces splintering in the tag contents due to typos. A better solution is a curated list of tags users can attach to their posts. The list of tags can be maintained by both admins and moderators allowing for each community to tailor tags to their specific needs. 65 | Content for tags would be located in the respective root: `https://example.org/c/example/tag/tag` 66 | 67 | The ID of a CommunityPostTag is a URL prefixed with `https://instance/c/community/tags/` and a user-chosen or generated (from the name) ID. The ID itself will rarely be user-visible, since the name is used there. 68 | 69 | For now tags will only be applicable to posts, however the general design allows for them to be attached to any kind of object later on, be that instance, community or user. The limited initial scope allows for easier modifications should any rough edges or missing features be discovered. 70 | Additionally per Tag Inheritance could be added by expanding on this structure, more details can be found in [Future Possibilities > Tag Inheritance](#tag-inheritance). 71 | 72 | Example Tag Objects: 73 | 74 | ```json 75 | { 76 | "type": "lemmy:CommunityPostTag", 77 | "url": "https://example.org/c/news/tag/newspaper-company-1", 78 | "name": "Related to Newspaper Company 1" 79 | } 80 | ``` 81 | 82 | ```json 83 | { 84 | "type": "lemmy:CommunityPostTag", 85 | "url": "https://example.org/c/news/tag/blood-gore", 86 | "name": "Blood/Gore" 87 | } 88 | ``` 89 | 90 | ```json 91 | { 92 | "type": "lemmy:CommunityPostTag", 93 | "url": "https://example.org/c/news/tag/news", 94 | "name": "News" 95 | } 96 | ``` 97 | 98 | Below is an example of a News post in the news community. The post has a communtiy tag for the newspaper company that published it, as well as a content warning for Blood/Gore. 99 | 100 | Example Post json: 101 | 102 | ```json 103 | { 104 | "@context": [ 105 | "https://www.w3.org/ns/activitystreams", 106 | "https://join-lemmy.org/context.json" 107 | ], 108 | "to": [ 109 | "https://example.org/c/news", 110 | "https://www.w3.org/ns/activitystreams#Public" 111 | ], 112 | "audience": "https://example.org/c/news", 113 | "content": ". . .", 114 | "sensitive": true, 115 | "tag": [ 116 | { 117 | "type": "lemmy:CommunityPostTag", 118 | "url": "https://example.org/c/news/tag/newspaper-company-1", 119 | "name": "Related to Newspaper Company 1" 120 | }, 121 | { 122 | "type": "lemmy:CommunityPostTag", 123 | "url": "https://example.org/c/news/tag/blood-gore", 124 | "name": "Blood/Gore" 125 | }, 126 | { 127 | "type": "lemmy:CommunityPostTag", 128 | "url": "https://example.org/c/news/tag/news", 129 | "name": "News" 130 | } 131 | ] 132 | } 133 | ``` 134 | 135 | ## Backend: 136 | 137 | I am not quite familiar with the Lemmy Backend so any corrections or additions for this section are appreciated. 138 | 139 | One new table for "community_post_tag" would be required: 140 | 141 | ```sql 142 | CREATE TABLE community_post_tag ( 143 | id serial PRIMARY KEY, 144 | community_id int REFERENCES community.id, 145 | ap_id text UNIQUE NOT NULL, 146 | name text NOT NULL, 147 | published timestamptz NOT NULL, 148 | deleted timestamptz NULL, 149 | ); 150 | ``` 151 | 152 | Additional columns for tag display style (for example background & text color) and hierarchy could be added later by extending this table. 153 | 154 | Additionally, a way to store the association between posts and tags is needed. This can either be done with a `tags: array[int]` column in the post table and a inverse index (`GIN` or `GIST`) or with a new table `post_tag (post_id, tag_id)` 155 | 156 | Instance Admins should have the option to delete/ban tags. 157 | Instances with nsfw disables/blocked could/should auto reject posts with an nsfw flavor tag. 158 | 159 | The following API routes will need to be added: 160 | 161 | **GET /api/v3/tag/list:** 162 | Parameters: 163 | 164 | - community_id (required) 165 | - auth (optional) 166 | 167 | Returns: 168 | List of all tags in a community. 169 | Deleted tags should not be returned in the list unless an admin/moderator. 170 | 171 | ```json 172 | { 173 | "tags": [ 174 | { 175 | "ap_id": "https://example.org/c/community/tag/foo", // activitypub id 176 | "name": "Foo Tag", 177 | "id": 1, // the lemmy-internal id 178 | "community_id": 1 // lemmy-internal community id 179 | }, 180 | {...} 181 | ] 182 | } 183 | ``` 184 | 185 | **POST /api/v3/tag/create:** 186 | Parameters: 187 | 188 | - id_slug // the generated url will be https://instance/c/community/tags/id_slug 189 | - name 190 | - community_id 191 | 192 | Returns: 193 | Object of freshly created tag 194 | 195 | **PUT /api/v3/tag:** 196 | 197 | Request to update tag object, see the post update API request. 198 | **POST /api/v3/tag/delete:** 199 | 200 | Request to delete tag object, see the post delete API request. 201 | 202 | **ActivityPub Endpoint: GET /c/community/tag/foo (Content-Type: application/activity+json)** 203 | 204 | This is the AP endpoint (not a lemmy api endpoint) and must contain the tag object response in JSON-LD: 205 | 206 | ```json 207 | { 208 | "@context": [ 209 | "https://join-lemmy.org/context.json", 210 | "https://www.w3.org/ns/activitystreams" 211 | ], 212 | "id": "https://example.org/c/community/tag/foo", // activitypub id 213 | "type": "lemmy:CommunityPostTag", 214 | "name": "Foo Tag" 215 | } 216 | ``` 217 | 218 | **Additionally:** 219 | 220 | Posts will need to be made editable by moderators, this is currently not possible but will be required to allow mods to fix missing or misused tags on posts. 221 | Ideally the endpoint that will be opened for this should only allow the addition or removal of tags from a post and nothing else to prevent abuse. 222 | As such I propose the use of: 223 | `POST /post/tag` and `POST /post/tag/delete` for these roles. 224 | Nesting these endpoints under the `/post` endpoint seems appropriate. 225 | Shared parameters would be authentication, `post_id` and `tag_id` with an additional `delete` parameter for the delete endpoint. 226 | 227 | Groups that should be able to add/edit the tags: 228 | 229 | - Instance Admins of the Community 230 | - Moderators of the Community 231 | - Post creator 232 | 233 | ## Frontend: 234 | 235 | **General Changes:** 236 | 237 | Tags can be listed next to the Post title in the feed and at the end of the post in the post view. 238 | Adding tags to a post can be implemented via a separate tag box where they can be typed in with search support. 239 | 240 |  241 | 242 | Tags in the feed should be displayed next to the post interaction elements. 243 |  244 | 245 | **Moderator Changes:** 246 | 247 | Moderators need a UI Section in the community settings for adding, edditing and deleting tags. This could also implement a way to "import" a tag from another instance. 248 | Moderators should also be able to add tags to user posts. 249 | 250 | # Drawbacks 251 | 252 | Adding the tag system would increase backend complexity, increased workload for alternative frontends and apps as well as add another barrier for full federation between lemmy and other services. On top of that the moderation workload would somewhat increase since posts would need to be checked for proper usage of tags as well. 253 | 254 | # Rationale and alternatives 255 | 256 | The proposed system aims to be a balance between the extremely limited flair feature of reddit and the often fragmented tag system of image hosting platforms, combining the best properties of both options into a theoretically ideal version of the system. Additionally the current system with a singular NSFW flag is far too inflexible to properly moderate the scope of content that falls under NSFW. Many instances have implemented a blanket NSFW ban because of this, greatly limiting what content can be posted where. Aside from that the inability to better sort content is a often discussed topic, especially story communities are desperately craving for a better option to both sort posts based on story association as well as hide/blur posts if they contain spoilers. Given the very high community demand not implementing a tag system of some sort will likely lead to a (soft-)fork of lemmy. The feature is extremely desired by many communities. An implementation of tags via UI rendering ([] brackets for tags in text would turn into a tag on a post) would be possible but ultimately far more limiting and would lead to an incosistent experience across lemmy apps/frontends as well as an inability to properly federate the tags. 257 | 258 | # Prior art 259 | 260 | Similar implementations can be found on Reddit as well as a great many image hosting platforms. 261 | 262 | Reddit's Flair System is rather restrictive, a Post can only have a single custom Flair (such as "News") greatly limiting the usefullness of the feature. 263 | 264 | Pros: 265 | 266 | - low moderation effort due to predefined tags 267 | - no/little content fragmentation since typos are not possible 268 | - no flair spam due to only 1 flair being allowed at a time 269 | 270 | Cons: 271 | 272 | - extreme moderation effort for 1st time setup due to inability to mix flairs 273 | - filter lists get extremely long because all variants of a flair need to be filtered (for example "News Europe", "News America", etc. instead of just "News") 274 | - flairs need to be created before being usable 275 | 276 | Tag/Flair Systems on Image hosting platform generally tend to favor a more unmoderated experience, often allowing Users to type in the tags themselves. 277 | 278 | Pros: 279 | 280 | - enhanced user freedom when applying tags 281 | - no delay between arising demand for tag and creation of the tag 282 | 283 | Cons: 284 | 285 | - greater moderation demand since tags have to be checked for inappropriate content 286 | - very high chance for content fragmentation (typos, differences in naming things, language barriers) 287 | - almost completely removes the ability of users to blocklist content tags (pronography would slip past a "pornography" blocklist). 288 | 289 | # Unresolved questions 290 | 291 | - How would tags federate/display on other Fediverse services such as Mastodon? 292 | - ~~Should instance wide and community tags be implemented separately or together. If separately which one should be first.~~ 293 | -> resolved, community tags will be implemented first with instance tags to follow some time later. 294 | - There is a discussion about creation permissions for tags however that changes nothing about the fundamental functionality and can be discussed after initial experience is gathered. 295 | - Should there be a limit on how many tags can be applied? If so, should this limit be hard coded or community configurable? 296 | -> should be made configurable, still up for debate whether to be implemented with this RFC or later on. 297 | 298 | # Future possibilities 299 | 300 | ## Global Tags 301 | 302 | Many tags will probably be the same across different communities. As such, it makes sense to create global tags in the future. These tag objects would still be assigned to posts by users or moderators, but their type would be `GlobalPostTag` and their ID would be global (e.g. `https://join-lemmy.org/tags/xxx`). This way, a user could configure user-global allow/block lists of tags in their Lemmy UI / App. For example Spoiler,Gore,NSFL,Trigger Warning, ... 303 | 304 | ## Filtering of user feeds based on tags 305 | 306 | ## Pre-Selected tags determined by Instance/Community/User settings: 307 | 308 | Allows for easier handling for cases where a few tags are used very often (example: a news community could pre-select the "News" tag, thereby automatically adding it to every users post creation form) 309 | 310 | Addition by [RocketDerp](https://github.com/RocketDerp) (Source: [GitHub Comment](https://github.com/Neshura87/Lemmy-RFC/commit/a11727bb992aa91e89354286876d7144b61b926f#commitcomment-125201367)): 311 | 312 | Tagging of Instances, Communitites and Users using the same system. 313 | 314 | > There are issues open on Lemmy project to have flares for users, flares for posts. I think community itself being tagged is another thing to consider and could be a means to implement a multi-community (multi-reddit) presentation system for blending communities on a post list. 315 | > [...] 316 | > Perhaps a scope smallint added to the proposed database table... scope 0 = all, 1 = community itself tagged, 2 = post tagged, 3 = user tagged. And community_id specific ones would have to be 2 = post. 317 | 318 | ## Migration and replacement of current "NSFW" flag in favor of "NSFW" tag: 319 | 320 | The current flag used to mark posts NSFW can be replaced by a Instance wide default "NSFW" flag once the feature has been field tested. 321 | 322 | ## Tag Amount Limit: 323 | 324 | Unlimited Tag usage might lead to undesired situations and extra moderation effort, long term the addition of Instance or Community limits to number of tags on a Post might be useful. 325 | 326 | ## Instance wide or other tags: 327 | 328 | The basic framework should allow this system to be used in many other contexts, however due to the complexity this should be done after an initial implementation. 329 | Areas that could use this system include: 330 | 331 | - Instance wide post tags (for example a single instance wide NSFW tag or some such) 332 | - User flairs 333 | - Tags on Communities (as opposed to on Posts) 334 | 335 | ## Tag Inheritance: 336 | 337 | Initially Tags will have a flat structure, however an inheritance system could be introduced later on to easy usability for both users and moderators. 338 | Such a system would add an attribute `inherits` to the tag object which would then reference the URL of the parent tag. If no or an empty `inherits` field is given the tag is a "root" tag and has no parent. 339 | The inheritance trees could then be used to enhance search filtering, tag settings upon creation and/or cosmetic behaviour of tags. 340 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc.