diff --git a/src/app_service/service/chat/async_tasks.nim b/src/app_service/service/chat/async_tasks.nim index d6dfc5fb35..d181febd9d 100644 --- a/src/app_service/service/chat/async_tasks.nim +++ b/src/app_service/service/chat/async_tasks.nim @@ -107,7 +107,8 @@ type msg: string replyTo: string preferredUsername: string - linkPreviews: JsonNode + standardLinkPreviews: JsonNode + statusLinkPreviews: JsonNode const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = let arg = decode[AsyncSendImagesTaskArg](argEncoded) @@ -120,8 +121,15 @@ const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = if imagePath != "": imagePaths.add(imagePath) - let response = status_chat.sendImages(arg.chatId, imagePaths, arg.msg, arg.replyTo, arg.preferredUsername, - arg.linkPreviews) + let response = status_chat.sendImages( + arg.chatId, + imagePaths, + arg.msg, + arg.replyTo, + arg.preferredUsername, + arg.standardLinkPreviews, + arg.statusLinkPreviews, + ) for imagePath in imagePaths: removeFile(imagePath) diff --git a/src/app_service/service/chat/service.nim b/src/app_service/service/chat/service.nim index 561f1e583f..b3f5e6fbf0 100644 --- a/src/app_service/service/chat/service.nim +++ b/src/app_service/service/chat/service.nim @@ -431,22 +431,28 @@ QtObject: replyTo: string, preferredUsername: string = "", linkPreviews: seq[LinkPreview] = @[]) = + try: + let (standardLinkPreviews, statusLinkPreviews) = extractLinkPreviewsLists(linkPreviews) + let arg = AsyncSendImagesTaskArg( + tptr: asyncSendImagesTask, + vptr: cast[ByteAddress](self.vptr), + slot: "onAsyncSendImagesDone", + chatId: chatId, + imagePathsAndDataJson: imagePathsAndDataJson, + tempDir: TMPDIR, + msg: msg, + replyTo: replyTo, + preferredUsername: preferredUsername, + standardLinkPreviews: %standardLinkPreviews, + statusLinkPreviews: %statusLinkPreviews, + ) - let arg = AsyncSendImagesTaskArg( - tptr: asyncSendImagesTask, - vptr: cast[ByteAddress](self.vptr), - slot: "onAsyncSendImagesDone", - chatId: chatId, - imagePathsAndDataJson: imagePathsAndDataJson, - tempDir: TMPDIR, - msg: msg, - replyTo: replyTo, - preferredUsername: preferredUsername, - linkPreviews: %linkPreviews, - ) + self.threadpool.start(arg) + except Exception as e: + error "Error sending images", msg = e.msg + self.events.emit(SIGNAL_SENDING_FAILED, MessageSendingFailure(chatId: chatId, error: e.msg)) - self.threadpool.start(arg) proc onAsyncSendImagesDone*(self: Service, rpcResponseJson: string) {.slot.} = let rpcResponseObj = rpcResponseJson.parseJson diff --git a/src/backend/chat.nim b/src/backend/chat.nim index 752253e6f1..822175d730 100644 --- a/src/backend/chat.nim +++ b/src/backend/chat.nim @@ -75,7 +75,7 @@ proc sendChatMessage*( "contentType": contentType, "communityId": communityId, "linkPreviews": standardLinkPreviews, - "statusLinkPreviews": statusLinkPreviews + "statusLinkPreviews": statusLinkPreviews, } ]) @@ -84,7 +84,8 @@ proc sendImages*(chatId: string, msg: string, replyTo: string, preferredUsername: string, - linkPreviews: JsonNode, + standardLinkPreviews: JsonNode, + statusLinkPreviews: JsonNode, ): RpcResponse[JsonNode] = let imagesJson = %* images.map(image => %* { @@ -94,7 +95,8 @@ proc sendImages*(chatId: string, "ensName": preferredUsername, "text": msg, "responseTo": replyTo, - "linkPreviews": linkPreviews + "linkPreviews": standardLinkPreviews, + "statusLinkPreviews": statusLinkPreviews, } ) callPrivateRPC("sendChatMessages".prefix, %* [imagesJson])