parent
6e276b605f
commit
775df8097c
|
@ -107,7 +107,8 @@ type
|
||||||
msg: string
|
msg: string
|
||||||
replyTo: string
|
replyTo: string
|
||||||
preferredUsername: string
|
preferredUsername: string
|
||||||
linkPreviews: JsonNode
|
standardLinkPreviews: JsonNode
|
||||||
|
statusLinkPreviews: JsonNode
|
||||||
|
|
||||||
const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
let arg = decode[AsyncSendImagesTaskArg](argEncoded)
|
let arg = decode[AsyncSendImagesTaskArg](argEncoded)
|
||||||
|
@ -120,8 +121,15 @@ const asyncSendImagesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
if imagePath != "":
|
if imagePath != "":
|
||||||
imagePaths.add(imagePath)
|
imagePaths.add(imagePath)
|
||||||
|
|
||||||
let response = status_chat.sendImages(arg.chatId, imagePaths, arg.msg, arg.replyTo, arg.preferredUsername,
|
let response = status_chat.sendImages(
|
||||||
arg.linkPreviews)
|
arg.chatId,
|
||||||
|
imagePaths,
|
||||||
|
arg.msg,
|
||||||
|
arg.replyTo,
|
||||||
|
arg.preferredUsername,
|
||||||
|
arg.standardLinkPreviews,
|
||||||
|
arg.statusLinkPreviews,
|
||||||
|
)
|
||||||
|
|
||||||
for imagePath in imagePaths:
|
for imagePath in imagePaths:
|
||||||
removeFile(imagePath)
|
removeFile(imagePath)
|
||||||
|
|
|
@ -431,22 +431,28 @@ QtObject:
|
||||||
replyTo: string,
|
replyTo: string,
|
||||||
preferredUsername: string = "",
|
preferredUsername: string = "",
|
||||||
linkPreviews: seq[LinkPreview] = @[]) =
|
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(
|
self.threadpool.start(arg)
|
||||||
tptr: asyncSendImagesTask,
|
except Exception as e:
|
||||||
vptr: cast[ByteAddress](self.vptr),
|
error "Error sending images", msg = e.msg
|
||||||
slot: "onAsyncSendImagesDone",
|
self.events.emit(SIGNAL_SENDING_FAILED, MessageSendingFailure(chatId: chatId, error: e.msg))
|
||||||
chatId: chatId,
|
|
||||||
imagePathsAndDataJson: imagePathsAndDataJson,
|
|
||||||
tempDir: TMPDIR,
|
|
||||||
msg: msg,
|
|
||||||
replyTo: replyTo,
|
|
||||||
preferredUsername: preferredUsername,
|
|
||||||
linkPreviews: %linkPreviews,
|
|
||||||
)
|
|
||||||
|
|
||||||
self.threadpool.start(arg)
|
|
||||||
|
|
||||||
proc onAsyncSendImagesDone*(self: Service, rpcResponseJson: string) {.slot.} =
|
proc onAsyncSendImagesDone*(self: Service, rpcResponseJson: string) {.slot.} =
|
||||||
let rpcResponseObj = rpcResponseJson.parseJson
|
let rpcResponseObj = rpcResponseJson.parseJson
|
||||||
|
|
|
@ -75,7 +75,7 @@ proc sendChatMessage*(
|
||||||
"contentType": contentType,
|
"contentType": contentType,
|
||||||
"communityId": communityId,
|
"communityId": communityId,
|
||||||
"linkPreviews": standardLinkPreviews,
|
"linkPreviews": standardLinkPreviews,
|
||||||
"statusLinkPreviews": statusLinkPreviews
|
"statusLinkPreviews": statusLinkPreviews,
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ proc sendImages*(chatId: string,
|
||||||
msg: string,
|
msg: string,
|
||||||
replyTo: string,
|
replyTo: string,
|
||||||
preferredUsername: string,
|
preferredUsername: string,
|
||||||
linkPreviews: JsonNode,
|
standardLinkPreviews: JsonNode,
|
||||||
|
statusLinkPreviews: JsonNode,
|
||||||
): RpcResponse[JsonNode] =
|
): RpcResponse[JsonNode] =
|
||||||
let imagesJson = %* images.map(image => %*
|
let imagesJson = %* images.map(image => %*
|
||||||
{
|
{
|
||||||
|
@ -94,7 +95,8 @@ proc sendImages*(chatId: string,
|
||||||
"ensName": preferredUsername,
|
"ensName": preferredUsername,
|
||||||
"text": msg,
|
"text": msg,
|
||||||
"responseTo": replyTo,
|
"responseTo": replyTo,
|
||||||
"linkPreviews": linkPreviews
|
"linkPreviews": standardLinkPreviews,
|
||||||
|
"statusLinkPreviews": statusLinkPreviews,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
callPrivateRPC("sendChatMessages".prefix, %* [imagesJson])
|
callPrivateRPC("sendChatMessages".prefix, %* [imagesJson])
|
||||||
|
|
Loading…
Reference in New Issue