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

Initial support for ban syncing + minor improvements and bugfixes #1807

Open
wants to merge 14 commits into
base: develop
Choose a base branch
from

Conversation

funderscore1
Copy link

@funderscore1 funderscore1 commented Jun 14, 2024

Few improvements to the bridge:

Change format for bridging file uploads and codeblocks to something more natural to IRC users
For file uploads:

<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing/image.png (20KiB)

For code blocks:

<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing

Change default format for replies, again, to something that's a bit more natural
New format:

<f_[mtrx]> f_: "hi everyone!..." <- hi!

Handle replying to self
New format (long):

<f_[mtrx]> <f_[mtrx]> what is this
<f_[mtrx]> ^

Use "`" instead of an "M" when the nick starts with an invalid character
This is more in-line with what a usual IRC user would do, and less noticeable.

Fix bug when replying to a long message
See #1521

In !cmd, don't require commands be uppercase
IRC commands are, for the most part, case-insensitive. For example, with NICK:

NICK funderscore1
:[email protected] NICK :funderscore1
nick funderscore12
:[email protected] NICK :funderscore12
Nick funderscore1
:[email protected] NICK :funderscore1
NIcK funderscore12
:[email protected] NICK :funderscore12

Or PING:

Ping :D
:helix.oftc.net PONG helix.oftc.net :D
PING :D
:helix.oftc.net PONG helix.oftc.net :D
pIng :D
:helix.oftc.net PONG helix.oftc.net :D
ping :D
:helix.oftc.net PONG helix.oftc.net :D

Fix a formatting issue in !help

Doesn't need much explanation.

Initial support for bridging Matrix bans to IRC

This is the big one. The bridge used to treat matrix bans as kicks, thus only kick the IRC user that has been banned on Matrix.

This resulted in IRC users still annoying other IRC users while the Matrix side didn't notice anything at all.

Now, matrix bans are bridged as /mode +b ${nick}!*@* and /kick ${nick}. Unbanning is still unimplemented, so moderators will need to manually send a raw command to the admin room: !cmd mode #channel -b ${nick}!*@*.


Feedback welcome!

@funderscore1 funderscore1 requested a review from a team as a code owner June 14, 2024 20:18
@funderscore1 funderscore1 changed the title Change format for replies/uploads & don't require commands be uppercase in !cmd [UNTESTED] Change format for replies/uploads & don't require commands be uppercase in !cmd Jun 14, 2024
@funderscore1 funderscore1 changed the title [UNTESTED] Change format for replies/uploads & don't require commands be uppercase in !cmd Change format for replies/uploads & don't require commands be uppercase in !cmd Jun 16, 2024
@funderscore1
Copy link
Author

This is now ready for review.

@funderscore1 funderscore1 changed the title Change format for replies/uploads & don't require commands be uppercase in !cmd Bridge improvements and bug fixing Jun 18, 2024
@funderscore1
Copy link
Author

ping?

Ferass El Hafidi added 5 commits July 29, 2024 01:05
Usually, IRC users just upload files somewhere and send a bare link,
perhaps with a bit of explanation.

The bridge originally did something like this for files:

	* f_[mtrx] uploaded an image: (20KiB) < https://matrix.org/_matrix/media/v3/download/something/some-other-thing/image.png >

and something like this for code blocks:

	* f_[mtrx] sent a code block: https://matrix.org/_matrix/media/v3/download/something/some-other-thing

That is quite unusual on IRC. This commit changes it to:

	<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing/image.png (20KiB)
	<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing

Which is more natural.

Signed-off-by: Ferass El Hafidi <[email protected]>
It previously was:

	<f_> hi everyone, what's up? I'm about to migrate some stuff today
	~ a while after ~
	<f_[mtrx]> <f_> "hi everyone,..." <- hi, doing great!

Now it is:

	<f_> hi everyone, what's up? I'm about to migrate some stuff today
	~ a while after ~
	<f_[mtrx]> f_: "hi everyone,..." <- hi, doing great!

Some IRC clients may not create a ping when the nickname is surrounded
with `<` and `>`.

Signed-off-by: Ferass El Hafidi <[email protected]>
when using `!cmd`

IRC commands can be lowercase.

Signed-off-by: Ferass El Hafidi <[email protected]>
@funderscore1
Copy link
Author

funderscore1 commented Jul 28, 2024

gentle ping - could anyone review this please?

@funderscore1 funderscore1 changed the title Bridge improvements and bug fixing Initial support for ban syncing + minor improvements and bugfixes Jul 29, 2024
Copy link
Contributor

@tadzik tadzik left a comment

Choose a reason for hiding this comment

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

Sorry for the long wait.

I generally agree with everything, there's just a few nitpicks. Nice work!

Can we get test to selfReplyTemplate as well? Should be easy enough to cargo-cult the other ones. This would give us an excuse to cover the 4th case (the one that's currently a compilation error).

src/bridge/MatrixHandler.ts Outdated Show resolved Hide resolved
src/bridge/MatrixHandler.ts Show resolved Hide resolved
src/bridge/MatrixHandler.ts Show resolved Hide resolved
src/bridge/MatrixHandler.ts Show resolved Hide resolved
src/irc/BridgedClient.ts Show resolved Hide resolved
src/irc/BridgedClient.ts Show resolved Hide resolved
src/models/IrcAction.ts Show resolved Hide resolved
src/models/MatrixAction.ts Show resolved Hide resolved
Ferass El Hafidi added 3 commits August 3, 2024 23:10
starts with an invalid character

Looks more natural to IRC users. IRC users usually add an underscore at
the beginning or a "`".

With that, "M24Hacker[m]" becomes "`24Hacker[m]"

Signed-off-by: Ferass El Hafidi <[email protected]>
The bridge used to *not* bridge Matrix bans to IRC. As such, when
someone banned an IRC user from Matrix, it would only prevent Matrix
users from seeing messages coming from said user, but would not ban that
user from IRC at all. This resulted in Matrix channel moderators being
confused when other IRC users are reporting spam that simply isn't
bridged at all as a result.

This commit adds support for bridging Matrix bans to IRC. Currently, it
just bans on IRC based on the IRC user's nickname, but this could change
in the future, and most importantly is better than not bridging the
ban at all.

Signed-off-by: Ferass El Hafidi <[email protected]>
Copy link
Contributor

@tadzik tadzik left a comment

Choose a reason for hiding this comment

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

LGTM but we're failing all sorts of tests

@funderscore1 funderscore1 force-pushed the bridge-improvements branch 2 times, most recently from 1ee448c to 6d92beb Compare August 6, 2024 12:10
@tadzik
Copy link
Contributor

tadzik commented Aug 7, 2024

Plenty of test regressions here. Tricky to track down, since we're changing so many things at once.

Test "should allow arbitrary IRC commands to be issued" fails presumably due to command casing changes in 7956631

fb0a326 changes some Matrix->IRC messages from emote to message, which trips up the tests that expect action instead of message. This manifests itself as a timeout, since the expected "action" never arrives, so the tests waits too long.

I know it's late in the process, but I think it'd make sense to split this PR into a few smaller ones, so that the big features (like the ban syncing) don't block the minor things (like case-insensitive command handling). Not only it'll make it obvious what broke which test, it'll make the changelog much neater – we currently expect these to be a single item pointing to a single PR, and mega-PRs like this one would make it a lot trickier to process.

Ferass El Hafidi added 2 commits August 14, 2024 15:27
When someone sent a message:

	<f_[mtrx]> Hello?

And then replied to their own message:

	<f_[mtrx]> > <@Funderscore:nova.astraltech.org> Hello?
	           Hi?

What would be sent on IRC would either be this:

	<f_[mtrx]> Hello?
	<f_[mtrx]> f_[mtrx]: Hi?

Or:

	<f_[mtrx]> Hello?
	-- a while later --
	<f_[mtrx]> f_[mtrx]: "Hello?" <- Hi?

Both of which are confusing because usually nobody pings themself on
IRC.

This commit treats replies to self differently, and introduces a new
`selfReplyTemplate` config option, so that the reply gets bridged as:

	<f_[mtrx]> <f_[mtrx]> Hello?
	<f_[mtrx]> Hi?

Which is a bit more natural.

Signed-off-by: Ferass El Hafidi <[email protected]>
Usually, IRC users just upload files somewhere and send a bare link,
perhaps with a bit of explanation.

The bridge originally did something like this for files:

	* f_[mtrx] uploaded an image: (20KiB) < https://matrix.org/_matrix/media/v3/download/something/some-other-thing/image.png >

and something like this for code blocks:

	* f_[mtrx] sent a code block: https://matrix.org/_matrix/media/v3/download/something/some-other-thing

That is quite unusual on IRC. This commit changes it to:

	<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing/image.png (20KiB)
	<f_[mtrx]> https://matrix.org/_matrix/media/v3/download/something/some-other-thing

Which is more natural.

Signed-off-by: Ferass El Hafidi <[email protected]>
Ferass El Hafidi added 4 commits August 14, 2024 15:27
Signed-off-by: Ferass El Hafidi <[email protected]>
Signed-off-by: Ferass El Hafidi <[email protected]>
@tadzik
Copy link
Contributor

tadzik commented Aug 28, 2024

One linting error away and the changelog, and we should be good to go

@tadzik
Copy link
Contributor

tadzik commented Sep 12, 2024

I've split it into #1821, #1822 and #1823, hopefully I didn't miss anything.

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.

2 participants