WIP: Refactor upload, get url from modules #504

Draft
ilja wants to merge 4 commits from ilja/akkoma:refactor_upload_get_url_from_modules into develop

4 Commits

Author SHA1 Message Date
ilja 9d8ab46cd6 Move building of url to modules
ci/woodpecker/pr/woodpecker Pipeline is pending Details
We got a path and there's a "base_url" function. With that the url was
build. But not all url's are nessecarely build like this. Building the
url should be the responsability of the Uploader itself, so it's now
moved to there.
2023-03-27 09:25:44 +02:00
ilja 2edb0944ba Return the complete `upload` from Pleroma.Uploaders.put_file/2
ci/woodpecker/pr/woodpecker Pipeline is pending Details
To move more logic to the Uploader modules, it's better to keep the same
`upload` and manipulate that while going through the upload pipeline, so
that's how it's now done.

Since we expect the `upload`, I removed the option for returning just `:ok`
from the uploaders.

It was possible to bypass the logic in the `get_url` function, but that was
unused. Since it makes even less sense when returning `upload`, I removed that
In a later stage I want to return the url from the uploader module, which
should obsolete this function.

I saw a warning from `Pleroma.Upload.Filter.MogrifyTest` which I now fixed.
2023-03-26 15:26:11 +02:00
ilja 5db2e998c5 Make getting the uploader constistent
ci/woodpecker/pr/woodpecker Pipeline is pending Details
It was possible to get the uploader from opts.
But during the upload flow, a function was called who didn't use opts and just got it from settings.
This is inconsistent.

In practice, providing the uploader through opts was never used, so I removed it and now we always get it from settings.
2023-03-19 12:00:45 +01:00
ilja 053276ef6c Refactor upload, get url from modules
ci/woodpecker/pr/woodpecker Pipeline is pending Details
To get the url and base url, we had a function in upload.ex.
This included a `case` to check on what module is used.
This means that adding a new upload module implies changing code besides just adding a new module.

Here we try to get the logic properly into the respective modules.
This doesn't add new functionality, but should make it easier to add new uploaders in the future.
2023-03-12 10:13:07 +01:00