parent
6e276b605f
commit
775df8097c
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue