feat(v2/ezytel): inline images as base64 data URIs by default#128
Open
hiddifyafk wants to merge 1 commit into
Open
feat(v2/ezytel): inline images as base64 data URIs by default#128hiddifyafk wants to merge 1 commit into
hiddifyafk wants to merge 1 commit into
Conversation
GetChannelInfo and GetChannelMessages now embed avatars and post images as data:image/jpeg;base64,… URIs directly in their JSON/HTML, so a client can render them with no second ProxyImage round-trip. Adds disable_inline_images=true on both requests as an opt-out that preserves the legacy "cache/<md5>.jpg" / "proxy.php?url=<hex>" form. Image fetches reuse the existing translate.goog front and disk cache; GetChannelMessages fans out to 8 workers per page.
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.
Summary
Follow-up to #127. The three image surfaces in
v2/ezytelnow hand back ready-to-renderdata:image/jpeg;base64,…URIs by default, so a JSON / HTML client can paint thumbnails with no secondProxyImageround-trip.GetChannelInfo.avatar_path— was a server-sidecache/<md5>.jpgpath that a remote client could not resolve. Now adata:URI.GetChannelMessages.html—<img src>andbackground-image:url(...)carriedproxy.php?url=<hex>placeholders the client had to intercept. Now resolved server-side and replaced inline.GetChannelMessages.channel_avatar— same treatment.ProxyImageis unchanged and still works as the per-image escape hatch.Wire change
Both requests gain
bool disable_inline_images = 3;. Field name is inverted on purpose — proto3 cannot distinguish unset fromfalse, so leaving the new field at its zero value (the default) gives the desired inline behavior. Set it totrueto opt back into the legacycache/<md5>.jpg/proxy.php?url=<hex>form.Implementation notes
ProxyImageinto a privatefetchImageBytesshared byProxyImage,GetChannelInfo, andGetChannelMessages.dataURL(bytes, contentType)helper.GetChannelMessagesresolves placeholders with a bounded 8-worker fan-out, then substitutes via a singlestrings.NewReplacersweep. Per-image fetch failures leave the placeholder so a single broken image does not fail the whole page.<chid>.jsonsnapshot keeps thecache/<md5>.jpgform so the cache file stays small. The stale-replay path re-encodes from the on-disk JPEG when a caller wants inline.Test plan
go build ./v2/ezytel/...— cleango vet ./v2/ezytel/...— cleango test ./v2/ezytel/... -count=1 -v— 12/12 pass: 7 pre-existing tests plusTestDataURL,TestExtractProxyHexes,TestInlineProxyPlaceholders(concurrent path with hit count),TestInlineProxyPlaceholderSingle,TestDisableInlineImagesNoFetch.grpcurl -plaintext -d '{"channel_id":"durov"}' 127.0.0.1:50051 ezytel.Ezytel/GetChannelInfo→avatarPathstarts withdata:image/jpeg;base64,; piping throughbase64 -dproduces a valid JPEG.grpcurl -plaintext -d '{"channel_id":"durov"}' 127.0.0.1:50051 ezytel.Ezytel/GetChannelMessages→htmlcontainsdata:image/jpeg;base64,…and zeroproxy.php?url=; rendered in a browser shows thumbnails with no further requests.{"channel_id":"durov","disable_inline_images":true}reproduces today'sproxy.php?url=<hex>form.Notes / follow-ups
GetChannelMessagespage may exceed gRPC's 4 MB default. If real pages hit that ceiling, bumpgrpc.MaxSendMsgSize(server) andMaxCallRecvMsgSize(client) at the registration site inv2/hcore/grpc_server.go. Not changed here pending real-world measurement.