Never reset gossip timestamp for all chats at the same time

This commit is contained in:
Alexander Krotov
2020-01-10 08:56:48 +03:00
parent 8eebd2aa67
commit 6c838ab57c
2 changed files with 17 additions and 27 deletions

View File

@@ -1678,7 +1678,7 @@ fn real_group_exists(context: &Context, chat_id: u32) -> bool {
.unwrap_or_default() .unwrap_or_default()
} }
pub fn reset_gossiped_timestamp(context: &Context, chat_id: u32) -> crate::sql::Result<()> { pub fn reset_gossiped_timestamp(context: &Context, chat_id: u32) -> Result<(), Error> {
set_gossiped_timestamp(context, chat_id, 0) set_gossiped_timestamp(context, chat_id, 0)
} }
@@ -1699,31 +1699,23 @@ pub fn set_gossiped_timestamp(
context: &Context, context: &Context,
chat_id: u32, chat_id: u32,
timestamp: i64, timestamp: i64,
) -> crate::sql::Result<()> { ) -> Result<(), Error> {
if 0 != chat_id { ensure!(
info!( chat_id > DC_CHAT_ID_LAST_SPECIAL,
context, "can not add member to special chats"
"set gossiped_timestamp for chat #{} to {}.", chat_id, timestamp, );
); info!(
context,
"set gossiped_timestamp for chat #{} to {}.", chat_id, timestamp,
);
sql::execute( sql::execute(
context, context,
&context.sql, &context.sql,
"UPDATE chats SET gossiped_timestamp=? WHERE id=?;", "UPDATE chats SET gossiped_timestamp=? WHERE id=?;",
params![timestamp, chat_id as i32], params![timestamp, chat_id as i32],
) )?;
} else { Ok(())
info!(
context,
"set gossiped_timestamp for all chats to {}.", timestamp,
);
sql::execute(
context,
&context.sql,
"UPDATE chats SET gossiped_timestamp=?;",
params![timestamp],
)
}
} }
pub fn shall_attach_selfavatar(context: &Context, chat_id: u32) -> Result<bool, Error> { pub fn shall_attach_selfavatar(context: &Context, chat_id: u32) -> Result<bool, Error> {

View File

@@ -5,7 +5,6 @@ use std::fmt;
use num_traits::FromPrimitive; use num_traits::FromPrimitive;
use crate::aheader::*; use crate::aheader::*;
use crate::chat::*;
use crate::constants::*; use crate::constants::*;
use crate::context::Context; use crate::context::Context;
use crate::key::*; use crate::key::*;
@@ -418,7 +417,6 @@ impl<'a> Peerstate<'a> {
&self.addr, &self.addr,
], ],
)?; )?;
reset_gossiped_timestamp(self.context, 0)?;
} else if self.to_save == Some(ToSave::Timestamps) { } else if self.to_save == Some(ToSave::Timestamps) {
sql::execute( sql::execute(
self.context, self.context,