Fix preview and comment work with proxified images#1656
Merged
Conversation
34a67e5 to
0258b15
Compare
umputun
reviewed
Jul 21, 2023
Owner
umputun
left a comment
There was a problem hiding this comment.
A minor suggestion to make it more readable
| // 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) { |
Owner
There was a problem hiding this comment.
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
Collaborator
Author
There was a problem hiding this comment.
@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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.