Draft: feat: URL previews
Implements: #11640
There is a lot wrong with this MR, it's a draft, but I pushed it here nonetheless just to signal that I had a look at this (I don't particularly want to own it and I'm not sure when I'll get back to it, so if anybody else wants to pick up from here, be my guest ;)). I think the dependency-free OpenGraphParser implementation is mostly OK, maybe it should stop parsing as soon as we have a title and a description. It does not parse the HTML to check if a different namespace prefix than og: is defined, but FWIW, in Wikipedia at least, they actually don't even define it and just use og:. I suspect almost everybody does it this way.
@lovetox I have a few questions whenever you feel like having a look:
- Do we want to parse incoming metadata included by Cheogram, cf https://wiki.soprani.ca/CheogramApp/LinkPreviews
- Do we want to include such metadata in outgoing messages?
- If the answer to one of this questions is yes, should it be part of this MR, or should this specific MR focus on generating previews locally?
- Do we want to support previews of multiple links in a single message?
About the general design, I think it would not be great to re-fetch and re-parse whenever the chat view is opened, do you agree? I am not sure what is the best course of action to do so, I see two options:
- Download the HTML file once, and (re)parse it for metadata every time the conversation view is opened.
- Actually store the link metadata in the DB, which would require an additional column somewhere. Presumably a single JSON column would be a good fit, nothing is relational about this (except the message it belongs to).