Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions deltachat-jsonrpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -1051,7 +1051,7 @@ impl CommandApi {
&self,
account_id: u32,
chat_id: u32,
visibility: JSONRPCChatVisibility,
visibility: JsonrpcChatVisibility,
) -> Result<()> {
let ctx = self.get_context(account_id).await?;

Expand Down Expand Up @@ -1256,7 +1256,7 @@ impl CommandApi {
chat_id: u32,
info_only: bool,
add_daymarker: bool,
) -> Result<Vec<JSONRPCMessageListItem>> {
) -> Result<Vec<JsonrpcMessageListItem>> {
let ctx = self.get_context(account_id).await?;
let msg = get_chat_msgs_ex(
&ctx,
Expand All @@ -1270,7 +1270,7 @@ impl CommandApi {
Ok(msg
.iter()
.map(|chat_item| (*chat_item).into())
.collect::<Vec<JSONRPCMessageListItem>>())
.collect::<Vec<JsonrpcMessageListItem>>())
}

async fn get_message(&self, account_id: u32, msg_id: u32) -> Result<MessageObject> {
Expand Down Expand Up @@ -2191,7 +2191,7 @@ impl CommandApi {
&self,
account_id: u32,
message_id: u32,
) -> Result<Option<JSONRPCReactions>> {
) -> Result<Option<JsonrpcReactions>> {
let ctx = self.get_context(account_id).await?;
let reactions = get_msg_reactions(&ctx, MsgId::new(message_id)).await?;
if reactions.is_empty() {
Expand Down
10 changes: 5 additions & 5 deletions deltachat-jsonrpc/src/api/types/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
12 changes: 6 additions & 6 deletions deltachat-jsonrpc/src/api/types/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -102,7 +102,7 @@ pub struct MessageObject {

saved_message_id: Option<u32>,

reactions: Option<JSONRPCReactions>,
reactions: Option<JsonrpcReactions>,

vcard_contact: Option<VcardContact>,
}
Expand Down Expand Up @@ -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,
},
Expand All @@ -594,13 +594,13 @@ pub enum JSONRPCMessageListItem {
},
}

impl From<ChatItem> for JSONRPCMessageListItem {
impl From<ChatItem> 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 },
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions deltachat-jsonrpc/src/api/types/reactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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<u32, Vec<String>>,
/// Unique reactions and their count, sorted in descending order.
reactions: Vec<JSONRPCReaction>,
reactions: Vec<JsonrpcReaction>,
}

impl From<Reactions> for JSONRPCReactions {
impl From<Reactions> for JsonrpcReactions {
fn from(reactions: Reactions) -> Self {
let mut reactions_by_contact: BTreeMap<u32, Vec<String>> = BTreeMap::new();

Expand All @@ -56,15 +56,15 @@ impl From<Reactions> for JSONRPCReactions {
false
};

let reaction = JSONRPCReaction {
let reaction = JsonrpcReaction {
emoji,
count,
is_from_self,
};
reactions_v.push(reaction)
}

JSONRPCReactions {
JsonrpcReactions {
reactions_by_contact,
reactions: reactions_v,
}
Expand Down