diff --git a/deltachat-ffi/deltachat.h b/deltachat-ffi/deltachat.h index 6e8dedf85..30b236fba 100644 --- a/deltachat-ffi/deltachat.h +++ b/deltachat-ffi/deltachat.h @@ -3165,24 +3165,6 @@ dc_lot_t* dc_chatlist_get_summary2 (dc_context_t* context, uint32_t ch dc_context_t* dc_chatlist_get_context (dc_chatlist_t* chatlist); -/** - * Get info summary for a chat, in JSON format. - * - * The returned JSON string has the following key/values: - * - * id: chat id - * name: chat/group name - * color: color of this chat - * last-message-from: who sent the last message - * last-message-text: message (truncated) - * last-message-state: @ref DC_STATE constant - * last-message-date: - * avatar-path: path-to-blobfile - * is_verified: yes/no - * @return a UTF8-encoded JSON string containing all requested info. Must be freed using dc_str_unref(). NULL is never returned. - */ -char* dc_chat_get_info_json (dc_context_t* context, size_t chat_id); - /** * @class dc_chat_t * diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index d355aab98..af7d61a15 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2943,41 +2943,6 @@ pub unsafe extern "C" fn dc_chat_get_remaining_mute_duration(chat: *mut dc_chat_ } } -#[no_mangle] -pub unsafe extern "C" fn dc_chat_get_info_json( - context: *mut dc_context_t, - chat_id: u32, -) -> *mut libc::c_char { - if context.is_null() { - eprintln!("ignoring careless call to dc_chat_get_info_json()"); - return "".strdup(); - } - let ctx = &*context; - - block_on(async move { - let chat = match chat::Chat::load_from_db(ctx, ChatId::new(chat_id)).await { - Ok(chat) => chat, - Err(err) => { - error!(ctx, "dc_get_chat_info_json() failed to load chat: {}", err); - return "".strdup(); - } - }; - let info = match chat.get_info(ctx).await { - Ok(info) => info, - Err(err) => { - error!( - ctx, - "dc_get_chat_info_json() failed to get chat info: {}", err - ); - return "".strdup(); - } - }; - serde_json::to_string(&info) - .unwrap_or_log_default(ctx, "dc_get_chat_info_json() failed to serialise to json") - .strdup() - }) -} - // dc_msg_t /// FFI struct for [dc_msg_t] diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index d546d4775..0a6711a44 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -171,12 +171,6 @@ class Chat(object): """ return lib.dc_chat_get_color(self._dc_chat) - def get_summary(self): - """return dictionary with summary information.""" - dc_res = lib.dc_chat_get_info_json(self.account._dc_context, self.id) - s = from_dc_charpointer(dc_res) - return json.loads(s) - def mute(self, duration: Optional[int] = None) -> None: """mutes the chat diff --git a/src/chat.rs b/src/chat.rs index 10317a71b..4a2f063eb 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -1172,35 +1172,6 @@ impl Chat { Ok(color) } - /// Returns a struct describing the current state of the chat. - /// - /// This is somewhat experimental, even more so than the rest of - /// deltachat, and the data returned is still subject to change. - pub async fn get_info(&self, context: &Context) -> Result { - let draft = match self.id.get_draft(context).await? { - Some(message) => message.text.unwrap_or_default(), - _ => String::new(), - }; - Ok(ChatInfo { - id: self.id, - type_: self.typ as u32, - name: self.name.clone(), - archived: self.visibility == ChatVisibility::Archived, - param: self.param.to_string(), - gossiped_timestamp: self.id.get_gossiped_timestamp(context).await?, - is_sending_locations: self.is_sending_locations, - color: self.get_color(context).await?, - profile_image: self - .get_profile_image(context) - .await? - .map(Into::into) - .unwrap_or_else(std::path::PathBuf::new), - draft, - is_muted: self.is_muted(), - ephemeral_timer: self.id.get_ephemeral_timer(context).await?, - }) - } - pub fn get_visibility(&self) -> ChatVisibility { self.visibility } @@ -3469,37 +3440,6 @@ mod tests { use crate::receive_imf::receive_imf; use crate::test_utils::TestContext; - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] - async fn test_chat_info() { - let t = TestContext::new().await; - let chat = t.create_chat_with_contact("bob", "bob@example.com").await; - let info = chat.get_info(&t).await.unwrap(); - - // Ensure we can serialize this. - println!("{}", serde_json::to_string_pretty(&info).unwrap()); - - let expected = r#" - { - "id": 10, - "type": 100, - "name": "bob", - "archived": false, - "param": "", - "gossiped_timestamp": 0, - "is_sending_locations": false, - "color": 35391, - "profile_image": "", - "draft": "", - "is_muted": false, - "ephemeral_timer": "Disabled" - } - "#; - - // Ensure we can deserialize this. - let loaded: ChatInfo = serde_json::from_str(expected).unwrap(); - assert_eq!(info, loaded); - } - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_get_draft_no_draft() { let t = TestContext::new().await;