mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
feat: delete expired path locations in ephemeral loop
This commit is contained in:
@@ -80,6 +80,7 @@ use crate::contact::ContactId;
|
|||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::download::MIN_DELETE_SERVER_AFTER;
|
use crate::download::MIN_DELETE_SERVER_AFTER;
|
||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
|
use crate::location;
|
||||||
use crate::log::LogExt;
|
use crate::log::LogExt;
|
||||||
use crate::message::{Message, MessageState, MsgId, Viewtype};
|
use crate::message::{Message, MessageState, MsgId, Viewtype};
|
||||||
use crate::mimeparser::SystemMessage;
|
use crate::mimeparser::SystemMessage;
|
||||||
@@ -592,6 +593,11 @@ pub(crate) async fn ephemeral_loop(context: &Context, interrupt_receiver: Receiv
|
|||||||
.await
|
.await
|
||||||
.log_err(context)
|
.log_err(context)
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
|
location::delete_expired(context, time())
|
||||||
|
.await
|
||||||
|
.log_err(context)
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -467,6 +467,25 @@ pub async fn delete_all(context: &Context) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Deletes expired locations.
|
||||||
|
///
|
||||||
|
/// Only path locations are deleted.
|
||||||
|
/// POIs should be deleted when corresponding message is deleted.
|
||||||
|
pub(crate) async fn delete_expired(context: &Context, now: i64) -> Result<()> {
|
||||||
|
let deleted = context
|
||||||
|
.sql
|
||||||
|
.execute(
|
||||||
|
"DELETE FROM locations WHERE independent=0 AND timestamp < ?",
|
||||||
|
(now,),
|
||||||
|
)
|
||||||
|
.await?
|
||||||
|
> 0;
|
||||||
|
if deleted {
|
||||||
|
context.emit_location_changed(None).await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns `location.kml` contents.
|
/// Returns `location.kml` contents.
|
||||||
pub async fn get_kml(context: &Context, chat_id: ChatId) -> Result<Option<(String, u32)>> {
|
pub async fn get_kml(context: &Context, chat_id: ChatId) -> Result<Option<(String, u32)>> {
|
||||||
let mut last_added_location_id = 0;
|
let mut last_added_location_id = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user