mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 12:56:30 +03:00
refactor: remove MessageObject::from_message_id()
It accepted u32, not Message-ID. There is a properly typed from_msg_id function that accepts MsgId next to it.
This commit is contained in:
@@ -1099,7 +1099,7 @@ impl CommandApi {
|
|||||||
|
|
||||||
async fn get_message(&self, account_id: u32, message_id: u32) -> Result<MessageObject> {
|
async fn get_message(&self, account_id: u32, message_id: u32) -> Result<MessageObject> {
|
||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
MessageObject::from_message_id(&ctx, message_id).await
|
MessageObject::from_msg_id(&ctx, MsgId::new(message_id)).await
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_message_html(&self, account_id: u32, message_id: u32) -> Result<Option<String>> {
|
async fn get_message_html(&self, account_id: u32, message_id: u32) -> Result<Option<String>> {
|
||||||
@@ -1119,7 +1119,7 @@ impl CommandApi {
|
|||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
let mut messages: HashMap<u32, MessageLoadResult> = HashMap::new();
|
let mut messages: HashMap<u32, MessageLoadResult> = HashMap::new();
|
||||||
for message_id in message_ids {
|
for message_id in message_ids {
|
||||||
let message_result = MessageObject::from_message_id(&ctx, message_id).await;
|
let message_result = MessageObject::from_msg_id(&ctx, MsgId::new(message_id)).await;
|
||||||
messages.insert(
|
messages.insert(
|
||||||
message_id,
|
message_id,
|
||||||
match message_result {
|
match message_result {
|
||||||
@@ -2042,11 +2042,9 @@ impl CommandApi {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
let msg_id = chat::send_msg(&ctx, ChatId::new(chat_id), &mut message)
|
let msg_id = chat::send_msg(&ctx, ChatId::new(chat_id), &mut message).await?;
|
||||||
.await?
|
let message = MessageObject::from_msg_id(&ctx, msg_id).await?;
|
||||||
.to_u32();
|
Ok((msg_id.to_u32(), message))
|
||||||
let message = MessageObject::from_message_id(&ctx, msg_id).await?;
|
|
||||||
Ok((msg_id, message))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mimics the old desktop call, will get replaced with something better in the composer rewrite,
|
// mimics the old desktop call, will get replaced with something better in the composer rewrite,
|
||||||
|
|||||||
@@ -105,11 +105,6 @@ enum MessageQuote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MessageObject {
|
impl MessageObject {
|
||||||
pub async fn from_message_id(context: &Context, message_id: u32) -> Result<Self> {
|
|
||||||
let msg_id = MsgId::new(message_id);
|
|
||||||
Self::from_msg_id(context, msg_id).await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn from_msg_id(context: &Context, msg_id: MsgId) -> Result<Self> {
|
pub async fn from_msg_id(context: &Context, msg_id: MsgId) -> Result<Self> {
|
||||||
let message = Message::load_from_db(context, msg_id).await?;
|
let message = Message::load_from_db(context, msg_id).await?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user