[Standards] The Open Graph protocol

Severino Ferrer de la Peñita seve at delape.net
Thu Nov 5 06:31:07 UTC 2020


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.

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?

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" />

Then, should the format be something like this?

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! :)

PS: I know, I know. You are right, this is a client feature and all this is not needed, but it is useful in scenarios where as an operator
I want to avoid clients automatically visiting URLs without voluntary action, for example.


Kind regards,

Seve
https://delape.net
https://github.com/SeveFP
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.jabber.org/pipermail/standards/attachments/20201105/3a99e8d7/attachment.html>


More information about the Standards mailing list