Skip to content

feat(daemon): Negotiate media-send capability to skip stopping the daemon#27

Merged
cuiko merged 2 commits into
vika2603:mainfrom
cuiko:feat/daemon-media-version-negotiation
Jun 4, 2026
Merged

feat(daemon): Negotiate media-send capability to skip stopping the daemon#27
cuiko merged 2 commits into
vika2603:mainfrom
cuiko:feat/daemon-media-version-negotiation

Conversation

@cuiko

@cuiko cuiko commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • msg send --sticker/--gif used to always take the local MTProto path, so a running daemon's account lock forced tg daemon stop before every media send. That local-only gate existed only to avoid a stale daemon silently dropping the unknown Sticker/Gif SendQuery fields (→ empty message).
  • The daemon now advertises a msg.send.media capability in its Hello frame; the client routes sticker/GIF sends over IPC when the connected daemon supports it. Capability-based (not version-string), so it's dev-build safe and additive on the wire — an older daemon omits the feature and the client falls back.
  • A media send against a too-old daemon now returns a clear busy error pointing at daemon restart / daemon stop, instead of a bare lock failure. Text sends are unchanged (version-agnostic, always routed through a reachable daemon). File attachments still take the local path (IPC can't carry the bytes).

Test plan

  • go build ./..., go vet ./..., golangci-lint run, go test ./...
  • Unit: SupportsMediaSend true only when the feature is advertised (old daemon → false); Hello frame advertises FeatureMediaSend.
  • Live verification (manual same-account daemons, all cleaned up):
    • New daemon + new CLI: msg send --gif and --sticker succeed while the daemon holds the account lock (a local fallback would ErrBusy), proving they routed over IPC — no daemon stop needed.
    • Old daemon + new CLI: sticker send returns the friendly busy error (exit 72) with restart/stop guidance; a plain text send still routes through the old daemon.

cuiko added 2 commits June 4, 2026 02:57
…emon

`tg msg send --sticker/--gif` unconditionally took the local MTProto path, so
a running daemon's account lock forced users to `tg daemon stop` before
sending media. That local-only gate existed only to dodge a stale daemon
silently dropping the unknown Sticker/Gif SendQuery fields and posting an
empty message.

Have the daemon advertise a media-send capability in its Hello frame and route
sticker/GIF sends over IPC when the connected daemon supports it. This is
dev-build safe (a capability, not a version string) and additive on the wire:
an older daemon omits the feature and the client falls back. When a media send
hits a daemon too old to relay it, return a clear busy error pointing at
`daemon restart` / `daemon stop` instead of a bare lock failure. Text sends are
unchanged — version-agnostic and always routed through a reachable daemon.
The send-path gate is no longer the canDaemonSend helper (removed in favor of
capability negotiation). Update reply's comments to point at newSend instead.
@cuiko
cuiko merged commit cc506aa into vika2603:main Jun 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant