Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Oembed config - oembed_endpoints (#2752) #10536

Closed
wants to merge 11 commits into from

Conversation

srdjan-catalyst
Copy link

@srdjan-catalyst srdjan-catalyst commented Aug 5, 2021

Moved twitter patterns from preview_url_resource to oembed_endpoints

Signed-off-by: Srdjan [email protected]

Pull Request Checklist

  • Pull request is based on the develop branch
  • Pull request includes a changelog file. The entry should:
    • Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from EventStore to EventWorkerStore.".
    • Use markdown where necessary, mostly for code blocks.
    • End with either a period (.) or an exclamation mark (!).
    • Start with a capital letter.
  • Pull request includes a sign off
  • Code style is correct (run the linters)

@clokep
Copy link
Member

clokep commented Aug 5, 2021

See also #10392.

@srdjan-catalyst
Copy link
Author

See also #10392.

Yes, it's a bit unfortunate. I made the change some time ago and did not have time to do the PR. Pick one that you like better I guess.

@richvdh
Copy link
Member

richvdh commented Aug 6, 2021

I think this is meant to fix #2752.

@richvdh richvdh requested a review from a team August 6, 2021 08:20
@richvdh richvdh linked an issue Aug 6, 2021 that may be closed by this pull request
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

I've written some words about how I think we should approach this over at #2752 (comment). TL;DR: let's use a providers.json file rather than config.

Also: note that CI is failing; we'll need to fix the failures before we can merge anything.

@richvdh richvdh added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Aug 6, 2021
@richvdh richvdh requested review from richvdh and removed request for richvdh August 9, 2021 10:38
@richvdh
Copy link
Member

richvdh commented Aug 9, 2021

@srdjan-catalyst: it doesn't matter too much in this case, since I didn't give it a thorough review, but please don't force-push changes in future, because it makes it hard to see what has changed since an earlier review.

@srdjan-catalyst
Copy link
Author

@richvdh I'm about to commit again. Would you prefer a separate commit, or squashed force push this time please?

@richvdh
Copy link
Member

richvdh commented Aug 12, 2021

a new commit please. there is never any need to squash.

@anoadragon453 anoadragon453 removed the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Aug 18, 2021
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for your work on this! It's definitely progressing in the right direction, but also I have a few comments below.

synapse/config/oembed.py Outdated Show resolved Hide resolved
oembed/providers.json Outdated Show resolved Hide resolved
changelog.d/10536.misc Outdated Show resolved Hide resolved
synapse/config/oembed.py Outdated Show resolved Hide resolved
synapse/config/oembed.py Outdated Show resolved Hide resolved
synapse/config/oembed.py Outdated Show resolved Hide resolved
synapse/rest/media/v1/preview_url_resource.py Outdated Show resolved Hide resolved
tests/rest/media/v1/test_url_preview.py Outdated Show resolved Hide resolved
tests/rest/media/v1/test_url_preview.py Outdated Show resolved Hide resolved
Comment on lines -583 to -593
client = self.reactor.tcpClients[0][2].buildProtocol(None)
server = AccumulatingProtocol()
server.makeConnection(FakeTransport(client, self.reactor))
client.makeConnection(FakeTransport(server, self.reactor))
client.dataReceived(
(
b"HTTP/1.0 200 OK\r\nContent-Length: %d\r\n"
b'Content-Type: application/json; charset="utf8"\r\n\r\n'
)
% (len(oembed_content),)
+ oembed_content
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think mocking out the HTTP client is fine, but out of interest, was there a reason you chose to replace this logic with mocks?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not make FakeTransport work with SSL at all with tests. I spent a day trying to make it work with no success. Other tests are passing because they are checking that certain requesta are attempted, and the fact that they are breaking at the SSL level does not matter for the outcome. In case of oembed we have two consecutive calls, and the second call never happens because the first one breaks.
Urls that come from oembed.com are (almost) all https, so I wanted to keep that.

@richvdh richvdh added the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Aug 23, 2021
@richvdh richvdh requested a review from a team August 31, 2021 09:23
@erikjohnston erikjohnston removed the X-Awaiting-Changes A contributed PR which needs changes and re-review before it can be merged label Aug 31, 2021
@clokep
Copy link
Member

clokep commented Aug 31, 2021

Hello! I implemented something similar in #10714, I think that meets all the requirements that you were going for, but please shout if not. The changes from that should be in Synapse 1.43.0 (which won't be released for several weeks). Thanks for your contribution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use oembed for url previews?
5 participants