mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-03 17:24:13 -04:00
Include more information in oEmbed previews. (#10819)
* Improved titles (fall back to the author name if there's not title) and include the site name. * Handle photo/video payloads. * Include the original URL in the Open Graph response. * Fix the expiration time (by properly converting from seconds to milliseconds).
This commit is contained in:
parent
9391de3f37
commit
6fc8be9a1b
4 changed files with 68 additions and 14 deletions
|
@ -620,11 +620,12 @@ class URLPreviewTests(unittest.HomeserverTestCase):
|
|||
self.assertIn(b"/matrixdotorg", server.data)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
self.assertIsNone(channel.json_body["og:title"])
|
||||
self.assertTrue(channel.json_body["og:image"].startswith("mxc://"))
|
||||
self.assertEqual(channel.json_body["og:image:height"], 1)
|
||||
self.assertEqual(channel.json_body["og:image:width"], 1)
|
||||
self.assertEqual(channel.json_body["og:image:type"], "image/png")
|
||||
body = channel.json_body
|
||||
self.assertEqual(body["og:url"], "http://twitter.com/matrixdotorg/status/12345")
|
||||
self.assertTrue(body["og:image"].startswith("mxc://"))
|
||||
self.assertEqual(body["og:image:height"], 1)
|
||||
self.assertEqual(body["og:image:width"], 1)
|
||||
self.assertEqual(body["og:image:type"], "image/png")
|
||||
|
||||
def test_oembed_rich(self):
|
||||
"""Test an oEmbed endpoint which returns HTML content via the 'rich' type."""
|
||||
|
@ -633,6 +634,8 @@ class URLPreviewTests(unittest.HomeserverTestCase):
|
|||
result = {
|
||||
"version": "1.0",
|
||||
"type": "rich",
|
||||
# Note that this provides the author, not the title.
|
||||
"author_name": "Alice",
|
||||
"html": "<div>Content Preview</div>",
|
||||
}
|
||||
end_content = json.dumps(result).encode("utf-8")
|
||||
|
@ -660,9 +663,14 @@ class URLPreviewTests(unittest.HomeserverTestCase):
|
|||
|
||||
self.pump()
|
||||
self.assertEqual(channel.code, 200)
|
||||
body = channel.json_body
|
||||
self.assertEqual(
|
||||
channel.json_body,
|
||||
{"og:title": None, "og:description": "Content Preview"},
|
||||
body,
|
||||
{
|
||||
"og:url": "http://twitter.com/matrixdotorg/status/12345",
|
||||
"og:title": "Alice",
|
||||
"og:description": "Content Preview",
|
||||
},
|
||||
)
|
||||
|
||||
def test_oembed_format(self):
|
||||
|
@ -705,7 +713,11 @@ class URLPreviewTests(unittest.HomeserverTestCase):
|
|||
self.assertIn(b"format=json", server.data)
|
||||
|
||||
self.assertEqual(channel.code, 200)
|
||||
body = channel.json_body
|
||||
self.assertEqual(
|
||||
channel.json_body,
|
||||
{"og:title": None, "og:description": "Content Preview"},
|
||||
body,
|
||||
{
|
||||
"og:url": "http://www.hulu.com/watch/12345",
|
||||
"og:description": "Content Preview",
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue