jsonrpc: use camel-case for Event struct and move events.rs to types folder (#4372)

* use camel-case for Event struct and move events.rs to types folder

---------

Co-authored-by: link2xt <link2xt@testrun.org>
This commit is contained in:
Asiel Díaz Benítez
2023-05-08 12:49:19 +02:00
committed by GitHub
parent 3efbe5b1ef
commit 5c3df7e452
6 changed files with 9 additions and 9 deletions

View File

@@ -35,13 +35,13 @@ use tokio::sync::{watch, Mutex, RwLock};
use walkdir::WalkDir;
use yerpc::rpc;
pub mod events;
pub mod types;
use num_traits::FromPrimitive;
use types::account::Account;
use types::chat::FullChat;
use types::contact::ContactObject;
use types::events::Event;
use types::http::HttpResponse;
use types::message::MessageData;
use types::message::MessageObject;
@@ -49,7 +49,6 @@ use types::provider_info::ProviderInfo;
use types::reactions::JSONRPCReactions;
use types::webxdc::WebxdcMessageInfo;
use self::events::Event;
use self::types::message::MessageLoadResult;
use self::types::{
chat::{BasicChat, JSONRPCChatVisibility, MuteDuration},

View File

@@ -3,6 +3,7 @@ use serde::Serialize;
use typescript_type_def::TypeDef;
#[derive(Serialize, TypeDef)]
#[serde(rename_all = "camelCase")]
pub struct Event {
/// Event payload.
event: EventType,

View File

@@ -2,6 +2,7 @@ pub mod account;
pub mod chat;
pub mod chat_list;
pub mod contact;
pub mod events;
pub mod http;
pub mod location;
pub mod message;

View File

@@ -1,5 +1,4 @@
pub mod api;
pub use api::events;
pub use yerpc;
#[cfg(test)]

View File

@@ -50,16 +50,16 @@ export class BaseDeltaChat<
async eventLoop(): Promise<void> {
while (true) {
const event = await this.rpc.getNextEvent();
this.emit(event.event.type, event.context_id, event.event as any);
this.emit("ALL", event.context_id, event.event as any);
this.emit(event.event.type, event.contextId, event.event as any);
this.emit("ALL", event.contextId, event.event as any);
if (this.contextEmitters[event.context_id]) {
this.contextEmitters[event.context_id].emit(
if (this.contextEmitters[event.contextId]) {
this.contextEmitters[event.contextId].emit(
event.event.type,
//@ts-ignore
event.event as any
);
this.contextEmitters[event.context_id].emit("ALL", event.event as any);
this.contextEmitters[event.contextId].emit("ALL", event.event as any);
}
}
}

View File

@@ -79,7 +79,7 @@ class Rpc:
if self.closing:
return
event = await self.get_next_event()
account_id = event["context_id"]
account_id = event["contextId"]
queue = await self.get_queue(account_id)
await queue.put(event["event"])