From 347938a9f991c44f304f20e562c460ed66ef13a4 Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Tue, 21 Oct 2025 13:49:16 +0200 Subject: [PATCH] refactor: jsonrpc rename change casing in names of jsonrpc structs/enums to comply with rust naming conventions. (#7324) --- deltachat-jsonrpc/src/api.rs | 14 +++++++------- deltachat-jsonrpc/src/api/types/chat.rs | 10 +++++----- deltachat-jsonrpc/src/api/types/message.rs | 12 ++++++------ deltachat-jsonrpc/src/api/types/reactions.rs | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/deltachat-jsonrpc/src/api.rs b/deltachat-jsonrpc/src/api.rs index 8b9fb648c..595f6e989 100644 --- a/deltachat-jsonrpc/src/api.rs +++ b/deltachat-jsonrpc/src/api.rs @@ -54,15 +54,15 @@ use types::events::Event; use types::http::HttpResponse; use types::message::{MessageData, MessageObject, MessageReadReceipt}; use types::provider_info::ProviderInfo; -use types::reactions::JSONRPCReactions; +use types::reactions::JsonrpcReactions; use types::webxdc::WebxdcMessageInfo; use self::types::message::{MessageInfo, MessageLoadResult}; use self::types::{ - chat::{BasicChat, JSONRPCChatVisibility, MuteDuration}, + chat::{BasicChat, JsonrpcChatVisibility, MuteDuration}, location::JsonrpcLocation, message::{ - JSONRPCMessageListItem, MessageNotificationInfo, MessageSearchResult, MessageViewtype, + JsonrpcMessageListItem, MessageNotificationInfo, MessageSearchResult, MessageViewtype, }, }; use crate::api::types::chat_list::{get_chat_list_item_by_id, ChatListItemFetchResult}; @@ -1049,7 +1049,7 @@ impl CommandApi { &self, account_id: u32, chat_id: u32, - visibility: JSONRPCChatVisibility, + visibility: JsonrpcChatVisibility, ) -> Result<()> { let ctx = self.get_context(account_id).await?; @@ -1254,7 +1254,7 @@ impl CommandApi { chat_id: u32, info_only: bool, add_daymarker: bool, - ) -> Result> { + ) -> Result> { let ctx = self.get_context(account_id).await?; let msg = get_chat_msgs_ex( &ctx, @@ -1268,7 +1268,7 @@ impl CommandApi { Ok(msg .iter() .map(|chat_item| (*chat_item).into()) - .collect::>()) + .collect::>()) } async fn get_message(&self, account_id: u32, msg_id: u32) -> Result { @@ -2189,7 +2189,7 @@ impl CommandApi { &self, account_id: u32, message_id: u32, - ) -> Result> { + ) -> Result> { let ctx = self.get_context(account_id).await?; let reactions = get_msg_reactions(&ctx, MsgId::new(message_id)).await?; if reactions.is_empty() { diff --git a/deltachat-jsonrpc/src/api/types/chat.rs b/deltachat-jsonrpc/src/api/types/chat.rs index 6b5e69304..b82b7df29 100644 --- a/deltachat-jsonrpc/src/api/types/chat.rs +++ b/deltachat-jsonrpc/src/api/types/chat.rs @@ -252,18 +252,18 @@ impl MuteDuration { #[derive(Clone, Serialize, Deserialize, TypeDef, schemars::JsonSchema)] #[serde(rename = "ChatVisibility")] -pub enum JSONRPCChatVisibility { +pub enum JsonrpcChatVisibility { Normal, Archived, Pinned, } -impl JSONRPCChatVisibility { +impl JsonrpcChatVisibility { pub fn into_core_type(self) -> ChatVisibility { match self { - JSONRPCChatVisibility::Normal => ChatVisibility::Normal, - JSONRPCChatVisibility::Archived => ChatVisibility::Archived, - JSONRPCChatVisibility::Pinned => ChatVisibility::Pinned, + JsonrpcChatVisibility::Normal => ChatVisibility::Normal, + JsonrpcChatVisibility::Archived => ChatVisibility::Archived, + JsonrpcChatVisibility::Pinned => ChatVisibility::Pinned, } } } diff --git a/deltachat-jsonrpc/src/api/types/message.rs b/deltachat-jsonrpc/src/api/types/message.rs index b2832db94..dd5a2023f 100644 --- a/deltachat-jsonrpc/src/api/types/message.rs +++ b/deltachat-jsonrpc/src/api/types/message.rs @@ -18,7 +18,7 @@ use typescript_type_def::TypeDef; use super::color_int_to_hex_string; use super::contact::ContactObject; -use super::reactions::JSONRPCReactions; +use super::reactions::JsonrpcReactions; #[derive(Serialize, TypeDef, schemars::JsonSchema)] #[serde(rename_all = "camelCase", tag = "kind")] @@ -102,7 +102,7 @@ pub struct MessageObject { saved_message_id: Option, - reactions: Option, + reactions: Option, vcard_contact: Option, } @@ -581,7 +581,7 @@ impl MessageSearchResult { #[derive(Serialize, TypeDef, schemars::JsonSchema)] #[serde(rename_all = "camelCase", rename = "MessageListItem", tag = "kind")] -pub enum JSONRPCMessageListItem { +pub enum JsonrpcMessageListItem { Message { msg_id: u32, }, @@ -594,13 +594,13 @@ pub enum JSONRPCMessageListItem { }, } -impl From for JSONRPCMessageListItem { +impl From for JsonrpcMessageListItem { fn from(item: ChatItem) -> Self { match item { - ChatItem::Message { msg_id } => JSONRPCMessageListItem::Message { + ChatItem::Message { msg_id } => JsonrpcMessageListItem::Message { msg_id: msg_id.to_u32(), }, - ChatItem::DayMarker { timestamp } => JSONRPCMessageListItem::DayMarker { timestamp }, + ChatItem::DayMarker { timestamp } => JsonrpcMessageListItem::DayMarker { timestamp }, } } } diff --git a/deltachat-jsonrpc/src/api/types/reactions.rs b/deltachat-jsonrpc/src/api/types/reactions.rs index 37739c848..a0916f811 100644 --- a/deltachat-jsonrpc/src/api/types/reactions.rs +++ b/deltachat-jsonrpc/src/api/types/reactions.rs @@ -8,7 +8,7 @@ use typescript_type_def::TypeDef; /// A single reaction emoji. #[derive(Serialize, TypeDef, schemars::JsonSchema)] #[serde(rename = "Reaction", rename_all = "camelCase")] -pub struct JSONRPCReaction { +pub struct JsonrpcReaction { /// Emoji. emoji: String, @@ -22,14 +22,14 @@ pub struct JSONRPCReaction { /// Structure representing all reactions to a particular message. #[derive(Serialize, TypeDef, schemars::JsonSchema)] #[serde(rename = "Reactions", rename_all = "camelCase")] -pub struct JSONRPCReactions { +pub struct JsonrpcReactions { /// Map from a contact to it's reaction to message. reactions_by_contact: BTreeMap>, /// Unique reactions and their count, sorted in descending order. - reactions: Vec, + reactions: Vec, } -impl From for JSONRPCReactions { +impl From for JsonrpcReactions { fn from(reactions: Reactions) -> Self { let mut reactions_by_contact: BTreeMap> = BTreeMap::new(); @@ -56,7 +56,7 @@ impl From for JSONRPCReactions { false }; - let reaction = JSONRPCReaction { + let reaction = JsonrpcReaction { emoji, count, is_from_self, @@ -64,7 +64,7 @@ impl From for JSONRPCReactions { reactions_v.push(reaction) } - JSONRPCReactions { + JsonrpcReactions { reactions_by_contact, reactions: reactions_v, }