mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
jsonrpc: MessageSearchResult, always include chat_name(not an option anymore), also add author_id and chat_type (#4374)
* jsonrpc: `MessageSearchResult`, always include `chat_name`(not an option anymore), also add `author_id` and `chat_type` * replace .ok_or_else with anyhow context
This commit is contained in:
@@ -10,13 +10,19 @@
|
|||||||
- `get_chatlist_items_by_entries` now takes only chatids instead of `ChatListEntries`
|
- `get_chatlist_items_by_entries` now takes only chatids instead of `ChatListEntries`
|
||||||
- `get_chatlist_entries` now returns `Vec<u32>` of chatids instead of `ChatListEntries`
|
- `get_chatlist_entries` now returns `Vec<u32>` of chatids instead of `ChatListEntries`
|
||||||
- `Event`: `context_id` property is now called `contextId`
|
- `Event`: `context_id` property is now called `contextId`
|
||||||
|
- jsonrpc: expand `MessageSearchResult`:
|
||||||
|
- always include `chat_name`(not an option anymore)
|
||||||
|
- add `author_id`, `chat_type`, `chat_color`, `is_chat_protected`, `is_chat_contact_request`, `is_chat_archived`
|
||||||
|
- `author_name` now contains the overridden sender name.
|
||||||
- JSON-RPC: add API to get reactions outside the message snapshot
|
- JSON-RPC: add API to get reactions outside the message snapshot
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Make the bots automatically accept group chat contact requests. #4377
|
- Make the bots automatically accept group chat contact requests. #4377
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- jsonrpc: typescript client: fix types of events in event emitter
|
- jsonrpc: typescript client: fix types of events in event emitter
|
||||||
|
|
||||||
|
|
||||||
## [1.114.0] - 2023-04-24
|
## [1.114.0] - 2023-04-24
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Context as _, Result};
|
use anyhow::{bail, Context as _, Result};
|
||||||
use deltachat::chat::{self, get_chat_contacts, ChatVisibility};
|
use deltachat::chat::{self, get_chat_contacts, ChatVisibility};
|
||||||
use deltachat::chat::{Chat, ChatId};
|
use deltachat::chat::{Chat, ChatId};
|
||||||
use deltachat::constants::Chattype;
|
use deltachat::constants::Chattype;
|
||||||
@@ -92,10 +92,7 @@ impl FullChat {
|
|||||||
is_protected: chat.is_protected(),
|
is_protected: chat.is_protected(),
|
||||||
profile_image, //BLOBS ?
|
profile_image, //BLOBS ?
|
||||||
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
|
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
|
||||||
chat_type: chat
|
chat_type: chat.get_type().to_u32().context("unknown chat type id")?,
|
||||||
.get_type()
|
|
||||||
.to_u32()
|
|
||||||
.ok_or_else(|| anyhow!("unknown chat type id"))?, // TODO get rid of this unwrap?
|
|
||||||
is_unpromoted: chat.is_unpromoted(),
|
is_unpromoted: chat.is_unpromoted(),
|
||||||
is_self_talk: chat.is_self_talk(),
|
is_self_talk: chat.is_self_talk(),
|
||||||
contacts,
|
contacts,
|
||||||
@@ -158,10 +155,7 @@ impl BasicChat {
|
|||||||
is_protected: chat.is_protected(),
|
is_protected: chat.is_protected(),
|
||||||
profile_image, //BLOBS ?
|
profile_image, //BLOBS ?
|
||||||
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
|
archived: chat.get_visibility() == chat::ChatVisibility::Archived,
|
||||||
chat_type: chat
|
chat_type: chat.get_type().to_u32().context("unknown chat type id")?,
|
||||||
.get_type()
|
|
||||||
.to_u32()
|
|
||||||
.ok_or_else(|| anyhow!("unknown chat type id"))?, // TODO get rid of this unwrap?
|
|
||||||
is_unpromoted: chat.is_unpromoted(),
|
is_unpromoted: chat.is_unpromoted(),
|
||||||
is_self_talk: chat.is_self_talk(),
|
is_self_talk: chat.is_self_talk(),
|
||||||
color,
|
color,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Context as _, Result};
|
||||||
use deltachat::chat::Chat;
|
use deltachat::chat::Chat;
|
||||||
use deltachat::chat::ChatItem;
|
use deltachat::chat::ChatItem;
|
||||||
use deltachat::constants::Chattype;
|
use deltachat::chat::ChatVisibility;
|
||||||
use deltachat::contact::Contact;
|
use deltachat::contact::Contact;
|
||||||
use deltachat::context::Context;
|
use deltachat::context::Context;
|
||||||
use deltachat::download;
|
use deltachat::download;
|
||||||
@@ -443,9 +443,17 @@ impl MessageNotificationInfo {
|
|||||||
pub struct MessageSearchResult {
|
pub struct MessageSearchResult {
|
||||||
id: u32,
|
id: u32,
|
||||||
author_profile_image: Option<String>,
|
author_profile_image: Option<String>,
|
||||||
|
/// if sender name if overridden it will show it as ~alias
|
||||||
author_name: String,
|
author_name: String,
|
||||||
author_color: String,
|
author_color: String,
|
||||||
chat_name: Option<String>,
|
author_id: u32,
|
||||||
|
chat_profile_image: Option<String>,
|
||||||
|
chat_color: String,
|
||||||
|
chat_name: String,
|
||||||
|
chat_type: u32,
|
||||||
|
is_chat_protected: bool,
|
||||||
|
is_chat_contact_request: bool,
|
||||||
|
is_chat_archived: bool,
|
||||||
message: String,
|
message: String,
|
||||||
timestamp: i64,
|
timestamp: i64,
|
||||||
}
|
}
|
||||||
@@ -460,17 +468,31 @@ impl MessageSearchResult {
|
|||||||
Some(path_buf) => path_buf.to_str().map(|s| s.to_owned()),
|
Some(path_buf) => path_buf.to_str().map(|s| s.to_owned()),
|
||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
let chat_profile_image = match chat.get_profile_image(context).await? {
|
||||||
|
Some(path_buf) => path_buf.to_str().map(|s| s.to_owned()),
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let author_name = if let Some(name) = message.get_override_sender_name() {
|
||||||
|
format!("~{name}")
|
||||||
|
} else {
|
||||||
|
sender.get_display_name().to_owned()
|
||||||
|
};
|
||||||
|
let chat_color = color_int_to_hex_string(chat.get_color(context).await?);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
id: msg_id.to_u32(),
|
id: msg_id.to_u32(),
|
||||||
author_profile_image: profile_image,
|
author_profile_image: profile_image,
|
||||||
author_name: sender.get_display_name().to_owned(),
|
author_name,
|
||||||
author_color: color_int_to_hex_string(sender.get_color()),
|
author_color: color_int_to_hex_string(sender.get_color()),
|
||||||
chat_name: if chat.get_type() == Chattype::Single {
|
author_id: sender.id.to_u32(),
|
||||||
Some(chat.get_name().to_owned())
|
chat_name: chat.get_name().to_owned(),
|
||||||
} else {
|
chat_color,
|
||||||
None
|
chat_type: chat.get_type().to_u32().context("unknown chat type id")?,
|
||||||
},
|
chat_profile_image,
|
||||||
|
is_chat_protected: chat.is_protected(),
|
||||||
|
is_chat_contact_request: chat.is_contact_request(),
|
||||||
|
is_chat_archived: chat.get_visibility() == ChatVisibility::Archived,
|
||||||
message: message.get_text().unwrap_or_default(),
|
message: message.get_text().unwrap_or_default(),
|
||||||
timestamp: message.get_timestamp(),
|
timestamp: message.get_timestamp(),
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user