From b913c141d2f135c23c8c8a312188902a5f4e9ac7 Mon Sep 17 00:00:00 2001 From: flipsimon <28535045+flipsimon@users.noreply.github.com> Date: Fri, 29 Jul 2022 13:19:45 +0200 Subject: [PATCH] Fixed clippy errors and formatting --- deltachat-jsonrpc/src/api/mod.rs | 1 - deltachat-jsonrpc/src/api/types/mod.rs | 10 +- .../typescript/generated/types.ts | 479 ++++++++++++++---- 3 files changed, 385 insertions(+), 105 deletions(-) diff --git a/deltachat-jsonrpc/src/api/mod.rs b/deltachat-jsonrpc/src/api/mod.rs index 5e28dbe17..20bc39bb7 100644 --- a/deltachat-jsonrpc/src/api/mod.rs +++ b/deltachat-jsonrpc/src/api/mod.rs @@ -204,7 +204,6 @@ impl CommandApi { } async fn check_qr(&self, account_id: u32, qr_content: String) -> Result { - println!("HELLO FROM CHECK_QR"); let ctx = self.get_context(account_id).await?; let qr = qr::check_qr(&ctx, &qr_content).await?; let qr_object = QrObject::from(qr); diff --git a/deltachat-jsonrpc/src/api/types/mod.rs b/deltachat-jsonrpc/src/api/types/mod.rs index ff1abb566..59440de83 100644 --- a/deltachat-jsonrpc/src/api/types/mod.rs +++ b/deltachat-jsonrpc/src/api/types/mod.rs @@ -137,16 +137,10 @@ impl From for QrObject { QrObject::FprOk { contact_id } } Qr::FprMismatch { contact_id } => { - let contact_id = match contact_id { - Some(contact_id) => Some(contact_id.to_u32()), - None => None, - }; + let contact_id = contact_id.map(|contact_id| contact_id.to_u32()); QrObject::FprMismatch { contact_id } } - Qr::FprWithoutAddr { fingerprint } => { - let fingerprint = fingerprint.to_string(); - QrObject::FprWithoutAddr { fingerprint } - } + Qr::FprWithoutAddr { fingerprint } => QrObject::FprWithoutAddr { fingerprint }, Qr::Account { domain } => QrObject::Account { domain }, Qr::WebrtcInstance { domain, diff --git a/deltachat-jsonrpc/typescript/generated/types.ts b/deltachat-jsonrpc/typescript/generated/types.ts index f3d32ee0a..076541d45 100644 --- a/deltachat-jsonrpc/typescript/generated/types.ts +++ b/deltachat-jsonrpc/typescript/generated/types.ts @@ -1,98 +1,385 @@ // AUTO-GENERATED by typescript-type-def -export type U32=number; -export type Account=(({"type":"Configured";}&{"id":U32;"displayName":(string|null);"addr":(string|null);"profileImage":(string|null);"color":string;})|({"type":"Unconfigured";}&{"id":U32;})); -export type ProviderInfo={"beforeLoginHint":string;"overviewPage":string;"status":U32;}; -export type Qr=(({"type":"askVerifyContact";}&{"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})|({"type":"askVerifyGroup";}&{"grpname":string;"grpid":string;"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})|({"type":"fprOk";}&{"contact_id":U32;})|({"type":"fprMismatch";}&{"contact_id":(U32|null);})|({"type":"fprWithoutAddr";}&{"fingerprint":string;})|({"type":"account";}&{"domain":string;})|({"type":"webrtcInstance";}&{"domain":string;"instance_pattern":string;})|({"type":"addr";}&{"contact_id":U32;})|({"type":"url";}&{"url":string;})|({"type":"text";}&{"text":string;})|({"type":"withdrawVerifyContact";}&{"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})|({"type":"withdrawVerifyGroup";}&{"grpname":string;"grpid":string;"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})|({"type":"reviveVerifyContact";}&{"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})|({"type":"reviveVerifyGroup";}&{"grpname":string;"grpid":string;"contact_id":U32;"fingerprint":string;"invitenumber":string;"authcode":string;})); -export type Usize=number; -export type ChatListEntry=[U32,U32]; -export type I64=number; -export type ChatListItemFetchResult=(({"type":"ChatListItem";}&{"id":U32;"name":string;"avatarPath":(string|null);"color":string;"lastUpdated":(I64|null);"summaryText1":string;"summaryText2":string;"summaryStatus":U32;"isProtected":boolean;"isGroup":boolean;"freshMessageCounter":Usize;"isSelfTalk":boolean;"isDeviceTalk":boolean;"isSendingLocation":boolean;"isSelfInGroup":boolean;"isArchived":boolean;"isPinned":boolean;"isMuted":boolean;"isContactRequest":boolean; -/** - * contact id if this is a dm chat (for view profile entry in context menu) - */ -"dmChatContact":(U32|null);})|{"type":"ArchiveLink";}|({"type":"Error";}&{"id":U32;"error":string;})); -export type Contact={"address":string;"color":string;"authName":string;"status":string;"displayName":string;"id":U32;"name":string;"profileImage":(string|null);"nameAndAddr":string;"isBlocked":boolean;"isVerified":boolean;}; -export type FullChat={"id":U32;"name":string;"isProtected":boolean;"profileImage":(string|null);"archived":boolean;"chatType":U32;"isUnpromoted":boolean;"isSelfTalk":boolean;"contacts":(Contact)[];"contactIds":(U32)[];"color":string;"freshMessageCounter":Usize;"isContactRequest":boolean;"isDeviceChat":boolean;"selfInGroup":boolean;"isMuted":boolean;"ephemeralTimer":U32;"canSend":boolean;}; -export type Viewtype=("Unknown"| -/** - * Text message. - */ -"Text"| -/** - * Image message. - * If the image is an animated GIF, the type `Viewtype.Gif` should be used. - */ -"Image"| -/** - * Animated GIF message. - */ -"Gif"| -/** - * Message containing a sticker, similar to image. - * If possible, the ui should display the image without borders in a transparent way. - * A click on a sticker will offer to install the sticker set in some future. - */ -"Sticker"| -/** - * Message containing an Audio file. - */ -"Audio"| -/** - * A voice message that was directly recorded by the user. - * For all other audio messages, the type `Viewtype.Audio` should be used. - */ -"Voice"| -/** - * Video messages. - */ -"Video"| -/** - * Message containing any file, eg. a PDF. - */ -"File"| -/** - * Message is an invitation to a videochat. - */ -"VideochatInvitation"| -/** - * Message is an webxdc instance. - */ -"Webxdc"); -export type I32=number; -export type U64=number; -export type Message={"id":U32;"chatId":U32;"fromId":U32;"quotedText":(string|null);"quotedMessageId":(U32|null);"text":(string|null);"hasLocation":boolean;"hasHtml":boolean;"viewType":Viewtype;"state":U32;"timestamp":I64;"sortTimestamp":I64;"receivedTimestamp":I64;"hasDeviatingTimestamp":boolean;"subject":string;"showPadlock":boolean;"isSetupmessage":boolean;"isInfo":boolean;"isForwarded":boolean;"duration":I32;"dimensionsHeight":I32;"dimensionsWidth":I32;"videochatType":(U32|null);"videochatUrl":(string|null);"overrideSenderName":(string|null);"sender":Contact;"setupCodeBegin":(string|null);"file":(string|null);"fileMime":(string|null);"fileBytes":U64;"fileName":(string|null);}; -export type WebxdcMessageInfo={ -/** - * The name of the app. - * - * Defaults to the filename if not set in the manifest. - */ -"name":string; -/** - * App icon file name. - * Defaults to an standard icon if nothing is set in the manifest. - * - * To get the file, use dc_msg_get_webxdc_blob(). (not yet in jsonrpc, use rust api or cffi for it) - * - * App icons should should be square, - * the implementations will add round corners etc. as needed. - */ -"icon":string; -/** - * if the Webxdc represents a document, then this is the name of the document - */ -"document":(string|null); -/** - * short string describing the state of the app, - * sth. as "2 votes", "Highscore: 123", - * can be changed by the apps - */ -"summary":(string|null); -/** - * URL where the source code of the Webxdc and other information can be found; - * defaults to an empty string. - * Implementations may offer an menu or a button to open this URL. - */ -"sourceCodeUrl":(string|null);}; -export type __AllTyps=[string,boolean,Record,U32,U32,null,(U32)[],U32,null,(U32|null),(Account)[],U32,Account,U32,string,(ProviderInfo|null),U32,boolean,U32,Record,U32,string,(string|null),null,U32,Record,null,U32,string,null,U32,string,Qr,U32,string,(string|null),U32,(string)[],Record,U32,null,U32,null,U32,(U32)[],U32,U32,Usize,U32,string,U32,U32,string,null,U32,(U32|null),(string|null),(U32|null),(ChatListEntry)[],U32,(ChatListEntry)[],Record,U32,U32,FullChat,U32,U32,null,U32,U32,null,U32,string,string,U32,U32,U32,U32,(U32)[],U32,U32,Message,U32,(U32)[],Record,U32,U32,Contact,U32,string,(string|null),U32,U32,U32,U32,U32,U32,null,U32,U32,null,U32,(Contact)[],U32,U32,(string|null),(U32)[],U32,U32,(string|null),(Contact)[],U32,(U32)[],Record,U32,U32,Viewtype,(Viewtype|null),(Viewtype|null),(U32)[],U32,U32,string,string,null,U32,U32,U32,string,U32,U32,WebxdcMessageInfo,U32,string,U32,U32]; +export type U32 = number; +export type Account = + | ({ type: "Configured" } & { + id: U32; + displayName: string | null; + addr: string | null; + profileImage: string | null; + color: string; + }) + | ({ type: "Unconfigured" } & { id: U32 }); +export type ProviderInfo = { + beforeLoginHint: string; + overviewPage: string; + status: U32; +}; +export type Qr = + | ({ type: "askVerifyContact" } & { + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }) + | ({ type: "askVerifyGroup" } & { + grpname: string; + grpid: string; + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }) + | ({ type: "fprOk" } & { contact_id: U32 }) + | ({ type: "fprMismatch" } & { contact_id: U32 | null }) + | ({ type: "fprWithoutAddr" } & { fingerprint: string }) + | ({ type: "account" } & { domain: string }) + | ({ type: "webrtcInstance" } & { domain: string; instance_pattern: string }) + | ({ type: "addr" } & { contact_id: U32 }) + | ({ type: "url" } & { url: string }) + | ({ type: "text" } & { text: string }) + | ({ type: "withdrawVerifyContact" } & { + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }) + | ({ type: "withdrawVerifyGroup" } & { + grpname: string; + grpid: string; + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }) + | ({ type: "reviveVerifyContact" } & { + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }) + | ({ type: "reviveVerifyGroup" } & { + grpname: string; + grpid: string; + contact_id: U32; + fingerprint: string; + invitenumber: string; + authcode: string; + }); +export type Usize = number; +export type ChatListEntry = [U32, U32]; +export type I64 = number; +export type ChatListItemFetchResult = + | ({ type: "ChatListItem" } & { + id: U32; + name: string; + avatarPath: string | null; + color: string; + lastUpdated: I64 | null; + summaryText1: string; + summaryText2: string; + summaryStatus: U32; + isProtected: boolean; + isGroup: boolean; + freshMessageCounter: Usize; + isSelfTalk: boolean; + isDeviceTalk: boolean; + isSendingLocation: boolean; + isSelfInGroup: boolean; + isArchived: boolean; + isPinned: boolean; + isMuted: boolean; + isContactRequest: boolean; + /** + * contact id if this is a dm chat (for view profile entry in context menu) + */ + dmChatContact: U32 | null; + }) + | { type: "ArchiveLink" } + | ({ type: "Error" } & { id: U32; error: string }); +export type Contact = { + address: string; + color: string; + authName: string; + status: string; + displayName: string; + id: U32; + name: string; + profileImage: string | null; + nameAndAddr: string; + isBlocked: boolean; + isVerified: boolean; +}; +export type FullChat = { + id: U32; + name: string; + isProtected: boolean; + profileImage: string | null; + archived: boolean; + chatType: U32; + isUnpromoted: boolean; + isSelfTalk: boolean; + contacts: Contact[]; + contactIds: U32[]; + color: string; + freshMessageCounter: Usize; + isContactRequest: boolean; + isDeviceChat: boolean; + selfInGroup: boolean; + isMuted: boolean; + ephemeralTimer: U32; + canSend: boolean; +}; +export type Viewtype = + | "Unknown" + /** + * Text message. + */ + | "Text" + /** + * Image message. + * If the image is an animated GIF, the type `Viewtype.Gif` should be used. + */ + | "Image" + /** + * Animated GIF message. + */ + | "Gif" + /** + * Message containing a sticker, similar to image. + * If possible, the ui should display the image without borders in a transparent way. + * A click on a sticker will offer to install the sticker set in some future. + */ + | "Sticker" + /** + * Message containing an Audio file. + */ + | "Audio" + /** + * A voice message that was directly recorded by the user. + * For all other audio messages, the type `Viewtype.Audio` should be used. + */ + | "Voice" + /** + * Video messages. + */ + | "Video" + /** + * Message containing any file, eg. a PDF. + */ + | "File" + /** + * Message is an invitation to a videochat. + */ + | "VideochatInvitation" + /** + * Message is an webxdc instance. + */ + | "Webxdc"; +export type I32 = number; +export type U64 = number; +export type Message = { + id: U32; + chatId: U32; + fromId: U32; + quotedText: string | null; + quotedMessageId: U32 | null; + text: string | null; + hasLocation: boolean; + hasHtml: boolean; + viewType: Viewtype; + state: U32; + timestamp: I64; + sortTimestamp: I64; + receivedTimestamp: I64; + hasDeviatingTimestamp: boolean; + subject: string; + showPadlock: boolean; + isSetupmessage: boolean; + isInfo: boolean; + isForwarded: boolean; + duration: I32; + dimensionsHeight: I32; + dimensionsWidth: I32; + videochatType: U32 | null; + videochatUrl: string | null; + overrideSenderName: string | null; + sender: Contact; + setupCodeBegin: string | null; + file: string | null; + fileMime: string | null; + fileBytes: U64; + fileName: string | null; +}; +export type WebxdcMessageInfo = { + /** + * The name of the app. + * + * Defaults to the filename if not set in the manifest. + */ + name: string; + /** + * App icon file name. + * Defaults to an standard icon if nothing is set in the manifest. + * + * To get the file, use dc_msg_get_webxdc_blob(). (not yet in jsonrpc, use rust api or cffi for it) + * + * App icons should should be square, + * the implementations will add round corners etc. as needed. + */ + icon: string; + /** + * if the Webxdc represents a document, then this is the name of the document + */ + document: string | null; + /** + * short string describing the state of the app, + * sth. as "2 votes", "Highscore: 123", + * can be changed by the apps + */ + summary: string | null; + /** + * URL where the source code of the Webxdc and other information can be found; + * defaults to an empty string. + * Implementations may offer an menu or a button to open this URL. + */ + sourceCodeUrl: string | null; +}; +export type __AllTyps = [ + string, + boolean, + Record, + U32, + U32, + null, + U32[], + U32, + null, + U32 | null, + Account[], + U32, + Account, + U32, + string, + ProviderInfo | null, + U32, + boolean, + U32, + Record, + U32, + string, + string | null, + null, + U32, + Record, + null, + U32, + string, + null, + U32, + string, + Qr, + U32, + string, + string | null, + U32, + string[], + Record, + U32, + null, + U32, + null, + U32, + U32[], + U32, + U32, + Usize, + U32, + string, + U32, + U32, + string, + null, + U32, + U32 | null, + string | null, + U32 | null, + ChatListEntry[], + U32, + ChatListEntry[], + Record, + U32, + U32, + FullChat, + U32, + U32, + null, + U32, + U32, + null, + U32, + string, + string, + U32, + U32, + U32, + U32, + U32[], + U32, + U32, + Message, + U32, + U32[], + Record, + U32, + U32, + Contact, + U32, + string, + string | null, + U32, + U32, + U32, + U32, + U32, + U32, + null, + U32, + U32, + null, + U32, + Contact[], + U32, + U32, + string | null, + U32[], + U32, + U32, + string | null, + Contact[], + U32, + U32[], + Record, + U32, + U32, + Viewtype, + Viewtype | null, + Viewtype | null, + U32[], + U32, + U32, + string, + string, + null, + U32, + U32, + U32, + string, + U32, + U32, + WebxdcMessageInfo, + U32, + string, + U32, + U32 +];