mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 15:36:30 +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::html::new_html_mimepart;
|
||||
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::param::{Param, Params};
|
||||
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);
|
||||
if let Some(forwards) = forwards {
|
||||
for forward in forwards.split(' ') {
|
||||
if let Ok(msg_id) = forward
|
||||
.parse::<u32>()
|
||||
.map_err(|_| InvalidMsgId)
|
||||
.map(MsgId::new)
|
||||
{
|
||||
if let Ok(msg_id) = forward.parse::<u32>().map(MsgId::new) {
|
||||
if let Ok(mut msg) = Message::load_from_db(context, msg_id).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 {
|
||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
||||
if self.0 <= DC_MSG_ID_LAST_SPECIAL {
|
||||
return Err(rusqlite::Error::ToSqlConversionFailure(Box::new(
|
||||
InvalidMsgId,
|
||||
)));
|
||||
return Err(rusqlite::Error::ToSqlConversionFailure(
|
||||
format_err!("Invalid MsgId").into(),
|
||||
));
|
||||
}
|
||||
let val = rusqlite::types::Value::Integer(self.0 as i64);
|
||||
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(
|
||||
Debug,
|
||||
Copy,
|
||||
|
||||
Reference in New Issue
Block a user