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

Let's port to Synapse module API #128

Merged
merged 5 commits into from
Feb 9, 2022
Merged

Let's port to Synapse module API #128

merged 5 commits into from
Feb 9, 2022

Conversation

Yoric
Copy link
Contributor

@Yoric Yoric commented Sep 1, 2021

No description provided.

@Yoric Yoric requested a review from turt2live September 1, 2021 08:14
@Yoric Yoric marked this pull request as draft September 1, 2021 08:14
@Yoric Yoric marked this pull request as ready for review September 1, 2021 08:33
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

it looks like python, but I'm not the best person to review python. Would recommend seeking backend review as well.

@Yoric Yoric requested review from turt2live and richvdh September 2, 2021 06:40
@richvdh richvdh requested review from a team and removed request for turt2live and richvdh September 2, 2021 09:05
@babolivier babolivier linked an issue Sep 2, 2021 that may be closed by this pull request
@richvdh richvdh self-assigned this Sep 3, 2021
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

Remember you'll need to update the documentation for how the module should be installed.

It looks like this change will make the module incompatible with the old API. I recommend supporting both the new API at the same time as the old one, at least for a while, so that we don't need to deploy code and config changes at the same time.

One way to do that is to leave AntiSpam as it is today - complete with definitions of all the methods like user_may_create_room required to implement the old module api - and to define a new class (for example mjolnir.Mjolnir) - which implements the new api and just wraps AntiSpam.

src/commands/UnbanBanCommand.ts Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
@richvdh richvdh removed their assignment Sep 3, 2021
Copy link
Contributor

@Gnuxie Gnuxie left a comment

Choose a reason for hiding this comment

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

Could we add the mx-tester build step to github actions?

mx-tester.yml Outdated Show resolved Hide resolved
@Gnuxie
Copy link
Contributor

Gnuxie commented Feb 7, 2022

Ok, ofc we already have mx-tester build in the CI

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm, except for your implementation of check_username_for_spam which has an error.

A few suggestions/comments though.

README.md Outdated Show resolved Hide resolved
mx-tester.yml Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
class AntiSpam(object):
def __init__(self, config, api):
self.block_invites = config.get("block_invites", True)
self.block_messages = config.get("block_messages", False)
self.block_usernames = config.get("block_usernames", False)
self.list_room_ids = config.get("ban_lists", [])
self.rooms_to_lists = {} # type: Dict[str, BanList]
Copy link
Member

Choose a reason for hiding this comment

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

is this no longer correct, or?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, importing Dict isn't correct anymore, so I guess that this isn't either?

synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
synapse_antispam/mjolnir/antispam.py Outdated Show resolved Hide resolved
@Yoric Yoric merged commit 9c9bd0e into main Feb 9, 2022
@Yoric Yoric deleted the yoric/module-api branch February 9, 2022 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate antispam module to Synapse's new modules system
4 participants