fix(message/service): fix crash on missing assignment of MessageResult

Fixes #12195
This commit is contained in:
Jonathan Rainville 2023-09-19 10:14:17 -04:00
parent 7cef5fcbf5
commit fb4f77b9bb
1 changed files with 5 additions and 2 deletions

View File

@ -572,10 +572,13 @@ QtObject:
proc getMessageByMessageId*(self: Service, messageId: string): GetMessageResult = proc getMessageByMessageId*(self: Service, messageId: string): GetMessageResult =
try: try:
result = GetMessageResult()
let msgResponse = status_go.getMessageByMessageId(messageId) let msgResponse = status_go.getMessageByMessageId(messageId)
if msgResponse.error.isNil: if not msgResponse.error.isNil:
result.message = msgResponse.result.toMessageDto() let error = Json.decode($msgResponse.error, RpcError)
raise newException(RpcException, "Error resending chat message: " & error.message)
result.message = msgResponse.result.toMessageDto()
if result.message.id.len == 0: if result.message.id.len == 0:
result.error = "message with id: " & messageId & " doesn't exist" result.error = "message with id: " & messageId & " doesn't exist"
return return