mirror of
https://github.com/chatmail/core.git
synced 2026-05-25 01:36:31 +03:00
rustfmt
This commit is contained in:
27
src/chat.rs
27
src/chat.rs
@@ -1943,19 +1943,18 @@ impl MuteDuration {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_muted (
|
||||
context: &Context,
|
||||
chat_id: ChatId,
|
||||
duration: MuteDuration
|
||||
) -> Result<(), Error>{
|
||||
pub fn set_muted(context: &Context, chat_id: ChatId, duration: MuteDuration) -> Result<(), Error> {
|
||||
let mut success = false;
|
||||
ensure!(!chat_id.is_special(), "Invalid chat ID");
|
||||
if real_group_exists(context, chat_id) && sql::execute(
|
||||
if real_group_exists(context, chat_id)
|
||||
&& sql::execute(
|
||||
context,
|
||||
&context.sql,
|
||||
"UPDATE chats SET muted_until=? WHERE id=?;",
|
||||
params![duration.serialize(), chat_id],
|
||||
).is_ok() {
|
||||
)
|
||||
.is_ok()
|
||||
{
|
||||
context.call_cb(Event::ChatModified(chat_id));
|
||||
success = true;
|
||||
}
|
||||
@@ -2868,13 +2867,23 @@ mod tests {
|
||||
false
|
||||
);
|
||||
// Timed in the future
|
||||
set_muted(&t.ctx, chat_id, MuteDuration::MutedUntilTimestamp(time() + 3600)).unwrap();
|
||||
set_muted(
|
||||
&t.ctx,
|
||||
chat_id,
|
||||
MuteDuration::MutedUntilTimestamp(time() + 3600),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
Chat::load_from_db(&t.ctx, chat_id).unwrap().is_muted(),
|
||||
true
|
||||
);
|
||||
// Time in the past
|
||||
set_muted(&t.ctx, chat_id, MuteDuration::MutedUntilTimestamp(time() - 3600)).unwrap();
|
||||
set_muted(
|
||||
&t.ctx,
|
||||
chat_id,
|
||||
MuteDuration::MutedUntilTimestamp(time() - 3600),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
Chat::load_from_db(&t.ctx, chat_id).unwrap().is_muted(),
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user