diff --git a/library/api/client_api.nim b/library/api/client_api.nim index 71c2827..8dca8fa 100644 --- a/library/api/client_api.nim +++ b/library/api/client_api.nim @@ -73,7 +73,7 @@ registerReqFFI(CreateClientRequest, ctx: ptr FFIContext[Client]): proc( configJson: cstring, chatCallbacks: ChatCallbacks ): Future[Result[string, string]] {.async.} = - ctx[].myLib[] = (await createChatClient(configJson, chatCallbacks)).valueOr: + ctx.myLib[] = (await createChatClient(configJson, chatCallbacks)).valueOr: error "CreateClientRequest failed", error = error return err($error) return ok("") @@ -88,7 +88,7 @@ proc chat_start( userData: pointer ) {.ffi.} = try: - await ctx[].myLib[].start() + await ctx.myLib[].start() return ok("") except CatchableError as e: error "chat_start failed", error = e.msg @@ -100,7 +100,7 @@ proc chat_stop( userData: pointer ) {.ffi.} = try: - await ctx[].myLib[].stop() + await ctx.myLib[].stop() return ok("") except CatchableError as e: error "chat_stop failed", error = e.msg @@ -116,7 +116,7 @@ proc chat_get_id( userData: pointer ) {.ffi.} = ## Get the client's identifier - let clientId = ctx[].myLib[].getId() + let clientId = ctx.myLib[].getId() return ok(clientId) proc chat_get_default_inbox_id( @@ -125,7 +125,7 @@ proc chat_get_default_inbox_id( userData: pointer ) {.ffi.} = ## Get the default inbox conversation ID - let inboxId = ctx[].myLib[].defaultInboxConversationId() + let inboxId = ctx.myLib[].defaultInboxConversationId() return ok(inboxId) ################################################# @@ -138,7 +138,7 @@ proc chat_list_conversations( userData: pointer ) {.ffi.} = ## List all conversations as JSON array - let convos = ctx[].myLib[].listConversations() + let convos = ctx.myLib[].listConversations() var convoList = newJArray() for convo in convos: convoList.add(%*{"id": convo.id()}) @@ -151,6 +151,6 @@ proc chat_get_conversation( convoId: cstring ) {.ffi.} = ## Get a specific conversation by ID - let convo = ctx[].myLib[].getConversation($convoId) + let convo = ctx.myLib[].getConversation($convoId) return ok($(%*{"id": convo.id()})) diff --git a/library/api/conversation_api.nim b/library/api/conversation_api.nim index 79779f4..9320eda 100644 --- a/library/api/conversation_api.nim +++ b/library/api/conversation_api.nim @@ -44,7 +44,7 @@ proc chat_new_private_conversation( let content = hexToSeqByte($contentHex) # Create the conversation - let errOpt = await ctx[].myLib[].newPrivateConversation(introBundle, content) + let errOpt = await ctx.myLib[].newPrivateConversation(introBundle, content) if errOpt.isSome(): return err("failed to create conversation: " & $errOpt.get()) @@ -68,7 +68,7 @@ proc chat_send_message( ## convoId: Conversation ID string ## contentHex: Message content as hex-encoded string try: - let convo = ctx[].myLib[].getConversation($convoId) + let convo = ctx.myLib[].getConversation($convoId) let content = hexToSeqByte($contentHex) let msgId = await convo.sendMessage(content) diff --git a/library/api/identity_api.nim b/library/api/identity_api.nim index 6d2ccdb..024d583 100644 --- a/library/api/identity_api.nim +++ b/library/api/identity_api.nim @@ -26,7 +26,7 @@ proc chat_get_identity( ) {.ffi.} = ## Get the client identity ## Returns JSON string: {"name": "...", "address": "...", "pubkey": "hex..."} - let ident = ctx[].myLib[].identity() + let ident = ctx.myLib[].identity() let identJson = %*{ "name": ident.getName(), "address": ident.getAddr(), @@ -45,7 +45,7 @@ proc chat_create_intro_bundle( ) {.ffi.} = ## Create an IntroBundle for initiating private conversations ## Returns JSON string: {"ident": "hex...", "ephemeral": "hex..."} - let bundle = ctx[].myLib[].createIntroBundle() + let bundle = ctx.myLib[].createIntroBundle() let bundleJson = %*{ "ident": bundle.ident.toHex(), "ephemeral": bundle.ephemeral.toHex()