MCPcopy Create free account
hub / github.com/chatmail/core / get_existing_msg_ids

Function get_existing_msg_ids

src/message.rs:1940–1962  ·  view source on GitHub ↗

Checks if the messages with given IDs exist. Returns IDs of existing messages.

(context: &Context, ids: &[MsgId])

Source from the content-addressed store, hash-verified

1938///
1939/// Returns IDs of existing messages.
1940pub async fn get_existing_msg_ids(context: &Context, ids: &[MsgId]) -> Result<Vec<MsgId>> {
1941 let query_only = true;
1942 let res = context
1943 .sql
1944 .transaction_ex(query_only, |transaction| {
1945 let mut res: Vec<MsgId> = Vec::new();
1946 for id in ids {
1947 if transaction.query_one(
1948 "SELECT COUNT(*) > 0 FROM msgs WHERE id=? AND chat_id!=3",
1949 (id,),
1950 |row| {
1951 let exists: bool = row.get(0)?;
1952 Ok(exists)
1953 },
1954 )? {
1955 res.push(*id);
1956 }
1957 }
1958 Ok(res)
1959 })
1960 .await?;
1961 Ok(res)
1962}
1963
1964pub(crate) async fn update_msg_state(
1965 context: &Context,

Callers 1

get_existing_msg_idsMethod · 0.85

Calls 2

transaction_exMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected