LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.2k stars 875 forks source link

[Bug]: Content removal for local communities does not federate out when banning remote users #4118

Closed Nothing4You closed 7 months ago

Nothing4You commented 11 months ago

Requirements

Summary

When banning and removing content for a remote user, who has posted to a local community, the content removal in local communities does not federate out to other instances and it will stay up.

Steps to Reproduce

  1. Have 3 instances
  2. Create !community@instance1
  3. Subscribe to !community@instance1 from the other 2 instances
  4. Create post 1 to !community@instance1 from @user@instance2
  5. Remove only post 1 as @user@instance1
  6. Post will be marked as removed by mod on all 3 instances -- this works as intended
  7. Create post 2 to !community@instance1 from @user@instance2
  8. Ban @user@instance2 from instance1, selecting ban + remove content
  9. User is banned, but content is removed only from instance1. Removed content stays up on instance2 and instance3.

Technical Details

I've just skimmed through the code, so my conclusions may be wrong.

The code references are referring to main, not 0.18.5, but I assume (untested by me) the issue still exists on main.

As I understand, https://github.com/LemmyNet/lemmy/blob/08739e2925762eb7152f48032e2b170c061b5da0/crates/api/src/local_user/ban_person.rs#L25-L88 is the function called to process banning the user from the local instance. Based on this, as I understand, content removal does not result in federated activities for each content instance, but it's intended to be federated as part of the site (instance) ban. This calls SendActivityData::BanFromSite, which calls send_ban_from_site. send_ban_from_site however has a check to only federate this out if the user is local, therefore a ban with content removal for remote users never gets federated out.

I don't know how this is intended to be handled in ActivityPub, but logically I would assume either site bans from instances other than the user's instance should federate to some degree to support content removal in that instance's communities, or, if this doesn't work, removal for each instance of content created by this user on the instance that bans the user with content removal would need to be queued for federation.

Version

BE: 0.18.5

Lemmy Instance URL

dueu6o.lem.rocks, ib9kux.lem.rocks, w3s72m.lem.rocks

Nothing4You commented 11 months ago

this could probably be replicated with just 2 instances, as removal of individual posts from does federate to the instance the content is coming from, so instance2 and instance3 could be the same instance.

Nutomic commented 11 months ago

This is intended behaviour for "ban from site", it only federates out if a local user is banned. In this case you should use "ban from community" which federates to all other instances if it was made in a local community.

Nothing4You commented 11 months ago

This seems to be both counter-intuitive and undesired. If I ban a user from my instance that has been spamming to a bunch of communities, such as posting unmarked pornographic images to !community@myinstance and 20 other communities on other instances, my goal is to remove all that spam for all users in my instance. Additionally, for all of this content in communities that are hosted on my instance, the removal of this content should also federate out. Currently, this results in the post to !community@myinstance being shown as removed by mod without this federating out, leading me (instance admin) and community mods to believe that content was already removed.

I'm fairly sure that this is a common issue already currently for both lemmy.ml and lemmy.world already. As these are some of the biggest instances, it's of course more common for this stuff to be seen from them, but I've recently seen multiple cases where spam moderation on communities from these instances did not federate to the instance I'm using.

An example, which is still up at this time, is @Mariam28m@masto.es posting spam to !memes@sopuli.xyz (among other places). As you can see at https://sopuli.xyz/u/Mariam28m@masto.es, the user is banned on sopuli and their content has been removed, but the user hasn't been banned by sh.itjust.works yet, which leaves their post to !memes@sopuli.xyz still up on sh.itjust.works.

Edit: reviewing this specific instance, it's also possible that this was not caused by the same issue, as the modlog does show posts purged from the community on sopuli.xyz, which would also explain the lack of federation. There's an argument to be made for this to at least federate as deletion, but that'd be a separate issue, which I've raised in #4119.

Nutomic commented 10 months ago

Yes that definitely makes sense. The problem is that site bans are currently stored as a simple db column person.banned. So if we simply federated the site ban and updated that column, the affected user wouldnt be able to post on any instance which received the ban, and not even login to his home instance.

I guess the solution is to always federate site bans, but on the receiving side store it not as site ban, but as community bans from all the communities of the sending instance.

Edit: Arthur pointed out that this wont help with communities which are created or federated after the ban. Then the solution would be to make a new table person_site_bans, and check it in all relevant queries. Might be complicated...