Do not send ephemeral timer updates to unpromoted chats

This commit is contained in:
link2xt
2022-12-15 19:40:29 +00:00
parent c3a0bb2b77
commit 90c478e58d
3 changed files with 63 additions and 10 deletions

View File

@@ -806,6 +806,19 @@ impl ChatId {
.unwrap_or_default())
}
/// Returns true if the chat is not promoted.
pub(crate) async fn is_unpromoted(self, context: &Context) -> Result<bool> {
let param = self.get_param(context).await?;
let unpromoted = param.get_bool(Param::Unpromoted).unwrap_or_default();
Ok(unpromoted)
}
/// Returns true if the chat is promoted.
pub(crate) async fn is_promoted(self, context: &Context) -> Result<bool> {
let promoted = !self.is_unpromoted(context).await?;
Ok(promoted)
}
// Returns true if chat is a saved messages chat.
pub async fn is_self_talk(self, context: &Context) -> Result<bool> {
Ok(self.get_param(context).await?.exists(Param::Selftalk))
@@ -1277,7 +1290,7 @@ impl Chat {
}
pub fn is_unpromoted(&self) -> bool {
self.param.get_int(Param::Unpromoted).unwrap_or_default() == 1
self.param.get_bool(Param::Unpromoted).unwrap_or_default()
}
pub fn is_promoted(&self) -> bool {