fix(msg): Report the count Telegram actually deleted, not requested#29
Merged
Conversation
added 2 commits
June 4, 2026 18:32
`msg delete` printed "deleted N message(s)" with N = the number of IDs requested, even when the server affected fewer. Deleting another user's message self-side in a supergroup is a no-op, yet it still reported success for every ID. Thread the RPC's affected count (PtsCount) through DeleteMessages -> DeleteFunc -> DeleteResult so the output reflects what Telegram actually removed. The daemon's msg.delete handler now returns the count instead of a bare "true"; the client decodes it and, against an older daemon that still answers "true", falls back to the requested count so delete keeps working across a version skew.
Pull the daemon msg.delete response decoding into decodeDeleteCount so the old-daemon fallback (a bare "true" ack -> requested count) is unit-tested rather than only exercised through the production closure.
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
msg deleteprinteddeleted N message(s)with N = the number of IDs requested, even when the server affected fewer. Deleting another user's message self-side in a supergroup is a no-op, yet it still reported success for every ID.PtsCount) throughDeleteMessages→DeleteFunc→DeleteResult, so the output reflects what Telegram actually removed.msg.deletehandler now returns the count instead of a baretrue. The client decodes it and — against an older daemon that still answerstrue— falls back to the requested count so delete keeps working across a version skew.Test plan
go build ./...,go vet,golangci-lint run,go test ./...deleted 1), notlen(ids).deleted 1; deleting a non-existent id →deleted 0(previously1).true) → delete still succeeds via the requested-count fallback (no unmarshal error).