lemmy
lemmy copied to clipboard
[WIP] Add backend support for muting communities
Fixes https://github.com/LemmyNet/lemmy/issues/3160
Adding backend support for muting communities in this PR.
The database schema and API are identical to that for blocking of communities.
Communities are muted/unmuted via /api/v3/community/mute
endpoint and the request structure is identical to /community/blocking
:
curl -i -H "Content-Type: application/json" -X POST \
-d "{"mute": true, "auth": "...", "community_id": 3}" \
"http://localhost:8536/api/v3/community/mute"
Where muting differs from blocking is that it only affects listing of posts when ListingType
in PostQuery
is All
or Local
and all of community_id
, creator_id
and search_term
are not provided. Plus PostQuery
takes an optional value show_muted
. When this value is Option<true>
, posts from muted communities are never hidden. I have tried to be conservative with making changes to default API behaviour which is why as things currently are, only the default output for /c/all and /c/local would be affected.
TODO
- [ ] Have to update the API documentation but don't know how to do that yet.
- [ ] There is a lot of code duplication from the community blocking. I am not sure how to modularise. Advice for it is welcome.
- [ ] I don't understand the changes I made in the
apub
crate. I implemented theSendActivity
trait so that compilation succeeds and I can test the changes locally. ActivityPub spec does not mention muting so not sure what to do here. Help appreciated. - [ ] Have to update tests for
post_view.rs
This is already implemented as /api/v3/community/hide
@Nutomic hiding seems to be something that admins do. Like they can hide a community so that it doesn't appear on the front page for every user.
This PR is per user configuration like blocking. I can mute a community so that it does not appear in the all feed for me but continues to appear for other users (unless they choose to mute it too).
I still don't fully understand the difference between community blocking and muting. If I don't want to see a community, why not block it?
Blocking precludes you from interacting with the community in any way. If you mute a community, you can either visit it manually or follow a link to a post in that community and leave a comment there or vote if you want. It just won't appear in your feeds.
To be more clear then, this should be hide_from_feeds
or hide_from_all_and_home
. It wasn't clear to me and I'm sure it won't be to others.
Blocking precludes you from interacting with the community in any way. If you mute a community, you can either visit it manually or follow a link to a post in that community and leave a comment there or vote if you want. It just won't appear in your feeds.
I think theres an open issue about allowing you to browse a blocked community if you explicitly navigate to it, or view a post inside it. I think that would be a reasonable solution and it wouldnt require yet another setting.
That does sound like a better solution to me. I'll look into that and close the PR in a while.