fix(deps): bump grammers 0.8.1 -> 0.10.0 (MTProto layer 227) - #13
Open
rafanate20 wants to merge 1 commit into
Open
fix(deps): bump grammers 0.8.1 -> 0.10.0 (MTProto layer 227)#13rafanate20 wants to merge 1 commit into
rafanate20 wants to merge 1 commit into
Conversation
Telegram servers reject the old MTProto layer 216 shipped with
grammers 0.8.x, causing every request to fail with rpc error 400
CONNECTION_LAYER_INVALID and breaking sync/daemon.
Upgrade all grammers crates (client, session, mtsender, tl-types)
to 0.10 and migrate to the new APIs:
- grammers_session::defs -> grammers_session::types
- PeerRef { id: PeerId, auth: PeerAuth } (no more Option auth);
PeerId::user/chat/channel now return Option, bare_id() -> Option<i64>
- Session::peer / SqliteSession::open / Client::new(SenderPoolFatHandle)
and stream_updates / sync_update_state are now async
- PeerRef::from(&Peer) removed; use Dialog::peer_ref() or
Peer::to_ref() (new peer_to_ref / peer_to_ref_async helpers)
- types module split: tl::types::update -> tl::types::updates,
Message moved to tl::types root
- Message::peer() -> Option<&Peer>, User::bare_id() -> User::id()
- Document::name() -> Option<&str>
- New required TL fields: SendMessage/EditMessage (rich_message,
schedule_repeat_period), ForwardMessages (effect,
schedule_repeat_period), InputReplyToMessage (poll_option),
InputMediaPoll (attached_media, solution_media), Poll/PollAnswer,
ChatBannedRights (edit_rank, send_reactions), ChatAdminRights
(manage_ranks), contacts::Search (bots, broadcasts)
- ImportChatInvite now returns ChatInviteJoinResult;
InputMedia::Poll takes Box; EditAdmin rank is Option<String>
- from_raw() constructors now require &Client
Verified: profile show, sync chats (236 chats) and full sync with
message fetch all work against a real session.
fix(tg): restore 0.8 peer-resolution semantics after grammers 0.10 port
The 0.10 port turned several previously-infallible APIs into Option/Result
and the mechanical conversion changed behavior in a few places. This keeps
every command behaving as it did on 0.8.
Peer auth resolution:
- `PeerInfo::auth()` is now `Option<PeerAuth>`, where `None` means the peer is
cached but has no usable (non-min) access hash. Mapping that to
`PeerAuth::default()` and returning early produced a zeroed access_hash and
skipped the user/chat/dialog-scan fallbacks that used to recover the peer.
Use `Session::peer_ref()` instead, which yields `None` in that case so the
fallback chain runs as before. Affects chats, folders, users and sync.
- `peer_to_ref` mapped every `Peer::Group` to ambient auth, but a `Group` wraps
`tl::enums::Chat`, which may be a megagroup/gigagroup `Chat::Channel` that
needs an access hash. Handle the channel variants, and propagate session
errors instead of swallowing them into a silently-wrong `PeerRef`.
- Unify the dialog-scan sites on `peer_to_ref_async`; `Dialog::peer_ref()`
unwraps internally and would panic on a peer without auth.
Database keys:
- `PeerId::bare_id()` is now `Option<i64>`. Writing `unwrap_or(-1)` into
`upsert_chat`/`upsert_contact` would collide distinct peers on row -1, and
the daemon did the same with 0 for its chat_id. Skip the record instead.
Inside `if let Peer::User(..)` the enclosing `id` is already the user's bare
id, so reuse it.
Cleanups:
- Carry the resolved `PeerRef` out of the sync filter loop instead of
re-resolving inside each task; the lookup is a database query in 0.10, so it
was being paid twice per chat.
- `resolve_peer_from_session` now delegates to `resolve_peer_from_session_static`
rather than duplicating ~55 lines.
- Flatten the duplicated branches in the chats member resolver.
CI:
- `cargo fmt`.
- `map(..).flatten()` -> `and_then(..)`, matching the idiom used elsewhere in
the port.
- `sort_by` -> `sort_by_key` in two spots that current stable clippy rejects
under `-D warnings`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Telegram servers reject the old MTProto layer 216 shipped with
grammers 0.8.x, causing every request to fail with rpc error 400
CONNECTION_LAYER_INVALID and breaking sync/daemon.
Upgrade all grammers crates (client, session, mtsender, tl-types)
to 0.10 and migrate to the new APIs:
PeerId::user/chat/channel now return Option, bare_id() -> Option
and stream_updates / sync_update_state are now async
Peer::to_ref() (new peer_to_ref / peer_to_ref_async helpers)
Message moved to tl::types root
schedule_repeat_period), ForwardMessages (effect,
schedule_repeat_period), InputReplyToMessage (poll_option),
InputMediaPoll (attached_media, solution_media), Poll/PollAnswer,
ChatBannedRights (edit_rank, send_reactions), ChatAdminRights
(manage_ranks), contacts::Search (bots, broadcasts)
InputMedia::Poll takes Box; EditAdmin rank is Option
Verified: profile show, sync chats (236 chats) and full sync with
message fetch all work against a real session.
fix(tg): restore 0.8 peer-resolution semantics after grammers 0.10 port
The 0.10 port turned several previously-infallible APIs into Option/Result
and the mechanical conversion changed behavior in a few places. This keeps
every command behaving as it did on 0.8.
Peer auth resolution:
PeerInfo::auth()is nowOption<PeerAuth>, whereNonemeans the peer iscached but has no usable (non-min) access hash. Mapping that to
PeerAuth::default()and returning early produced a zeroed access_hash andskipped the user/chat/dialog-scan fallbacks that used to recover the peer.
Use
Session::peer_ref()instead, which yieldsNonein that case so thefallback chain runs as before. Affects chats, folders, users and sync.
peer_to_refmapped everyPeer::Groupto ambient auth, but aGroupwrapstl::enums::Chat, which may be a megagroup/gigagroupChat::Channelthatneeds an access hash. Handle the channel variants, and propagate session
errors instead of swallowing them into a silently-wrong
PeerRef.Unify the dialog-scan sites on
peer_to_ref_async;Dialog::peer_ref()unwraps internally and would panic on a peer without auth.
Database keys:
PeerId::bare_id()is nowOption<i64>. Writingunwrap_or(-1)intoupsert_chat/upsert_contactwould collide distinct peers on row -1, andthe daemon did the same with 0 for its chat_id. Skip the record instead.
Inside
if let Peer::User(..)the enclosingidis already the user's bareid, so reuse it.
Cleanups:
PeerRefout of the sync filter loop instead ofre-resolving inside each task; the lookup is a database query in 0.10, so it
was being paid twice per chat.
resolve_peer_from_sessionnow delegates toresolve_peer_from_session_staticrather than duplicating ~55 lines.
CI:
cargo fmt.map(..).flatten()->and_then(..), matching the idiom used elsewhere inthe port.
sort_by->sort_by_keyin two spots that current stable clippy rejectsunder
-D warnings.Co-Authored-By: Claude Opus 5 & Qwen3.8-27B