diff options
| author | 2025-11-12 17:07:55 +0100 | |
|---|---|---|
| committer | 2025-11-17 14:15:28 +0100 | |
| commit | 4a71d92bb37d3f1bdd214750fa78aec2f7cdf9fa (patch) | |
| tree | b3ac7dbd8c6d8989734adb1c32edbb8a0df9a49a | |
| parent | [bugfix] Add Swagger docs for blur filter action (#4551) (diff) | |
| download | gotosocial-4a71d92bb37d3f1bdd214750fa78aec2f7cdf9fa.tar.xz | |
[bugfix] Fix async-emoji-loading (#4553)
Fixes emoji async loading by having placeholder emojis return a path that correctly resolves to the correct emoji with our HTTP routing (due to a quirk in which we ignore the path extension). This ensures the emoji gets correctly resolved, and if necessary will block until it has been loaded by ProcessingEmoji{}. In some sense it is quite hacky, but also quite elegant in how it relies on existing lock structures we already had in place to block on load without needing to stream emoji model changes to websocket APIs.
closes https://codeberg.org/superseriousbusiness/gotosocial/issues/4529
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4553
Reviewed-by: tobi <kipvandenbos@noreply.codeberg.org>
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
| -rw-r--r-- | internal/media/processingemoji.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/media/processingemoji.go b/internal/media/processingemoji.go index feb54da2f..ce9000472 100644 --- a/internal/media/processingemoji.go +++ b/internal/media/processingemoji.go @@ -69,6 +69,13 @@ func (p *ProcessingEmoji) LoadAsync(deferred func()) *gtsmodel.Emoji { } }) + var pathID string + if p.newPathID != "" { + pathID = p.newPathID + } else { + pathID = p.emoji.ID + } + // Placeholder returns a copy of internally stored processing placeholder, // returning only the fields that may be known *before* completion, // and as such all fields which are safe to concurrently read. @@ -82,6 +89,15 @@ func (p *ProcessingEmoji) LoadAsync(deferred func()) *gtsmodel.Emoji { placeholder.Disabled = p.emoji.Disabled placeholder.VisibleInPicker = p.emoji.VisibleInPicker placeholder.CategoryID = p.emoji.CategoryID + + // We specifically set placeholder path values that allow an API user to fetch the appropriate + // emoji, even if we don't know what filetype it is yet. (since we just parse the IDs from URL path). + // + // This way the API caller can (in the worst case that it hasn't loaded yet) attempt to fetch the emoji, + // then block on ProcessingEmoji{}.Load() for the processing entry it gets from a call to the dereferencer. + placeholder.ImageURL = uris.URIForAttachment(p.instAccID, string(TypeEmoji), string(SizeOriginal), pathID, "loading") + placeholder.ImageStaticURL = uris.URIForAttachment(p.instAccID, string(TypeEmoji), string(SizeStatic), pathID, "png") + return placeholder } |
