-
-
Notifications
You must be signed in to change notification settings - Fork 886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image api rework #5260
Image api rework #5260
Conversation
b38a9ee
to
d252be2
Compare
09b06f0
to
60ba7af
Compare
f66e392
to
7c771d2
Compare
use lemmy_utils::rate_limit::RateLimitCell; | ||
|
||
// Deprecated, use api v4 instead. | ||
// When removing api v3, we also need to rewrite all links in database with | ||
// `/api/v3/image_proxy` to use `/api/v4/image_proxy` instead. | ||
// `/api/v3/image_proxy` to use `/api/v4/image/proxy` instead. | ||
pub fn config(cfg: &mut ServiceConfig, rate_limit: &RateLimitCell) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation was changed in this file, use "hide whitespace" in github to review it.
Ready to review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job, adding these as API actions is going to be much better.
- We still need a way to clear images. I'd add some
POST
orDELETE
endpoints, that just delete the images and return that item. IEPOST /site/icon/delete
,/community/banner/delete
...- Speaking of which, I see that this PR is the first one that adds
HTTP DELETE
. Maybe we should use that instead ofPOST
for all our delete API actions.
- Speaking of which, I see that this PR is the first one that adds
- Banners can't be square. So whether that means adding both a max height and max width, or just unfortunately not being able to resize them.
- We're gonna need a DB migration to fix the history of all proxied images. So unfortunately that means doing a DB replace for
comment.content
, andpost.body
, wherelocal = true
. I believe the regular image endpoints stayed the same, so no need to correct those.
is there a reason to expose the pict-rs delete token to the user? i guess this was historically exposed to the user during upload before it got used in the media listing, but there isn't really any need to keep that, now that we have the media listing. |
9fc02be
to
6123659
Compare
81db6c9
to
c9dfbfe
Compare
Addressed all the review comments. However the api tests are consistently failing and Im not sure why. Seems to be a problem with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the deleteImage is working fine, but look at https://github.com/LemmyNet/lemmy/blob/image-api-rework/api_tests/src/image.spec.ts#L61 , and also L92 .
Its weird because everything's passing locally for me too when I run the federation tests, but in a dockerized environment, this fetch might be timing out.
.woodpecker.yml
Outdated
@@ -95,15 +95,6 @@ steps: | |||
when: | |||
- event: pull_request | |||
|
|||
cargo_clippy: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we get the federation tests figured out, these all need to get re-added back in.
api_tests/run-federation-test.sh
Outdated
@@ -11,7 +11,7 @@ killall -s1 lemmy_server || true | |||
popd | |||
|
|||
pnpm i | |||
pnpm api-test || true | |||
pnpm api-test-image || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also will need to get changed back.
crates/routes/src/images/delete.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
99e7352
to
a45fcc5
Compare
01b3e80
to
4b3f2f5
Compare
5ba5391
to
4b94043
Compare
Found the problem, purges would delete the image from pictrs but not the row from LocalImage table. So it would try to delete the image a second time in afterAll hook using deleteAllImages. Previously this worked fine, but now there is a stricter success check. Not sure why it was passing locally though. |
/api/v4/image/
crates/api_common/src/image.rs
, no more exposing of pictrs data structurescrates/routes/images
adapt_request()
for image upload, not for simple things like delete or health checkPOST /api/v4/account/avatar
which directly takes image upload, instead of setting avatar url via/api/v4/account/settings/save
POST /api/v4/account/banner
,POST /api/v4/community/icon
,POST /api/v4/community/banner
,POST /api/v4/site/icon
andPOST /api/v4/site/banner