matrix-org / matrix-hookshot

A bridge between Matrix and multiple project management services, such as GitHub, GitLab and JIRA.

Home Page:https://matrix-org.github.io/matrix-hookshot/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Select link with `type="text/html"` from RSS feed if there are multiple links

chvp opened this issue · comments

One of the feeds I follow, recently added an atom link per article in addition to a link to the article itself. Example of an entry for clarity:

<entry>
    <title type="text">Snelheidsduivels racen tot wel 230 kilometer per uur op E313 in Tessenderlo: politie trekt rijbewijzen onmiddellijk in</title>
    <id>https://vrtnws.be/p.jG4nqMGVV</id>
    <published>2023-06-12T10:01:03.000Z</published>
    <updated>2023-06-12T10:01:03.000Z</updated>
    <summary type="text">De lokale politiezone Beringen - Ham - Tessenderlo heeft afgelopen weekend vijf rijbewijzen onmiddellijk ingetrokken na ernstige snelheidsovertredingen. Op de E313 in Beringen haalde een bestuurder 192 kilometer per uur. Op diezelfde snelweg werden in de richting van Antwerpen drie voertuigen gecontroleerd die elkaar opjutten en tot wel 230 kilometer per uur reden.</summary>
    <vrtns:nstag xmlns="">Binnenland</vrtns:nstag>
    <vrtns:nslabeltag xmlns="">system:vrtnieuws/brands/radio-2</vrtns:nslabeltag>
    <link href="https://www.vrt.be/vrtnws/nl/2023/06/12/snelheidsduivels-e313.rss.xml" rel="self" title="Snelheidsduivels racen tot wel 230 kilometer per uur op E313 in Tessenderlo: politie trekt rijbewijzen onmiddellijk in" type="application/atom+xml"></link>
    <link href="https://vrtnws.be/p.jG4nqMGVV" rel="alternate" title="Snelheidsduivels racen tot wel 230 kilometer per uur op E313 in Tessenderlo: politie trekt rijbewijzen onmiddellijk in" type="text/html"></link>
    <link href="https://images.vrt.be/vrtnws_share/2020/12/29/3da9eaa9-49eb-11eb-aae0-02b7b76bf47f.jpg" rel="enclosure" type="image/jpeg"></link>
</entry>

Note the three links at the bottom. For hookshot, it would make sense (IMO) to use the second link in the messages it sends; users expect to be taken to a normal webpage when clicking links like that in their preferred matrix client. Right now, hookshot uses the first link in the entry, which results in the undesired behaviour of downloading an XML on my devices.

Is there a chance this could be changed to select the link that is most likely to be useful?

Looking at the RSS dependency, having multiple links is apparently an Atom extension. So at least the atom feature would need to be activated for that dependency and the code in parser.rs would need to be changed to detect the presence of that extension and change the link to something more appropriate if present.