UniversityOfHelsinkiCS / toska-silta

Minttuinen discord silta
0 stars 4 forks source link

Fix slack to discord urls breaking #20

Closed Jakousa closed 2 years ago

Jakousa commented 3 years ago

Happens sometimes, no repro idea. Might have something to do with an embed? There might be a regex solution to check every message and remove if this happens.

(Btw embeds are not passed to the other side. Maybe they should? Is it possible?)

image

ZeroDayOwl commented 3 years ago

If the URLs work fine, Discord should be able to generate the embeds there. So even if it is possible, I think passing embeds would be redundant.

ZeroDayOwl commented 3 years ago

Also @Jakousa, your URL is being pipe-lined through itself, because http://yle.fi/uutiset/3-12125116%7Chttp://yle.fi/uutiset/3-12125116 is the same as http://yle.fi/uutiset/3-12125116|http://yle.fi/uutiset/3-12125116.

image

I think it might have something to do with the embed. The API gets the messages, and since there's an embed after the URL, it might have been placing the embed's URL (which is the same as the original one) after the original URL with a pipeline.

sasumaki commented 3 years ago

I maybe fixed it https://github.com/UniversityOfHelsinkiCS/toska-silta/commit/e55e20202402d669b9ae649fe70d9f23d6fa37bc Thanks @LoneRanger1337!

ZeroDayOwl commented 3 years ago

No worries @sasumaki !

Rochet2 commented 2 years ago

Issue still persists. Example http://ledbaseline.com/%7CLedbaseline.com Seems that the current regex in https://github.com/UniversityOfHelsinkiCS/toska-silta/commit/e55e20202402d669b9ae649fe70d9f23d6fa37bc is not matching because the latter part of the URL does not have http:// at the beginning of it. Making http:// optional in the regex might fix the issue.

On a quick look the code in https://github.com/UniversityOfHelsinkiCS/toska-silta/commit/e55e20202402d669b9ae649fe70d9f23d6fa37bc looked to me like it erases the entire link (replaces with empty string) resulting in no link at all, so I did not commit a fix yet. Should probably test it before committing.

Rochet2 commented 2 years ago

This should now be fixed in https://github.com/UniversityOfHelsinkiCS/toska-silta/commit/5496a9ac92e5c3718e6cfc973bc1e07b28bb3fc1

The links in the messages are originally in the following format: <http://google.com/|google.com> The latter part is what a user actually wrote in chat and the former part is a deduced link. I opted to remove everything else except the actual text written by a user, leaving google.com.