[Standards] The Open Graph protocol

Jonas Schäfer jonas at wielicki.name
Mon Nov 9 20:46:14 UTC 2020


Hi Seve,

Thanks for bringing this up. Something like this has been on my mind for a 
while now [1]. I’ll just drop a few thoughts here.

On Donnerstag, 5. November 2020 07:31:07 CET Severino Ferrer de la Peñita 
wrote:
> Hello!
> I'm working on a Prosody module that will use XEP-0422: Message Fastening (
> https://xmpp.org/extensions/xep-0422.html ) to attach URL previews to
> messages by fetching Open Graph Protocol <meta> elements from the URL
> pasted in the chat. I would like to settle on a format that makes sense for
> XMPP so clients could easily understand these fastenings if they wanted to.

Though, I think this is more of a usecase for Message Attaching [2] than for 
Fastenings.

> My ideal scenario would be to basically send the same elements as the ones
> described in https://opengraphprotocol.org/ so as a client developer one
> would have https://opengraphprotocol.org/ as the one and only source of
> truth and avoid having some kind of translator between OGP and the XMPP
> format.
> 
> Using the example from https://opengraphprotocol.org/ a quick prototype
> could be something like:
> 
> 
> 1)
> <message to='alice at example.com mailto:to='alice at example.com
> /converse.js-118260153' xmlns='jabber:client' from='room at chat.example.com
> mailto:from='room at chat.example.com '> <apply-to xmlns='urn:xmpp:fasten:0'
> id='id7489c43f-976c-47a1-9fe1-6a18062b3f49'> <meta xmlns='urn:xmpp:ogp:0'
> property='og:url' content='http://www.imdb.com/title/tt0117500/'/ > <meta
> xmlns='urn:xmpp:ogp:0' property='og:image' content='https://m.media...jpg'/
> > <meta xmlns='urn:xmpp:ogp:0' property='og:type' content='video.movie'/>
> <meta xmlns='urn:xmpp:ogp:0' property='og:title' content='The Rock (1996) -
> IMDb'/> <meta xmlns='urn:xmpp:ogp:0' property='og:site_name'
> content='IMDb'/> <meta xmlns='urn:xmpp:ogp:0' property='og:description'
> content='Directed by Michael Bay. With Sean Connery, Nicolas Cage, Ed
> Harris, John Spencer...'/> </apply-to>
> </message>
> 
> 
> This would be my current preferred way to go, so as a client developer,
> whenever I wanted to extend my client, I would go to the OGP specification
> and include any new properties available.
> 
> The problem I see is possibly with the values of the property attribute. One
> could say the 'og:' prefix is redundant or that it doesn't look "xmppish"
> to have an attribute value like 'og:title'
> 
> Maybe, would this make more sense if that's the issue?

There is always a trade-off to be had when embedding existing protocols. I 
wouldn’t worry too much about the looks. Note that the <meta/> element used by 
OGP is in fact the HTML meta element, so you could correctly namespace it as 
XHTML (xmlns="http://www.w3.org/1999/xhtml" if memory serves right).

Either way, I would suggest to put it in a wrapper container to logically 
group your elements together for easier handling.

> 2)
> <message xmlns='jabber:client' from='room at chat.example.com
> mailto:from='room at chat.example.com ' to='alice at example.com
> mailto:to='alice at example.com /converse.js-118260153'> <apply-to
> xmlns='urn:xmpp:fasten:0' id='id914a1083-4717-44a2-a1fa-a743a0e089c8'>
> <meta xmlns='urn:xmpp:meta:0'>
> <ogp property='site_name'>IMDb</ogp>
> <ogp property='type'>video.movie</ogp>
> <ogp property='title'>The Rock (1996) - IMDb</ogp>
> <ogp property='url'>http://www.imdb.com/title/tt0117500/</ogp
> http://www.imdb.com/title/tt0117500/ > <ogp property='description'>Directed
> by Michael Bay. With Sean Connery, Nicolas Cage, Ed Harris, John
> Spencer...</ogp> <ogp property='image'>https://m.media...jpg</ogp
> https://m.media...jpg > </meta>
> </apply-to>
> </message>
> 
> After scrolling down a bit, I stumbled upon some properties having related
> content in this form (notice the value of the property attribute): <meta
> property="og:image:width" content="400" />

This is a transformation without any gain. I’d go with the previous embedding.


> 3)
> <message xmlns='jabber:client' from='room at chat.example.com
> mailto:from='room at chat.example.com ' to='alice at example.com
> mailto:to='alice at example.com /converse.js-118260153'> <apply-to
> xmlns='urn:xmpp:fasten:0' id='id914a1083-4717-44a2-a1fa-a743a0e089c8'> <ogp
> xmlns='urn:xmpp:ogp:0'>
> <site_name>IMDb</site_name>
> <type>video.movie</type>
> <title>The Rock (1996) - IMDb</title>
> <url>http://www.imdb.com/title/tt0117500/</url
> http://www.imdb.com/title/tt0117500/ > <description>Directed by Michael
> Bay. With Sean Connery, Nicolas Cage, Ed Harris, John
> Spencer...</description> <image content='https://m.media...jpg' >
> <width>400</width>
> <height>300</height>
> <alt>A shiny red apple with a bite taken out</alt>
> <secure_url>https://secure.example.com/ogp.jpg</secure_url
> https://secure.example.com/ogp.jpg > <type>image/jpeg</type>
> </image>
> </ogp>
> </apply-to>
> </message>
> 
> My initial thought is to stick with the first example I've mentioned and do
> something like:
> 
> // Stuff I support for my previews
> PREVIEW = {
> IMAGE = 'og:image',
> DESCRIPTION = 'og:description',
> TITLE = 'og:title',
> }
> .
> .
> .
> apply_to = message.children(xmlns='urn:xmpp:fasten:0')
> preview = Preview.new(to=apply_to.id)
> 
> for meta in apply_to.children()
> switch(meta.property)
> case PREVIEW.IMAGE:
> preview.image = meta.content
> case PREVIEW.DESCRIPTION:
> preview.description = meta.content
> case PREVIEW.TITLE:
> preview.title = meta.content
> 
> preview.display()
> 
> What do you think? Has anyone already implemented such format or feature?
> I would appreciate any feedback and suggestions, thank you! :)

See the references below.

Other than that, I’d like to throw SIMS in the ring -- adding extracted 
preview images as SIMS elements may or may not make sense.

kind regards,
Jonas


   [1]: https://github.com/jabbercat/jabbercat/issues/102
   [2]: https://xmpp.org/extensions/xep-0367.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.jabber.org/pipermail/standards/attachments/20201109/56c1ddf7/attachment.sig>


More information about the Standards mailing list