mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +03:00
Remove InvalidMsgId error type
This commit is contained in:
@@ -32,7 +32,7 @@ use crate::ephemeral::{delete_expired_messages, schedule_ephemeral_task, Timer a
|
|||||||
use crate::events::EventType;
|
use crate::events::EventType;
|
||||||
use crate::html::new_html_mimepart;
|
use crate::html::new_html_mimepart;
|
||||||
use crate::job::{self, Action};
|
use crate::job::{self, Action};
|
||||||
use crate::message::{self, InvalidMsgId, Message, MessageState, MsgId};
|
use crate::message::{self, Message, MessageState, MsgId};
|
||||||
use crate::mimeparser::SystemMessage;
|
use crate::mimeparser::SystemMessage;
|
||||||
use crate::param::{Param, Params};
|
use crate::param::{Param, Params};
|
||||||
use crate::peerstate::{Peerstate, PeerstateVerifiedStatus};
|
use crate::peerstate::{Peerstate, PeerstateVerifiedStatus};
|
||||||
@@ -1722,11 +1722,7 @@ pub async fn send_msg(context: &Context, chat_id: ChatId, msg: &mut Message) ->
|
|||||||
let forwards = msg.param.get(Param::PrepForwards);
|
let forwards = msg.param.get(Param::PrepForwards);
|
||||||
if let Some(forwards) = forwards {
|
if let Some(forwards) = forwards {
|
||||||
for forward in forwards.split(' ') {
|
for forward in forwards.split(' ') {
|
||||||
if let Ok(msg_id) = forward
|
if let Ok(msg_id) = forward.parse::<u32>().map(MsgId::new) {
|
||||||
.parse::<u32>()
|
|
||||||
.map_err(|_| InvalidMsgId)
|
|
||||||
.map(MsgId::new)
|
|
||||||
{
|
|
||||||
if let Ok(mut msg) = Message::load_from_db(context, msg_id).await {
|
if let Ok(mut msg) = Message::load_from_db(context, msg_id).await {
|
||||||
send_msg_inner(context, chat_id, &mut msg).await?;
|
send_msg_inner(context, chat_id, &mut msg).await?;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -236,9 +236,9 @@ impl std::fmt::Display for MsgId {
|
|||||||
impl rusqlite::types::ToSql for MsgId {
|
impl rusqlite::types::ToSql for MsgId {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
||||||
if self.0 <= DC_MSG_ID_LAST_SPECIAL {
|
if self.0 <= DC_MSG_ID_LAST_SPECIAL {
|
||||||
return Err(rusqlite::Error::ToSqlConversionFailure(Box::new(
|
return Err(rusqlite::Error::ToSqlConversionFailure(
|
||||||
InvalidMsgId,
|
format_err!("Invalid MsgId").into(),
|
||||||
)));
|
));
|
||||||
}
|
}
|
||||||
let val = rusqlite::types::Value::Integer(self.0 as i64);
|
let val = rusqlite::types::Value::Integer(self.0 as i64);
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
@@ -260,15 +260,6 @@ impl rusqlite::types::FromSql for MsgId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Message ID was invalid.
|
|
||||||
///
|
|
||||||
/// This usually occurs when trying to use a message ID of
|
|
||||||
/// [DC_MSG_ID_LAST_SPECIAL] or below in a situation where this is not
|
|
||||||
/// possible.
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
#[error("Invalid Message ID.")]
|
|
||||||
pub struct InvalidMsgId;
|
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Debug,
|
Debug,
|
||||||
Copy,
|
Copy,
|
||||||
|
|||||||
Reference in New Issue
Block a user