use pub key to gen chat message id
This commit is contained in:
parent
d4c597fa0f
commit
6252736ad2
|
@ -1,3 +1,5 @@
|
|||
import { recoverPublicKeyFromMetadata } from '~/src/utils/recover-public-key-from-metadata'
|
||||
|
||||
import { ApplicationMetadataMessage } from '../../../protos/application-metadata-message'
|
||||
import { ChatMessage } from '../../../protos/chat-message'
|
||||
import { ProtocolMessage } from '../../../protos/protocol-message'
|
||||
|
@ -46,12 +48,13 @@ export function handleChannelChatMessage(
|
|||
return
|
||||
}
|
||||
|
||||
const publicKey = recoverPublicKeyFromMetadata(decodedMetadata)
|
||||
|
||||
const decodedPayload = ChatMessage.decode(messageToDecode)
|
||||
|
||||
const messageId = payloadToId(
|
||||
decodedProtocol.publicMessage,
|
||||
wakuMessage.signaturePublicKey
|
||||
)
|
||||
// fixme?: handle decodedProtocol.encryptedMessage
|
||||
const messageId = payloadToId(decodedProtocol.publicMessage, publicKey)
|
||||
|
||||
const channelId = getChannelId(decodedPayload.chatId)
|
||||
|
||||
const message = mapChatMessage(decodedPayload, { messageId, channelId })
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// todo?: rename to handle-message
|
||||
import { bytesToHex } from 'ethereum-cryptography/utils'
|
||||
|
||||
import { recoverPublicKeyFromMetadata } from '~/src/utils/recover-public-key-from-metadata'
|
||||
|
||||
import { ApplicationMetadataMessage } from '../../../protos/application-metadata-message'
|
||||
import {
|
||||
ChatMessage,
|
||||
|
@ -61,17 +63,16 @@ export function handleChannelChatMessage(
|
|||
// break
|
||||
// }
|
||||
|
||||
const publicKey = recoverPublicKeyFromMetadata(decodedMetadata)
|
||||
|
||||
// todo: merge and process other types of messages
|
||||
// TODO?: ignore messages which are messageType !== COMMUNITY_CHAT
|
||||
switch (decodedMetadata.type) {
|
||||
case ApplicationMetadataMessage.Type.TYPE_CHAT_MESSAGE: {
|
||||
const decodedPayload = ChatMessage.decode(messageToDecode)
|
||||
|
||||
const messageId = payloadToId(
|
||||
decodedProtocol.publicMessage,
|
||||
// fixme!: replace for recoverPublicKeyFromMetadata
|
||||
wakuMessage.signaturePublicKey
|
||||
)
|
||||
// fixme?: handle decodedProtocol.encryptedMessage
|
||||
const messageId = payloadToId(decodedProtocol.publicMessage, publicKey)
|
||||
const channelId = getChannelId(decodedPayload.chatId)
|
||||
|
||||
const _messages = messages[channelId] || []
|
||||
|
|
Loading…
Reference in New Issue