-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
Fix preview and comment work with proxified images #1656
Conversation
34a67e5
to
0258b15
Compare
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.
A minor suggestion to make it more readable
backend/app/store/image/image.go
Outdated
// Proxied images are returned only if the flag is set: this is used in image check on post preview and load, | ||
// as proxied images have lazy loading and wouldn't be present on disk but still valid as they will be loaded | ||
// the first time someone requests them. | ||
func (s *Service) ExtractPictures(commentHTML string, returnProxied bool) (ids []string) { |
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.
this new bool is used in multiple places and each place needs a comment about what this true/false means. How about making a small "enum" type with "image.DIRECT" and "image.PROXIED" values (consts)? Should make the api more readable
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.
@umputun please take a look at the current version.
Previously, proxied and local images were checked for presence in the storage before previewing or posting the comment. That logic resulted in an inability to post with an image when a proxy for images is enabled, as proxied images are not downloaded to disk before the first time someone loads them, which could only happen after the user either previews or posts the message. After this change, preview and post only checks the local images' presence and ignore the proxied ones.
0258b15
to
d961c58
Compare
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.
LGTM, thx
Previously, image proxying through API was not tested. The test is added here.
Previously, proxied and local images were checked for presence in the storage before previewing or posting the comment. That logic resulted in an inability to post with an image when a proxy for images is enabled, as proxied images are not downloaded to disk before the first time someone loads them, which could only happen after the user either previews or posts the message.
After this change, preview and post only checks the local images' presence and ignore the proxied ones.
Resolves #1631.