Skip to content

AS3CF (WP Offload) compatibility#42

Merged
PabloPerezDeCiriza merged 28 commits intotinify:masterfrom
wcreateweb:task/as3cf-compatibility
Feb 26, 2025
Merged

AS3CF (WP Offload) compatibility#42
PabloPerezDeCiriza merged 28 commits intotinify:masterfrom
wcreateweb:task/as3cf-compatibility

Conversation

@tijmenbruggeman
Copy link
Copy Markdown
Collaborator

@tijmenbruggeman tijmenbruggeman commented Feb 8, 2025

Changes

  • Remove AS3CF from the core of the plug-in. Having plug-in dependancies in our core logic is a bad practice as changes to a plug-in might affect our own codebase. Instead I made a new class that handles the integration. The integration itself is quite simple. The plug-in provides an action as3cf_pre_upload_object (ref) where we will compress it before offloading.

Integration Tests
The challenging part is that to have fully working integration tests we need to mock AWS (or any other provider) for AS3CF support. I've added localstack to the mock services so that we can mock S3. This allows us to mock the WP Offload functionality. The integration test command will also install as3cf lite.

Changes

  • Added environment variables to wp-env to connect to localstack AWS. These variables will allow as3cf to connect.
  • As we now have two "mock" servers, one being tinify and one AWS, I decided to use docker compose to manage them instead of seperate containers.
  • Added localstack to the mocks. There is an initialization script that will add a bucket for WP Offload to use in tests.
  • Remove a lot in the core of the plug-in because we have encapsulated all external plug-in logic into a seperate class.
  • Added two filters from AS3CF in the fixtures to replace the client endpoints for AS3CF
  • Added utility function to activate and deactivate plugins

Future improvements

  • Add support when the local file is not present. AS3CF has the option to redownload the offloaded files so we could download them, compress and let the plug-in reoffload them. Will be one for a future PR as this will be to big for this PR.

@tijmenbruggeman tijmenbruggeman marked this pull request as draft February 8, 2025 10:45
@tijmenbruggeman tijmenbruggeman marked this pull request as ready for review February 17, 2025 09:29
@rkoopmans
Copy link
Copy Markdown
Contributor

👍

@PabloPerezDeCiriza PabloPerezDeCiriza merged commit 4aa6131 into tinify:master Feb 26, 2025
@tijmenbruggeman tijmenbruggeman deleted the task/as3cf-compatibility branch March 5, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants