Skip to content

Commit

Permalink
Update to layer 172
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Jan 26, 2024
1 parent 04d9577 commit bddf790
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 64 deletions.
4 changes: 4 additions & 0 deletions lib/grammers-client/src/client/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ impl SearchIter {
peer: peer.to_input_peer(),
q: String::new(),
from_id: None,
saved_peer_id: None,
saved_reaction: None,
top_msg_id: None,
filter: tl::enums::MessagesFilter::InputMessagesFilterEmpty,
min_date: 0,
Expand Down Expand Up @@ -486,6 +488,7 @@ impl Client {
reply_to_peer_id: None,
quote_text: None,
quote_entities: None,
quote_offset: None,
}
.into()
}),
Expand Down Expand Up @@ -515,6 +518,7 @@ impl Client {
reply_to_peer_id: None,
quote_text: None,
quote_entities: None,
quote_offset: None,
}
.into()
}),
Expand Down
4 changes: 3 additions & 1 deletion lib/grammers-client/src/types/chat/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ impl Channel {
usernames: None,
stories_max_id: None,
color: None,
background_emoji_id: None,
profile_color: None,
emoji_status: None,
level: None,
})
} else {
panic!("tried to create broadcast channel from megagroup");
Expand Down
3 changes: 2 additions & 1 deletion lib/grammers-client/src/types/chat/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ impl User {
close_friend: false,
stories_hidden: false,
stories_unavailable: true,
contact_require_premium: false,
id: empty.id,
access_hash: None,
first_name: None,
Expand All @@ -112,7 +113,7 @@ impl User {
usernames: None,
stories_max_id: None,
color: None,
background_emoji_id: None,
profile_color: None,
},
tl::enums::User::User(user) => user,
})
Expand Down
1 change: 1 addition & 0 deletions lib/grammers-client/src/types/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ impl Media {
M::Dice(dice) => Some(Self::Dice(Dice::from_media(dice))),
M::Story(_) => None,
M::Giveaway(_) => None,
M::GiveawayResults(_) => None,
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/grammers-client/src/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl Message {
id: msg.id,
from_id: msg.from_id,
peer_id: msg.peer_id,
saved_peer_id: None,
fwd_from: None,
via_bot_id: None,
reply_to: msg.reply_to,
Expand Down Expand Up @@ -119,6 +120,7 @@ impl Message {
id: updates.id,
from_id: None, // TODO self
peer_id: chat.to_peer(),
saved_peer_id: None,
fwd_from: None,
via_bot_id: None,
reply_to: input.reply_to.map(|reply_to_msg_id| {
Expand All @@ -133,6 +135,7 @@ impl Message {
reply_to_top_id: None,
quote_text: None,
quote_entities: None,
quote_offset: None,
}
.into()
}),
Expand Down
33 changes: 19 additions & 14 deletions lib/grammers-session/src/chat/hash_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ impl ChatHashCache {
}
}

fn has_dialog_peer(&self, peer: &tl::enums::DialogPeer) -> bool {
match peer {
tl::enums::DialogPeer::Peer(p) => self.has_peer(&p.peer),
tl::enums::DialogPeer::Folder(_) => true,
}
}

fn has_user(&self, peer: &tl::enums::InputUser) -> bool {
match peer {
tl::enums::InputUser::Empty => true,
Expand Down Expand Up @@ -227,15 +234,9 @@ impl ChatHashCache {
U::Config => true,
U::PtsChanged => true,
U::ChannelWebPage(u) => self.has(u.channel_id),
U::DialogPinned(u) => match &u.peer {
tl::enums::DialogPeer::Peer(p) => self.has_peer(&p.peer),
tl::enums::DialogPeer::Folder(_) => true,
},
U::DialogPinned(u) => self.has_dialog_peer(&u.peer),
U::PinnedDialogs(u) => match &u.order {
Some(o) => o.iter().all(|d| match d {
tl::enums::DialogPeer::Peer(p) => self.has_peer(&p.peer),
tl::enums::DialogPeer::Folder(_) => true,
}),
Some(o) => o.iter().all(|d| self.has_dialog_peer(d)),
None => true,
},
U::BotWebhookJson(_) => true,
Expand All @@ -249,10 +250,7 @@ impl ChatHashCache {
U::ChannelReadMessagesContents(u) => self.has(u.channel_id),
U::ContactsReset => true,
U::ChannelAvailableMessages(u) => self.has(u.channel_id),
U::DialogUnreadMark(u) => match &u.peer {
tl::enums::DialogPeer::Peer(p) => self.has_peer(&p.peer),
tl::enums::DialogPeer::Folder(_) => true,
},
U::DialogUnreadMark(u) => self.has_dialog_peer(&u.peer),
U::MessagePoll(_) => true,
U::ChatDefaultBannedRights(u) => self.has_peer(&u.peer),
U::FolderPeers(u) => u.folder_peers.iter().all(|f| match f {
Expand Down Expand Up @@ -362,6 +360,13 @@ impl ChatHashCache {
U::StoriesStealthMode(_) => true,
U::SentStoryReaction(u) => self.has_peer(&u.peer),
U::BotChatBoost(u) => self.has_peer(&u.peer),
U::ChannelViewForumAsMessages(u) => self.has(u.channel_id),
U::PeerWallpaper(u) => self.has_peer(&u.peer),
U::BotMessageReaction(u) => self.has_peer(&u.peer),
U::BotMessageReactions(u) => self.has_peer(&u.peer),
U::SavedDialogPinned(u) => self.has_dialog_peer(&u.peer),
U::PinnedSavedDialogs(_) => true,
U::SavedReactionTags => true,
},
// Telegram should be including all the peers referenced in the updates in
// `.users` and `.chats`, so no instrospection is done (unlike for `UpdateShort`).
Expand Down Expand Up @@ -536,14 +541,14 @@ impl ChatHashCache {
MA::TopicCreate(_) => true,
MA::TopicEdit(_) => true,
MA::SuggestProfilePhoto(_) => true,
MA::RequestedPeer(c) => self.has_peer(&c.peer),
MA::RequestedPeer(c) => c.peers.iter().all(|p| self.has_peer(p)),
MA::SetChatWallPaper(_) => true,
MA::SetSameChatWallPaper(_) => true,
MA::GiftCode(c) => match &c.boost_peer {
Some(p) => self.has_peer(p),
None => true,
},
MA::GiveawayLaunch => true,
MA::GiveawayResults(_) => true,
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions lib/grammers-session/src/message_box/adaptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ pub(super) fn update_short_message(
chat_id: short.user_id,
}
.into(),
saved_peer_id: None,
fwd_from: short.fwd_from,
via_bot_id: short.via_bot_id,
reply_to: short.reply_to,
Expand Down Expand Up @@ -126,6 +127,7 @@ pub(super) fn update_short_chat_message(
chat_id: short.chat_id,
}
.into(),
saved_peer_id: None,
fwd_from: short.fwd_from,
via_bot_id: short.via_bot_id,
reply_to: short.reply_to,
Expand Down Expand Up @@ -478,6 +480,21 @@ impl PtsInfo {
pts_count: 0,
entry: Entry::SecretChats,
}),
ChannelViewForumAsMessages(_) => None,
PeerWallpaper(_) => None,
BotMessageReaction(u) => Some(Self {
pts: u.qts,
pts_count: 0,
entry: Entry::SecretChats,
}),
BotMessageReactions(u) => Some(Self {
pts: u.qts,
pts_count: 0,
entry: Entry::SecretChats,
}),
SavedDialogPinned(_) => None,
PinnedSavedDialogs(_) => None,
SavedReactionTags => None,
}
.filter(|info| info.pts != NO_PTS)
}
Expand Down
Loading

0 comments on commit bddf790

Please sign in to comment.