Skip to content

Improve asset routing logic#9403

Merged
andreslucena merged 15 commits intodecidim:developfrom
mainio:refactor/asset-router
Jun 16, 2022
Merged

Improve asset routing logic#9403
andreslucena merged 15 commits intodecidim:developfrom
mainio:refactor/asset-router

Conversation

@ahukkanen
Copy link
Copy Markdown
Contributor

@ahukkanen ahukkanen commented Jun 8, 2022

🎩 What? Why?

This is a slight refactor as a continuation for ##9285.

When implementing the short URLs at #9383 I realized we also have the Decidim::EngineRouter class which can be utilized to create the local URLs. This PR:

  1. Moves the local default URL options generation from the uploader to the Decidim::EngineRouter for correct separation of concerns
  2. Introduces a new Decidim::AssetRouter which is a proxy class for generating the asset URLs and its sole purpose is to decide whether the routing should be done to the local server or to a remote CDN.

📌 Related Issues

Testing

See #9285 and #9154.

📋 Checklist

  • CONSIDER adding a unit test if your PR resolves an issue.
  • ✔️ DO check open PR's to avoid duplicates.
  • ✔️ DO keep pull requests small so they can be easily reviewed.
  • ✔️ DO build locally before pushing.
  • ✔️ DO make sure tests pass.
  • ✔️ DO make sure any new changes are documented in docs/.
  • ✔️ DO add and modify seeds if necessary.
  • ✔️ DO add CHANGELOG upgrade notes if required.
  • ✔️ DO add to GraphQL API if there are new public fields.
  • ✔️ DO add link to MetaDecidim if it's a new feature.
  • AVOID breaking the continuous integration build.
  • AVOID making significant changes to the overall architecture.

@ahukkanen ahukkanen added target: developer-experience type: internal PRs that aren't necessary to add to the CHANGELOG for implementers labels Jun 8, 2022
@ahukkanen ahukkanen marked this pull request as draft June 8, 2022 22:04
@ahukkanen ahukkanen changed the title Refactor asset routing Improve asset routing logic Jun 8, 2022
@ahukkanen ahukkanen marked this pull request as ready for review June 10, 2022 16:02
@ahukkanen ahukkanen requested a review from andreslucena June 14, 2022 18:28
andreslucena
andreslucena previously approved these changes Jun 15, 2022
Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

I've just gave it a quick spin locally, and everything works as expected: I could see the image on a newsletter in the admin panel and also on letter_opener.

Overall, great work as usual! Just a couple of changes regarding the hosts and the use of example.org or .test in the specs, that I want to hear your feedback, but I can live with it too.

@ahukkanen
Copy link
Copy Markdown
Contributor Author

Thanks @andreslucena, comments resolved.

Copy link
Copy Markdown
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

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

LGTM!

@andreslucena andreslucena merged commit 71c63fc into decidim:develop Jun 16, 2022
@ahukkanen ahukkanen deleted the refactor/asset-router branch June 16, 2022 09:53
andreslucena pushed a commit that referenced this pull request Jul 6, 2022
* Refactor the asset routing in the ApplicationUploader

* Fix the application uploader spec

* Add a spec for the asset router

* Do not modify the ENV vars during the application uploader test

* Fix the correct port expectations in the routing related specs

* Fix generators tests after moving the protocol options from the uploader

* Fix correct expected URL ports in specs

* Disable the images for the PDFs in tests due to jamming

After the image URLs were fixed, the PDF creation "jams" because
the server is busy doing something else when it's trying to
request the images, so those requests will never finish which
causes the tests to timeout (conference tests particularly).

* Move the URL default options generation to another class

* Add specs for the UrlOptionResolver

* Refactor the MultitenantAssetHost to use UrlOptionResolver

DRY

* Change the CDN url to example.org

* Allow other calls to the secrets dig

* Change the production URL to production.decidim.test
eliegaboriau pushed a commit to eliegaboriau/decidim that referenced this pull request Oct 25, 2022
* Refactor the asset routing in the ApplicationUploader

* Fix the application uploader spec

* Add a spec for the asset router

* Do not modify the ENV vars during the application uploader test

* Fix the correct port expectations in the routing related specs

* Fix generators tests after moving the protocol options from the uploader

* Fix correct expected URL ports in specs

* Disable the images for the PDFs in tests due to jamming

After the image URLs were fixed, the PDF creation "jams" because
the server is busy doing something else when it's trying to
request the images, so those requests will never finish which
causes the tests to timeout (conference tests particularly).

* Move the URL default options generation to another class

* Add specs for the UrlOptionResolver

* Refactor the MultitenantAssetHost to use UrlOptionResolver

DRY

* Change the CDN url to example.org

* Allow other calls to the secrets dig

* Change the production URL to production.decidim.test
@alecslupu alecslupu added this to the 0.27.0 milestone Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

target: developer-experience type: internal PRs that aren't necessary to add to the CHANGELOG for implementers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants