diff --git a/src/location.rs b/src/location.rs index 164eeb647..26b95903e 100644 --- a/src/location.rs +++ b/src/location.rs @@ -486,6 +486,21 @@ pub(crate) async fn delete_expired(context: &Context, now: i64) -> Result<()> { Ok(()) } +/// Deletes location if it is an independent location. +/// +/// This function is used when a message is deleted +/// that has a corresponding `location_id`. +pub(crate) async fn delete_poi_location(context: &Context, location_id: u32) -> Result<()> { + context + .sql + .execute( + "DELETE FROM locations WHERE independent = 1 AND id=?", + (location_id as i32,), + ) + .await?; + Ok(()) +} + /// Returns `location.kml` contents. pub async fn get_kml(context: &Context, chat_id: ChatId) -> Result> { let mut last_added_location_id = 0; diff --git a/src/message.rs b/src/message.rs index 31f992ad4..e4739bf85 100644 --- a/src/message.rs +++ b/src/message.rs @@ -22,6 +22,7 @@ use crate::download::DownloadState; use crate::ephemeral::{start_ephemeral_timers_msgids, Timer as EphemeralTimer}; use crate::events::EventType; use crate::imap::markseen_on_imap_table; +use crate::location::delete_poi_location; use crate::mimeparser::{parse_message_id, SystemMessage}; use crate::param::{Param, Params}; use crate::pgp::split_armored_data; @@ -1571,17 +1572,6 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> { Ok(()) } -async fn delete_poi_location(context: &Context, location_id: u32) -> Result<()> { - context - .sql - .execute( - "DELETE FROM locations WHERE independent = 1 AND id=?;", - (location_id as i32,), - ) - .await?; - Ok(()) -} - /// Marks requested messages as seen. pub async fn markseen_msgs(context: &Context, msg_ids: Vec) -> Result<()> { if msg_ids.is_empty() {