handle only MessageType.COMMUNITY_CHAT (#281)
This commit is contained in:
parent
5d65d4d95e
commit
cb88ee7a62
|
@ -5,6 +5,7 @@ import {
|
|||
ChatMessage,
|
||||
DeleteMessage,
|
||||
EditMessage,
|
||||
MessageType,
|
||||
} from '../../../protos/chat-message'
|
||||
import { EmojiReaction } from '../../../protos/emoji-reaction'
|
||||
import { PinMessage } from '../../../protos/pin-message'
|
||||
|
@ -68,8 +69,8 @@ export function handleWakuMessage(
|
|||
|
||||
client.wakuMessages.add(messageId)
|
||||
|
||||
// decode, map and handle (events)
|
||||
try {
|
||||
// decode, map and handle (events)
|
||||
switch (decodedMetadata.type) {
|
||||
case ApplicationMetadataMessage.Type.TYPE_COMMUNITY_DESCRIPTION: {
|
||||
// decode
|
||||
|
@ -85,7 +86,8 @@ export function handleWakuMessage(
|
|||
// decode
|
||||
const decodedPayload = ChatMessage.decode(messageToDecode)
|
||||
|
||||
// TODO?: ignore community.channelMessages which are messageType !== COMMUNITY_CHAT
|
||||
switch (decodedPayload.messageType) {
|
||||
case MessageType.COMMUNITY_CHAT: {
|
||||
const chatUuid = getChatUuid(decodedPayload.chatId)
|
||||
|
||||
// map
|
||||
|
@ -100,9 +102,19 @@ export function handleWakuMessage(
|
|||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
case ApplicationMetadataMessage.Type.TYPE_EDIT_MESSAGE: {
|
||||
const decodedPayload = EditMessage.decode(messageToDecode)
|
||||
|
||||
switch (decodedPayload.messageType) {
|
||||
case MessageType.COMMUNITY_CHAT: {
|
||||
const messageId = decodedPayload.messageId
|
||||
const chatUuid = getChatUuid(decodedPayload.chatId)
|
||||
|
||||
|
@ -113,9 +125,19 @@ export function handleWakuMessage(
|
|||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
case ApplicationMetadataMessage.Type.TYPE_DELETE_MESSAGE: {
|
||||
const decodedPayload = DeleteMessage.decode(messageToDecode)
|
||||
|
||||
switch (decodedPayload.messageType) {
|
||||
case MessageType.COMMUNITY_CHAT: {
|
||||
const messageId = decodedPayload.messageId
|
||||
const chatUuid = getChatUuid(decodedPayload.chatId)
|
||||
|
||||
|
@ -124,9 +146,19 @@ export function handleWakuMessage(
|
|||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
case ApplicationMetadataMessage.Type.TYPE_PIN_MESSAGE: {
|
||||
const decodedPayload = PinMessage.decode(messageToDecode)
|
||||
|
||||
switch (decodedPayload.messageType) {
|
||||
case MessageType.COMMUNITY_CHAT: {
|
||||
const messageId = decodedPayload.messageId
|
||||
const chatUuid = getChatUuid(decodedPayload.chatId)
|
||||
|
||||
|
@ -137,9 +169,19 @@ export function handleWakuMessage(
|
|||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
case ApplicationMetadataMessage.Type.TYPE_EMOJI_REACTION: {
|
||||
const decodedPayload = EmojiReaction.decode(messageToDecode)
|
||||
|
||||
switch (decodedPayload.messageType) {
|
||||
case MessageType.COMMUNITY_CHAT: {
|
||||
const messageId = decodedPayload.messageId
|
||||
const chatUuid = getChatUuid(decodedPayload.chatId)
|
||||
|
||||
|
@ -154,9 +196,18 @@ export function handleWakuMessage(
|
|||
break
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
default: {
|
||||
break
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// protons-runtime throws when trying to decode invalid protocol buffers
|
||||
// eslint-disable-next-line no-empty
|
||||
|
|
Loading…
Reference in New Issue