NicolasConstant / sengi

Mastodon & Pleroma Multi-account Desktop Client
https://nicolasconstant.github.io/sengi/
GNU Affero General Public License v3.0
524 stars 34 forks source link

Add GoToSocial URL support #631

Open anantshri opened 6 months ago

anantshri commented 6 months ago

URL which is within the toot content is not rendered properly

Original post : https://tatooine.club/@nemo/111696202370333457

Rendered in sengi as:

image

This is rendered correctly at my server side https://social.anantshri.info/@anant/statuses/01HK9YEMJBS6KR4NP8VTK2RHMB

this is rendered correctly on other clients (icecubes / pinafore)

when i copy all data i get this

https://tatooine.club/@nemo/111696202370333457

<p>Reached almost 50% coverage, and running out of steam so launching the Emoji Calendar 2024:</p><p><a href="https://captnemo.in/emoji-every-day/" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span>captnemo.in/emoji-every-day/</span><span class="invisible"></span></a></p><p>Please suggest more days to add.</p>

Reached almost 50% coverage, and running out of steam so launching the Emoji Calendar 2024:https://captnemo.in/emoji-every-day/Please suggest more days to add.
NicolasConstant commented 6 months ago

If I open this post via a Mastodon account it displays correctly:

image

But it seems you're using some exotic AP server on your side? Maybe there is a conversion between the original content and the content provided by your server's MastoAPI that differs from a common Mastodon/Pleroma/etc MastoAPI output.

Sengi parses MastoAPI content to be able to render it properly, so if it's not exactly the same than an usual MastoAPI output, there will be parsing errors/weird bugs.

tsmethurst commented 6 months ago

It looks like the link is getting dropped inside the processLink function of DatabindedTextComponent: https://github.com/NicolasConstant/sengi/blob/0f58252c61cd9cb4728268c738808bd09e8c0d8a/src/app/components/stream/status/databinded-text/databinded-text.component.ts#L157-L198

Links in GoToSocial are just the URL with an anchor around them and an appropriate href. Nothing fancy. They look like this:

<a href="https://example.org" rel="nofollow noreferrer noopener" target="_blank">https://example.org</a>

Sometimes they'll look more like this, if the user who posted the link has Markdown enabled and wrote a link in a slightly fancier way:

<a href="https://example.org" rel="nofollow noreferrer noopener" target="_blank">example link</a>

Or even like this, if the user added a title to the link:

<a href="https://example.org" title="this is a link title" rel="nofollow noreferrer noopener" target="_blank">example link</a>

Perhaps it would be possible to allow such links through instead of dropping them, since they're very standard, safe HTML.

NicolasConstant commented 6 months ago

So it's more about GoToSocial link support then?

If I remember correctly, link parsing was related to some Electron edge cases, that's not something I would change right now. It would be better to just document the new use cases via the unit tests and fix the code accordingly.