fix: consecutive discord messages should be grouped like status messages

- fill the senderId just like other messages
- add some checks in Utils since the "publicKey" (ID) coming Discord
isn't in the format we'd normally expect

Closes #6678
This commit is contained in:
Lukáš Tinkl 2022-10-27 11:21:10 +02:00 committed by Lukáš Tinkl
parent 6175beb40a
commit f122607ada
3 changed files with 9 additions and 6 deletions

View File

@ -134,6 +134,7 @@ proc initItem*(
if ContentType.DiscordMessage == contentType:
result.messageText = discordMessage.content
result.senderId = discordMessage.author.id
result.senderDisplayName = discordMessage.author.name
result.senderIcon = discordMessage.author.localUrl
result.timestamp = parseInt(discordMessage.timestamp)*1000

View File

@ -90,7 +90,7 @@ Loader {
property double prevMsgTimestamp: prevMessageAsJsonObj ? prevMessageAsJsonObj.timestamp : 0
property double nextMsgTimestamp: nextMessageAsJsonObj ? nextMessageAsJsonObj.timestamp : 0
property bool shouldRepeatHeader: ((messageTimestamp - prevMsgTimestamp) / 60 / 1000) > Constants.repeatHeaderInterval || isDiscordMessage
property bool shouldRepeatHeader: ((messageTimestamp - prevMsgTimestamp) / 60 / 1000) > Constants.repeatHeaderInterval
property bool hasMention: false

View File

@ -562,13 +562,13 @@ QtObject {
}
function isEnsVerified(publicKey, getVerificationRequest=true) {
if (!publicKey)
return false
if (publicKey === "" || !isChatKey(publicKey) )
return
return getContactDetailsAsJson(publicKey, getVerificationRequest).ensVerified
}
function getEmojiHashAsJson(publicKey) {
if (publicKey === "") {
if (publicKey === "" || !isChatKey(publicKey)) {
return ""
}
let jsonObj = globalUtilsInst.getEmojiHashAsJson(publicKey)
@ -576,7 +576,7 @@ QtObject {
}
function getColorHashAsJson(publicKey, force=false, getVerificationRequest=true) {
if (publicKey === "")
if (publicKey === "" || !isChatKey(publicKey) )
return
if (!force && isEnsVerified(publicKey, getVerificationRequest))
return
@ -585,7 +585,7 @@ QtObject {
}
function colorIdForPubkey(publicKey) {
if (publicKey === "") {
if (publicKey === "" || !isChatKey(publicKey)) {
return 0
}
return globalUtilsInst.getColorId(publicKey)
@ -608,6 +608,8 @@ QtObject {
if (publicKey === "") {
return ""
}
if (!isChatKey(publicKey))
return publicKey
return globalUtilsInst.getCompressedPk(publicKey)
}