Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature remote reporting #249

Merged
21 commits merged into from
Jan 4, 2024
Merged

Feature remote reporting #249

21 commits merged into from
Jan 4, 2024

Conversation

BentiGorlich
Copy link
Member

@BentiGorlich BentiGorlich commented Nov 11, 2023

Add sending of a FlagMessage whenever a SubjectReportedEvent is fired and add the code that handles that message.
That leads to the propagation of reports.

This branch is based on the previous branch which fetches moderators and subscriber count from remote magazines.

Here is more testing necessary and it is not the easiest to test, especially for the edge cases (e.g.: a local magazine with a remote moderator. The remote moderator should still get the report on his instance).

Resources:

@BentiGorlich BentiGorlich self-assigned this Nov 11, 2023
@BentiGorlich BentiGorlich added enhancement New feature or request activitypub ActivityPub related issues backend Backend related issues and pull requests labels Nov 11, 2023
@BentiGorlich
Copy link
Member Author

Something I noticed is not implemented yet even though I thought it was: notifications on reports. Imo you should definitely be notified via e-mail when a report occurs (should of course be able to be turned off)

@BentiGorlich
Copy link
Member Author

BentiGorlich commented Nov 11, 2023

ToDo List:

  • further testing
  • handle special case with the random magazine

@BentiGorlich BentiGorlich force-pushed the feature_remote_retrieval_mod_followers branch from 945959e to 70f6c11 Compare November 12, 2023 18:05
@BentiGorlich BentiGorlich force-pushed the feature_remote_retrieval_mod_followers branch 3 times, most recently from 475ed19 to 166c0b9 Compare November 23, 2023 21:29
Base automatically changed from feature_remote_retrieval_mod_followers to main November 26, 2023 13:53
@BentiGorlich
Copy link
Member Author

BentiGorlich commented Nov 30, 2023

what do you guys think about sending the report to the home instance of a user, too? If one reports a post, what should happen then?

@BentiGorlich
Copy link
Member Author

BentiGorlich commented Nov 30, 2023

What is working:

  • report posts in a magazine to lemmy or other mBin instances (tested)
  • report posts in the random magazine to Mastodon (tested)

What is not working:

  • report posts in a magazine to Mastodon (not tested, but I would be very suprised if it worked)

@BentiGorlich BentiGorlich marked this pull request as ready for review November 30, 2023 23:00
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE report ADD uuid VARCHAR(255) NULL');
$this->addSql('CREATE UNIQUE INDEX UNIQ_REPORT_UUID ON report (uuid)');
Copy link

@ghost ghost Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to follow the _idx naming convention that's used for indexes elsewhere? Not a big deal, just curious what your preference is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a preference. I just wanted it to have a readably name, but an idx in front of it wouldn't hurt :D

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it should be lower case as well. But more importantly. Since we are using doctrine. You need to define indexes in the entity php file.. For example see how it is done in User.php:

#[Table(name: '`user`', uniqueConstraints: [
    new UniqueConstraint(name: 'user_email_idx', columns: ['email']),
    new UniqueConstraint(name: 'user_username_idx', columns: ['username']),
])]
#[Index(columns: ['visibility'], name: 'user_visibility_idx')]

After you added a unique contain, you can use symphony doctrine CLI command to generate a migration file for you :).. If you don't do this correctly symfony migration diff will also trigger a difference between the code and the DB in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to doctrine via the 'unique' attribute when defining the column. I generated this fipe with the doctrine command and chanhed the index name. Thats all I did 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I did it now causes no diff. When I did it with the #[Table...] attribute I it constantly wanted to rename the index even though it had the name that I put into the migration...

@BentiGorlich BentiGorlich requested review from a user and e-five256 December 18, 2023 20:19
ghost
ghost previously approved these changes Dec 19, 2023
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the most recent commit/fix for earlier issues, federated functional verification for each reporting case seems to "pass" now (albeit via manual 2-way testing with @BentiGorlich's help). And all other federated activity seems to behave normally as well, so I approve!

@BentiGorlich
Copy link
Member Author

what do you guys think about sending the report to the home instance of a user, too? If one reports a post, what should happen then?

@asdfzdfj @e-five256 @melroy89 ?

I think I will not put it in this PR, one can always add that later

- the outbound reports should work now
- add logging
- add id to Outbox/FlagMessage
- make generated urls absolute
- make 'id' and make it a valid url so the signature checks don't fail
- fix using wrong indexes
- implement special case for the random magazine
- add a way to access the report object. Add a UUID field in the db for that
- create a factory which can be used in the new ReportController.php
- the subject could not be found previously, because the subject url was not the absolute url, so if a user reported a post to a remote magazine, that originated from their own instance it would throw errors
@ghost ghost self-requested a review December 22, 2023 15:21
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-approval after merge conflict resolution, no issues observed.

@ghost ghost merged commit 8579724 into main Jan 4, 2024
7 checks passed
@ghost ghost deleted the feature_remote_reporting branch January 4, 2024 14:58
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
activitypub ActivityPub related issues backend Backend related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants