refactor: extract layers in StatusMessage

Extracted:
- TransportLayer
- EncryptionLayer
- ApplicationLayer
This commit is contained in:
Patryk Osmaczko 2023-11-08 19:05:33 +01:00 committed by osmaczko
parent eab6118f12
commit f7042e4b9e
17 changed files with 251 additions and 253 deletions

View File

@ -1,6 +1,6 @@
//nolint //nolint
// Code generated by generate_handlers.go. DO NOT EDIT. // Code generated by generate_handlers.go. DO NOT EDIT.
// source: geneate_handlers.go // source: generate_handlers.go
package protocol package protocol
@ -17,13 +17,13 @@ import (
) )
func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter, fromArchive bool) error { func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter, fromArchive bool) error {
switch msg.Type { switch msg.ApplicationLayer.Type {
{{ range .}} {{ range .}}
case protobuf.ApplicationMetadataMessage_{{.EnumValue}}: case protobuf.ApplicationMetadataMessage_{{.EnumValue}}:
return m.{{.MethodName}}(messageState, protoBytes, msg, filter{{ if .FromArchiveArg }}, fromArchive{{ end }}) return m.{{.MethodName}}(messageState, protoBytes, msg, filter{{ if .FromArchiveArg }}, fromArchive{{ end }})
{{ end }} {{ end }}
default: default:
m.logger.Info("protobuf type not found", zap.String("type", string(msg.Type))) m.logger.Info("protobuf type not found", zap.String("type", string(msg.ApplicationLayer.Type)))
return errors.New("protobuf type not found") return errors.New("protobuf type not found")
} }
return nil return nil
@ -48,7 +48,7 @@ func (m *Messenger) {{.MethodName}}(messageState *ReceivedMessageState, protoByt
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.Handle{{.ProtobufName}}(messageState, p, msg{{ if .FromArchiveArg }}, fromArchive {{ end }}) return m.Handle{{.ProtobufName}}(messageState, p, msg{{ if .FromArchiveArg }}, fromArchive {{ end }})
{{ end }} {{ end }}

View File

@ -98,7 +98,7 @@ func (c *Client) sendUnprocessedMetrics() {
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: encodedMessage, Payload: encodedMessage,
Sender: ephemeralKey, Sender: ephemeralKey,
SkipProtocolLayer: true, SkipEncryptionLayer: true,
SendOnPersonalTopic: true, SendOnPersonalTopic: true,
MessageType: protobuf.ApplicationMetadataMessage_ANONYMOUS_METRIC_BATCH, MessageType: protobuf.ApplicationMetadataMessage_ANONYMOUS_METRIC_BATCH,
} }

View File

@ -165,7 +165,7 @@ func (s *MessageSender) SendPrivate(
// Currently we don't support sending through datasync and setting custom waku fields, // Currently we don't support sending through datasync and setting custom waku fields,
// as the datasync interface is not rich enough to propagate that information, so we // as the datasync interface is not rich enough to propagate that information, so we
// would have to add some complexity to handle this. // would have to add some complexity to handle this.
if rawMessage.ResendAutomatically && (rawMessage.Sender != nil || rawMessage.SkipProtocolLayer || rawMessage.SendOnPersonalTopic) { if rawMessage.ResendAutomatically && (rawMessage.Sender != nil || rawMessage.SkipEncryptionLayer || rawMessage.SendOnPersonalTopic) {
return nil, errors.New("setting identity, skip-encryption or personal topic and datasync not supported") return nil, errors.New("setting identity, skip-encryption or personal topic and datasync not supported")
} }
@ -489,7 +489,7 @@ func (s *MessageSender) sendPrivate(
return nil, err return nil, err
} }
} }
} else if rawMessage.SkipProtocolLayer { } else if rawMessage.SkipEncryptionLayer {
// When SkipProtocolLayer is set we don't pass the message to the encryption layer // When SkipProtocolLayer is set we don't pass the message to the encryption layer
messageIDs := [][]byte{messageID} messageIDs := [][]byte{messageID}
hash, newMessage, err := s.sendPrivateRawMessage(ctx, rawMessage, recipient, wrappedMessage, messageIDs) hash, newMessage, err := s.sendPrivateRawMessage(ctx, rawMessage, recipient, wrappedMessage, messageIDs)
@ -666,7 +666,7 @@ func (s *MessageSender) SendPublic(
return nil, errors.Wrap(err, "failed to wrap a public message in the encryption layer") return nil, errors.Wrap(err, "failed to wrap a public message in the encryption layer")
} }
if !rawMessage.SkipProtocolLayer { if !rawMessage.SkipEncryptionLayer {
newMessage, err = MessageSpecToWhisper(messageSpec) newMessage, err = MessageSpecToWhisper(messageSpec)
if err != nil { if err != nil {
return nil, err return nil, err
@ -721,7 +721,7 @@ func unwrapDatasyncMessage(m *v1protocol.StatusMessage, datasync *datasync.DataS
payloads, acks, err := datasync.UnwrapPayloadsAndAcks( payloads, acks, err := datasync.UnwrapPayloadsAndAcks(
m.SigPubKey(), m.SigPubKey(),
m.DecryptedPayload, m.EncryptionLayer.Payload,
) )
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -732,7 +732,7 @@ func unwrapDatasyncMessage(m *v1protocol.StatusMessage, datasync *datasync.DataS
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
message.DecryptedPayload = payload message.EncryptionLayer.Payload = payload
statusMessages = append(statusMessages, message) statusMessages = append(statusMessages, message)
} }
return statusMessages, acks, nil return statusMessages, acks, nil
@ -750,7 +750,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
var statusMessages []*v1protocol.StatusMessage var statusMessages []*v1protocol.StatusMessage
var acks [][]byte var acks [][]byte
err := statusMessage.HandleTransport(shhMessage) err := statusMessage.HandleTransportLayer(shhMessage)
if err != nil { if err != nil {
hlogger.Error("failed to handle transport layer message", zap.Error(err)) hlogger.Error("failed to handle transport layer message", zap.Error(err))
return nil, nil, err return nil, nil, err
@ -762,14 +762,14 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
} }
// Hash ratchet with a group id not found yet // Hash ratchet with a group id not found yet
if err == encryption.ErrHashRatchetGroupIDNotFound && len(statusMessage.HashRatchetInfo) == 1 { if err == encryption.ErrHashRatchetGroupIDNotFound && len(statusMessage.EncryptionLayer.HashRatchetInfo) == 1 {
info := statusMessage.HashRatchetInfo[0] info := statusMessage.EncryptionLayer.HashRatchetInfo[0]
err := s.persistence.SaveHashRatchetMessage(info.GroupID, info.KeyID, shhMessage) err := s.persistence.SaveHashRatchetMessage(info.GroupID, info.KeyID, shhMessage)
return nil, nil, err return nil, nil, err
} }
// Check if there are undecrypted message // Check if there are undecrypted message
for _, hashRatchetInfo := range statusMessage.HashRatchetInfo { for _, hashRatchetInfo := range statusMessage.EncryptionLayer.HashRatchetInfo {
messages, err := s.persistence.GetHashRatchetMessages(hashRatchetInfo.KeyID) messages, err := s.persistence.GetHashRatchetMessages(hashRatchetInfo.KeyID)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -778,7 +778,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
var processedIds [][]byte var processedIds [][]byte
for _, message := range messages { for _, message := range messages {
var statusMessage v1protocol.StatusMessage var statusMessage v1protocol.StatusMessage
err := statusMessage.HandleTransport(message) err := statusMessage.HandleTransportLayer(message)
if err != nil { if err != nil {
hlogger.Error("failed to handle transport layer message", zap.Error(err)) hlogger.Error("failed to handle transport layer message", zap.Error(err))
return nil, nil, err return nil, nil, err
@ -820,7 +820,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
} }
for _, statusMessage := range statusMessages { for _, statusMessage := range statusMessages {
err := statusMessage.HandleApplicationMetadata() err := statusMessage.HandleApplicationLayer()
if err != nil { if err != nil {
hlogger.Error("failed to handle application metadata layer message", zap.Error(err)) hlogger.Error("failed to handle application metadata layer message", zap.Error(err))
} }
@ -849,9 +849,9 @@ func (s *MessageSender) handleEncryptionLayer(ctx context.Context, message *v1pr
publicKey := message.SigPubKey() publicKey := message.SigPubKey()
// if it's an ephemeral key, we don't negotiate a topic // if it's an ephemeral key, we don't negotiate a topic
decryptionKey, skipNegotiation := s.fetchDecryptionKey(message.Dst) decryptionKey, skipNegotiation := s.fetchDecryptionKey(message.TransportLayer.Dst)
err := message.HandleEncryption(decryptionKey, publicKey, s.protocol, skipNegotiation) err := message.HandleEncryptionLayer(decryptionKey, publicKey, s.protocol, skipNegotiation)
// if it's an ephemeral key, we don't have to handle a device not found error // if it's an ephemeral key, we don't have to handle a device not found error
if err == encryption.ErrDeviceNotFound && !skipNegotiation { if err == encryption.ErrDeviceNotFound && !skipNegotiation {

View File

@ -120,9 +120,9 @@ func (s *MessageSenderSuite) TestHandleDecodedMessagesWrapped() {
s.Require().Equal(1, len(decodedMessages)) s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey()) s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID) s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload) s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type) s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
} }
func (s *MessageSenderSuite) TestHandleDecodedMessagesDatasync() { func (s *MessageSenderSuite) TestHandleDecodedMessagesDatasync() {
@ -155,9 +155,9 @@ func (s *MessageSenderSuite) TestHandleDecodedMessagesDatasync() {
// We send two messages, the unwrapped one will be attributed to the relayer, while the wrapped one will be attributed to the author // We send two messages, the unwrapped one will be attributed to the relayer, while the wrapped one will be attributed to the author
s.Require().Equal(1, len(decodedMessages)) s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey()) s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID) s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload) s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type) s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
} }
func (s *MessageSenderSuite) CalculatePoWTest() { func (s *MessageSenderSuite) CalculatePoWTest() {
@ -221,9 +221,9 @@ func (s *MessageSenderSuite) TestHandleDecodedMessagesDatasyncEncrypted() {
// while the wrapped one will be attributed to the author. // while the wrapped one will be attributed to the author.
s.Require().Equal(1, len(decodedMessages)) s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey()) s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID) s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload) s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type) s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
} }
func (s *MessageSenderSuite) TestHandleOutOfOrderHashRatchet() { func (s *MessageSenderSuite) TestHandleOutOfOrderHashRatchet() {

View File

@ -23,7 +23,7 @@ type RawMessage struct {
SendCount int SendCount int
Sent bool Sent bool
ResendAutomatically bool ResendAutomatically bool
SkipProtocolLayer bool // don't wrap message into ProtocolMessage SkipEncryptionLayer bool // don't wrap message into ProtocolMessage
SendPushNotification bool SendPushNotification bool
MessageType protobuf.ApplicationMetadataMessage_Type MessageType protobuf.ApplicationMetadataMessage_Type
Payload []byte Payload []byte

View File

@ -97,7 +97,7 @@ func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error {
message.MessageType, message.MessageType,
message.ResendAutomatically, message.ResendAutomatically,
encodedRecipients.Bytes(), encodedRecipients.Bytes(),
message.SkipProtocolLayer, message.SkipEncryptionLayer,
message.SendPushNotification, message.SendPushNotification,
message.SkipGroupMessageWrap, message.SkipGroupMessageWrap,
message.SendOnPersonalTopic, message.SendOnPersonalTopic,
@ -158,7 +158,7 @@ func (db RawMessagesPersistence) rawMessageByID(tx *sql.Tx, id string) (*RawMess
&message.MessageType, &message.MessageType,
&message.ResendAutomatically, &message.ResendAutomatically,
&encodedRecipients, &encodedRecipients,
&message.SkipProtocolLayer, &message.SkipEncryptionLayer,
&message.SendPushNotification, &message.SendPushNotification,
&skipGroupMessageWrap, &skipGroupMessageWrap,
&sendOnPersonalTopic, &sendOnPersonalTopic,

View File

@ -71,7 +71,7 @@ func (ckd *CommunitiesKeyDistributorImpl) distributeKey(community *communities.C
func (ckd *CommunitiesKeyDistributorImpl) sendKeyExchangeMessage(community *communities.Community, hashRatchetGroupID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error { func (ckd *CommunitiesKeyDistributorImpl) sendKeyExchangeMessage(community *communities.Community, hashRatchetGroupID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error {
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Sender: community.PrivateKey(), Sender: community.PrivateKey(),
SkipProtocolLayer: false, SkipEncryptionLayer: false,
CommunityID: community.ID(), CommunityID: community.ID(),
CommunityKeyExMsgType: msgType, CommunityKeyExMsgType: msgType,
Recipients: pubkeys, Recipients: pubkeys,

View File

@ -3269,9 +3269,8 @@ func (s *MessengerCommunitiesSuite) TestCommunityBanUserRequestToJoin() {
messageState.CurrentMessageState.PublicKey = &s.alice.identity.PublicKey messageState.CurrentMessageState.PublicKey = &s.alice.identity.PublicKey
statusMessage := v1protocol.StatusMessage{ statusMessage := v1protocol.StatusMessage{}
Dst: community.PublicKey(), statusMessage.TransportLayer.Dst = community.PublicKey()
}
err = s.owner.HandleCommunityRequestToJoin(messageState, requestToJoinProto, &statusMessage) err = s.owner.HandleCommunityRequestToJoin(messageState, requestToJoinProto, &statusMessage)
s.Require().ErrorContains(err, "can't request access") s.Require().ErrorContains(err, "can't request access")

View File

@ -2104,7 +2104,7 @@ func (m *Messenger) dispatchMessage(ctx context.Context, rawMessage common.RawMe
//SendPrivate will alter message identity and possibly datasyncid, so we save an unchanged //SendPrivate will alter message identity and possibly datasyncid, so we save an unchanged
//message for sending to paired devices later //message for sending to paired devices later
specCopyForPairedDevices := rawMessage specCopyForPairedDevices := rawMessage
if !common.IsPubKeyEqual(publicKey, &m.identity.PublicKey) || rawMessage.SkipProtocolLayer { if !common.IsPubKeyEqual(publicKey, &m.identity.PublicKey) || rawMessage.SkipEncryptionLayer {
id, err = m.sender.SendPrivate(ctx, publicKey, &rawMessage) id, err = m.sender.SendPrivate(ctx, publicKey, &rawMessage)
if err != nil { if err != nil {
@ -3482,14 +3482,14 @@ func (m *Messenger) handleImportedMessages(messagesToHandle map[transport.Filter
} }
for _, msg := range statusMessages { for _, msg := range statusMessages {
logger := logger.With(zap.String("message-id", msg.TransportMessage.ThirdPartyID)) logger := logger.With(zap.String("message-id", msg.TransportLayer.Message.ThirdPartyID))
logger.Debug("processing message") logger.Debug("processing message")
publicKey := msg.SigPubKey() publicKey := msg.SigPubKey()
senderID := contactIDFromPublicKey(publicKey) senderID := contactIDFromPublicKey(publicKey)
// Don't process duplicates // Don't process duplicates
messageID := msg.TransportMessage.ThirdPartyID messageID := msg.TransportLayer.Message.ThirdPartyID
exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap) exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap)
if err != nil { if err != nil {
logger.Warn("failed to check message exists", zap.Error(err)) logger.Warn("failed to check message exists", zap.Error(err))
@ -3513,26 +3513,26 @@ func (m *Messenger) handleImportedMessages(messagesToHandle map[transport.Filter
} }
messageState.CurrentMessageState = &CurrentMessageState{ messageState.CurrentMessageState = &CurrentMessageState{
MessageID: messageID, MessageID: messageID,
WhisperTimestamp: uint64(msg.TransportMessage.Timestamp) * 1000, WhisperTimestamp: uint64(msg.TransportLayer.Message.Timestamp) * 1000,
Contact: contact, Contact: contact,
PublicKey: publicKey, PublicKey: publicKey,
} }
if msg.UnwrappedPayload != nil { if msg.ApplicationLayer.Payload != nil {
logger.Debug("Handling parsed message") logger.Debug("Handling parsed message")
switch msg.Type { switch msg.ApplicationLayer.Type {
case protobuf.ApplicationMetadataMessage_CHAT_MESSAGE: case protobuf.ApplicationMetadataMessage_CHAT_MESSAGE:
err = m.handleChatMessageProtobuf(messageState, msg.UnwrappedPayload, msg, filter, true) err = m.handleChatMessageProtobuf(messageState, msg.ApplicationLayer.Payload, msg, filter, true)
if err != nil { if err != nil {
logger.Warn("failed to handle ChatMessage", zap.Error(err)) logger.Warn("failed to handle ChatMessage", zap.Error(err))
continue continue
} }
case protobuf.ApplicationMetadataMessage_PIN_MESSAGE: case protobuf.ApplicationMetadataMessage_PIN_MESSAGE:
err = m.handlePinMessageProtobuf(messageState, msg.UnwrappedPayload, msg, filter, true) err = m.handlePinMessageProtobuf(messageState, msg.ApplicationLayer.Payload, msg, filter, true)
if err != nil { if err != nil {
logger.Warn("failed to handle PinMessage", zap.Error(err)) logger.Warn("failed to handle PinMessage", zap.Error(err))
} }
@ -3644,12 +3644,12 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
logger.Debug("processing messages further", zap.Int("count", len(statusMessages))) logger.Debug("processing messages further", zap.Int("count", len(statusMessages)))
for _, msg := range statusMessages { for _, msg := range statusMessages {
logger := logger.With(zap.String("message-id", msg.ID.String())) logger := logger.With(zap.String("message-id", msg.ApplicationLayer.ID.String()))
logger.Info("processing message") logger.Info("processing message")
publicKey := msg.SigPubKey() publicKey := msg.SigPubKey()
m.handleInstallations(msg.Installations) m.handleInstallations(msg.EncryptionLayer.Installations)
err := m.handleSharedSecrets(msg.SharedSecrets) err := m.handleSharedSecrets(msg.EncryptionLayer.SharedSecrets)
if err != nil { if err != nil {
// log and continue, non-critical error // log and continue, non-critical error
logger.Warn("failed to handle shared secrets") logger.Warn("failed to handle shared secrets")
@ -3657,11 +3657,11 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
senderID := contactIDFromPublicKey(publicKey) senderID := contactIDFromPublicKey(publicKey)
ownID := contactIDFromPublicKey(m.IdentityPublicKey()) ownID := contactIDFromPublicKey(m.IdentityPublicKey())
m.logger.Info("processing message", zap.Any("type", msg.Type), zap.String("senderID", senderID)) m.logger.Info("processing message", zap.Any("type", msg.ApplicationLayer.Type), zap.String("senderID", senderID))
if senderID == ownID { if senderID == ownID {
// Skip own messages of certain types // Skip own messages of certain types
if msg.Type == protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT { if msg.ApplicationLayer.Type == protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT {
continue continue
} }
} }
@ -3676,7 +3676,7 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
} }
// Don't process duplicates // Don't process duplicates
messageID := types.EncodeHex(msg.ID) messageID := types.EncodeHex(msg.ApplicationLayer.ID)
exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap) exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap)
if err != nil { if err != nil {
logger.Warn("failed to check message exists", zap.Error(err)) logger.Warn("failed to check message exists", zap.Error(err))
@ -3694,21 +3694,21 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
continue continue
} }
contact = c contact = c
if msg.Type != protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY { if msg.ApplicationLayer.Type != protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY {
messageState.AllContacts.Store(senderID, contact) messageState.AllContacts.Store(senderID, contact)
m.forgetContactInfoRequest(senderID) m.forgetContactInfoRequest(senderID)
} }
} }
messageState.CurrentMessageState = &CurrentMessageState{ messageState.CurrentMessageState = &CurrentMessageState{
MessageID: messageID, MessageID: messageID,
WhisperTimestamp: uint64(msg.TransportMessage.Timestamp) * 1000, WhisperTimestamp: uint64(msg.TransportLayer.Message.Timestamp) * 1000,
Contact: contact, Contact: contact,
PublicKey: publicKey, PublicKey: publicKey,
} }
if msg.UnwrappedPayload != nil { if msg.ApplicationLayer.Payload != nil {
err := m.dispatchToHandler(messageState, msg.UnwrappedPayload, msg, filter, fromArchive) err := m.dispatchToHandler(messageState, msg.ApplicationLayer.Payload, msg, filter, fromArchive)
if err != nil { if err != nil {
allMessagesProcessed = false allMessagesProcessed = false
logger.Warn("failed to process protobuf", zap.Error(err)) logger.Warn("failed to process protobuf", zap.Error(err))

View File

@ -248,7 +248,7 @@ func (m *Messenger) encodeAndDispatchBackupMessage(ctx context.Context, message
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chatID, LocalChatID: chatID,
Payload: encodedMessage, Payload: encodedMessage,
SkipProtocolLayer: true, SkipEncryptionLayer: true,
SendOnPersonalTopic: true, SendOnPersonalTopic: true,
MessageType: protobuf.ApplicationMetadataMessage_BACKUP, MessageType: protobuf.ApplicationMetadataMessage_BACKUP,
}) })

View File

@ -111,9 +111,9 @@ func (m *Messenger) publishOrg(org *communities.Community) error {
Payload: payload, Payload: payload,
Sender: org.PrivateKey(), Sender: org.PrivateKey(),
// we don't want to wrap in an encryption layer message // we don't want to wrap in an encryption layer message
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
PubsubTopic: org.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic PubsubTopic: org.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic
} }
_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage) _, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
return err return err
@ -131,9 +131,9 @@ func (m *Messenger) publishCommunityEvents(community *communities.Community, msg
Payload: payload, Payload: payload,
Sender: m.identity, Sender: m.identity,
// we don't want to wrap in an encryption layer message // we don't want to wrap in an encryption layer message
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EVENTS_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EVENTS_MESSAGE,
PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic
} }
// TODO: resend in case of failure? // TODO: resend in case of failure?
@ -161,9 +161,9 @@ func (m *Messenger) publishCommunityEventsRejected(community *communities.Commun
Payload: payload, Payload: payload,
Sender: community.PrivateKey(), Sender: community.PrivateKey(),
// we don't want to wrap in an encryption layer message // we don't want to wrap in an encryption layer message
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EVENTS_MESSAGE_REJECTED, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EVENTS_MESSAGE_REJECTED,
PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic
} }
// TODO: resend in case of failure? // TODO: resend in case of failure?
@ -181,10 +181,10 @@ func (m *Messenger) publishCommunityPrivilegedMemberSyncMessage(msg *communities
} }
rawMessage := &common.RawMessage{ rawMessage := &common.RawMessage{
Payload: payload, Payload: payload,
Sender: msg.CommunityPrivateKey, // if empty, sender private key will be used in SendPrivate Sender: msg.CommunityPrivateKey, // if empty, sender private key will be used in SendPrivate
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_PRIVILEGED_USER_SYNC_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_PRIVILEGED_USER_SYNC_MESSAGE,
} }
for _, receivers := range msg.Receivers { for _, receivers := range msg.Receivers {
@ -1205,11 +1205,11 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun
} }
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: payload, Payload: payload,
CommunityID: community.ID(), CommunityID: community.ID(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()), PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
} }
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage) _, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
@ -1360,11 +1360,11 @@ func (m *Messenger) EditSharedAddressesForCommunity(request *requests.EditShared
} }
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: payload, Payload: payload,
CommunityID: community.ID(), CommunityID: community.ID(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EDIT_SHARED_ADDRESSES, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_EDIT_SHARED_ADDRESSES,
PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic
} }
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage) _, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
@ -1524,11 +1524,11 @@ func (m *Messenger) CancelRequestToJoinCommunity(ctx context.Context, request *r
} }
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: payload, Payload: payload,
CommunityID: community.ID(), CommunityID: community.ID(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()), PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
} }
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage) _, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
@ -1631,11 +1631,11 @@ func (m *Messenger) acceptRequestToJoinCommunity(requestToJoin *communities.Requ
} }
rawMessage := &common.RawMessage{ rawMessage := &common.RawMessage{
Payload: payload, Payload: payload,
Sender: community.PrivateKey(), Sender: community.PrivateKey(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()), PubsubTopic: common.DefaultNonProtectedPubsubTopic(community.Shard()),
} }
_, err = m.sender.SendPrivate(context.Background(), pk, rawMessage) _, err = m.sender.SendPrivate(context.Background(), pk, rawMessage)
@ -1710,10 +1710,10 @@ func (m *Messenger) declineRequestToJoinCommunity(requestToJoin *communities.Req
} }
rawSyncMessage := &common.RawMessage{ rawSyncMessage := &common.RawMessage{
Payload: payloadSyncMsg, Payload: payloadSyncMsg,
Sender: community.PrivateKey(), Sender: community.PrivateKey(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_PRIVILEGED_USER_SYNC_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_PRIVILEGED_USER_SYNC_MESSAGE,
} }
privilegedMembers := community.GetPrivilegedMembers() privilegedMembers := community.GetPrivilegedMembers()
@ -1814,11 +1814,11 @@ func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerRespon
} }
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: payload, Payload: payload,
CommunityID: communityID, CommunityID: communityID,
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in the community pubsub topic PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in the community pubsub topic
} }
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage) _, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
if err != nil { if err != nil {
@ -3233,11 +3233,11 @@ func (m *Messenger) sendSharedAddressToControlNode(receiver *ecdsa.PublicKey, co
} }
rawMessage := common.RawMessage{ rawMessage := common.RawMessage{
Payload: payload, Payload: payload,
CommunityID: community.ID(), CommunityID: community.ID(),
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN, MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic PubsubTopic: community.PubsubTopic(), // TODO: confirm if it should be sent in community pubsub topic
} }
if err = m.communitiesManager.SaveRequestToJoin(requestToJoin); err != nil { if err = m.communitiesManager.SaveRequestToJoin(requestToJoin); err != nil {

View File

@ -1478,7 +1478,7 @@ func (m *Messenger) HandleCommunityCancelRequestToJoin(state *ReceivedMessageSta
// HandleCommunityRequestToJoin handles an community request to join // HandleCommunityRequestToJoin handles an community request to join
func (m *Messenger) HandleCommunityRequestToJoin(state *ReceivedMessageState, requestToJoinProto *protobuf.CommunityRequestToJoin, statusMessage *v1protocol.StatusMessage) error { func (m *Messenger) HandleCommunityRequestToJoin(state *ReceivedMessageState, requestToJoinProto *protobuf.CommunityRequestToJoin, statusMessage *v1protocol.StatusMessage) error {
signer := state.CurrentMessageState.PublicKey signer := state.CurrentMessageState.PublicKey
community, requestToJoin, err := m.communitiesManager.HandleCommunityRequestToJoin(signer, statusMessage.Dst, requestToJoinProto) community, requestToJoin, err := m.communitiesManager.HandleCommunityRequestToJoin(signer, statusMessage.TransportLayer.Dst, requestToJoinProto)
if err != nil { if err != nil {
return err return err
} }
@ -3557,7 +3557,7 @@ func (m *Messenger) HandlePushNotificationQuery(state *ReceivedMessageState, mes
} }
publicKey := state.CurrentMessageState.PublicKey publicKey := state.CurrentMessageState.PublicKey
return m.pushNotificationServer.HandlePushNotificationQuery(publicKey, statusMessage.ID, message) return m.pushNotificationServer.HandlePushNotificationQuery(publicKey, statusMessage.ApplicationLayer.ID, message)
} }
func (m *Messenger) HandlePushNotificationQueryResponse(state *ReceivedMessageState, message *protobuf.PushNotificationQueryResponse, statusMessage *v1protocol.StatusMessage) error { func (m *Messenger) HandlePushNotificationQueryResponse(state *ReceivedMessageState, message *protobuf.PushNotificationQueryResponse, statusMessage *v1protocol.StatusMessage) error {
@ -3575,12 +3575,12 @@ func (m *Messenger) HandlePushNotificationRequest(state *ReceivedMessageState, m
} }
publicKey := state.CurrentMessageState.PublicKey publicKey := state.CurrentMessageState.PublicKey
return m.pushNotificationServer.HandlePushNotificationRequest(publicKey, statusMessage.ID, message) return m.pushNotificationServer.HandlePushNotificationRequest(publicKey, statusMessage.ApplicationLayer.ID, message)
} }
func (m *Messenger) HandleCommunityDescription(state *ReceivedMessageState, message *protobuf.CommunityDescription, statusMessage *v1protocol.StatusMessage) error { func (m *Messenger) HandleCommunityDescription(state *ReceivedMessageState, message *protobuf.CommunityDescription, statusMessage *v1protocol.StatusMessage) error {
err := m.handleCommunityDescription(state, state.CurrentMessageState.PublicKey, message, statusMessage.DecryptedPayload) err := m.handleCommunityDescription(state, state.CurrentMessageState.PublicKey, message, statusMessage.EncryptionLayer.Payload)
if err != nil { if err != nil {
m.logger.Warn("failed to handle CommunityDescription", zap.Error(err)) m.logger.Warn("failed to handle CommunityDescription", zap.Error(err))
return err return err

View File

@ -1,6 +1,6 @@
//nolint //nolint
// Code generated by generate_handlers.go. DO NOT EDIT. // Code generated by generate_handlers.go. DO NOT EDIT.
// source: geneate_handlers.go // source: generate_handlers.go
package protocol package protocol
@ -17,7 +17,7 @@ import (
) )
func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter, fromArchive bool) error { func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoBytes []byte, msg *v1protocol.StatusMessage, filter transport.Filter, fromArchive bool) error {
switch msg.Type { switch msg.ApplicationLayer.Type {
case protobuf.ApplicationMetadataMessage_CHAT_MESSAGE: case protobuf.ApplicationMetadataMessage_CHAT_MESSAGE:
return m.handleChatMessageProtobuf(messageState, protoBytes, msg, filter, fromArchive) return m.handleChatMessageProtobuf(messageState, protoBytes, msg, filter, fromArchive)
@ -233,7 +233,7 @@ func (m *Messenger) dispatchToHandler(messageState *ReceivedMessageState, protoB
return m.handleSyncActivityCenterCommunityRequestDecisionProtobuf(messageState, protoBytes, msg, filter) return m.handleSyncActivityCenterCommunityRequestDecisionProtobuf(messageState, protoBytes, msg, filter)
default: default:
m.logger.Info("protobuf type not found", zap.String("type", string(msg.Type))) m.logger.Info("protobuf type not found", zap.String("type", string(msg.ApplicationLayer.Type)))
return errors.New("protobuf type not found") return errors.New("protobuf type not found")
} }
return nil return nil
@ -251,7 +251,7 @@ func (m *Messenger) handleChatMessageProtobuf(messageState *ReceivedMessageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleChatMessage(messageState, p, msg, fromArchive ) return m.HandleChatMessage(messageState, p, msg, fromArchive )
@ -269,7 +269,7 @@ func (m *Messenger) handleContactUpdateProtobuf(messageState *ReceivedMessageSta
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleContactUpdate(messageState, p, msg) return m.HandleContactUpdate(messageState, p, msg)
@ -287,7 +287,7 @@ func (m *Messenger) handleMembershipUpdateMessageProtobuf(messageState *Received
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleMembershipUpdateMessage(messageState, p, msg) return m.HandleMembershipUpdateMessage(messageState, p, msg)
@ -310,7 +310,7 @@ func (m *Messenger) handleSyncPairInstallationProtobuf(messageState *ReceivedMes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncPairInstallation(messageState, p, msg) return m.HandleSyncPairInstallation(messageState, p, msg)
@ -328,7 +328,7 @@ func (m *Messenger) handleRequestAddressForTransactionProtobuf(messageState *Rec
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleRequestAddressForTransaction(messageState, p, msg) return m.HandleRequestAddressForTransaction(messageState, p, msg)
@ -346,7 +346,7 @@ func (m *Messenger) handleAcceptRequestAddressForTransactionProtobuf(messageStat
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleAcceptRequestAddressForTransaction(messageState, p, msg) return m.HandleAcceptRequestAddressForTransaction(messageState, p, msg)
@ -364,7 +364,7 @@ func (m *Messenger) handleDeclineRequestAddressForTransactionProtobuf(messageSta
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleDeclineRequestAddressForTransaction(messageState, p, msg) return m.HandleDeclineRequestAddressForTransaction(messageState, p, msg)
@ -382,7 +382,7 @@ func (m *Messenger) handleRequestTransactionProtobuf(messageState *ReceivedMessa
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleRequestTransaction(messageState, p, msg) return m.HandleRequestTransaction(messageState, p, msg)
@ -400,7 +400,7 @@ func (m *Messenger) handleSendTransactionProtobuf(messageState *ReceivedMessageS
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSendTransaction(messageState, p, msg) return m.HandleSendTransaction(messageState, p, msg)
@ -418,7 +418,7 @@ func (m *Messenger) handleDeclineRequestTransactionProtobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleDeclineRequestTransaction(messageState, p, msg) return m.HandleDeclineRequestTransaction(messageState, p, msg)
@ -441,7 +441,7 @@ func (m *Messenger) handleSyncInstallationContactV2Protobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncInstallationContactV2(messageState, p, msg) return m.HandleSyncInstallationContactV2(messageState, p, msg)
@ -464,7 +464,7 @@ func (m *Messenger) handleSyncInstallationAccountProtobuf(messageState *Received
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncInstallationAccount(messageState, p, msg) return m.HandleSyncInstallationAccount(messageState, p, msg)
@ -482,7 +482,7 @@ func (m *Messenger) handleContactCodeAdvertisementProtobuf(messageState *Receive
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleContactCodeAdvertisement(messageState, p, msg) return m.HandleContactCodeAdvertisement(messageState, p, msg)
@ -510,7 +510,7 @@ func (m *Messenger) handlePushNotificationRegistrationResponseProtobuf(messageSt
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePushNotificationRegistrationResponse(messageState, p, msg) return m.HandlePushNotificationRegistrationResponse(messageState, p, msg)
@ -528,7 +528,7 @@ func (m *Messenger) handlePushNotificationQueryProtobuf(messageState *ReceivedMe
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePushNotificationQuery(messageState, p, msg) return m.HandlePushNotificationQuery(messageState, p, msg)
@ -546,7 +546,7 @@ func (m *Messenger) handlePushNotificationQueryResponseProtobuf(messageState *Re
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePushNotificationQueryResponse(messageState, p, msg) return m.HandlePushNotificationQueryResponse(messageState, p, msg)
@ -564,7 +564,7 @@ func (m *Messenger) handlePushNotificationRequestProtobuf(messageState *Received
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePushNotificationRequest(messageState, p, msg) return m.HandlePushNotificationRequest(messageState, p, msg)
@ -582,7 +582,7 @@ func (m *Messenger) handlePushNotificationResponseProtobuf(messageState *Receive
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePushNotificationResponse(messageState, p, msg) return m.HandlePushNotificationResponse(messageState, p, msg)
@ -600,7 +600,7 @@ func (m *Messenger) handleEmojiReactionProtobuf(messageState *ReceivedMessageSta
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleEmojiReaction(messageState, p, msg) return m.HandleEmojiReaction(messageState, p, msg)
@ -618,7 +618,7 @@ func (m *Messenger) handleGroupChatInvitationProtobuf(messageState *ReceivedMess
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleGroupChatInvitation(messageState, p, msg) return m.HandleGroupChatInvitation(messageState, p, msg)
@ -636,7 +636,7 @@ func (m *Messenger) handleChatIdentityProtobuf(messageState *ReceivedMessageStat
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleChatIdentity(messageState, p, msg) return m.HandleChatIdentity(messageState, p, msg)
@ -654,7 +654,7 @@ func (m *Messenger) handleCommunityDescriptionProtobuf(messageState *ReceivedMes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityDescription(messageState, p, msg) return m.HandleCommunityDescription(messageState, p, msg)
@ -672,7 +672,7 @@ func (m *Messenger) handleCommunityRequestToJoinProtobuf(messageState *ReceivedM
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityRequestToJoin(messageState, p, msg) return m.HandleCommunityRequestToJoin(messageState, p, msg)
@ -690,7 +690,7 @@ func (m *Messenger) handlePinMessageProtobuf(messageState *ReceivedMessageState,
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandlePinMessage(messageState, p, msg, fromArchive ) return m.HandlePinMessage(messageState, p, msg, fromArchive )
@ -708,7 +708,7 @@ func (m *Messenger) handleEditMessageProtobuf(messageState *ReceivedMessageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleEditMessage(messageState, p, msg) return m.HandleEditMessage(messageState, p, msg)
@ -726,7 +726,7 @@ func (m *Messenger) handleStatusUpdateProtobuf(messageState *ReceivedMessageStat
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleStatusUpdate(messageState, p, msg) return m.HandleStatusUpdate(messageState, p, msg)
@ -744,7 +744,7 @@ func (m *Messenger) handleDeleteMessageProtobuf(messageState *ReceivedMessageSta
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleDeleteMessage(messageState, p, msg) return m.HandleDeleteMessage(messageState, p, msg)
@ -767,7 +767,7 @@ func (m *Messenger) handleSyncInstallationCommunityProtobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncInstallationCommunity(messageState, p, msg) return m.HandleSyncInstallationCommunity(messageState, p, msg)
@ -785,7 +785,7 @@ func (m *Messenger) handleAnonymousMetricBatchProtobuf(messageState *ReceivedMes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleAnonymousMetricBatch(messageState, p, msg) return m.HandleAnonymousMetricBatch(messageState, p, msg)
@ -808,7 +808,7 @@ func (m *Messenger) handleSyncChatRemovedProtobuf(messageState *ReceivedMessageS
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncChatRemoved(messageState, p, msg) return m.HandleSyncChatRemoved(messageState, p, msg)
@ -831,7 +831,7 @@ func (m *Messenger) handleSyncChatMessagesReadProtobuf(messageState *ReceivedMes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncChatMessagesRead(messageState, p, msg) return m.HandleSyncChatMessagesRead(messageState, p, msg)
@ -849,7 +849,7 @@ func (m *Messenger) handleBackupProtobuf(messageState *ReceivedMessageState, pro
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleBackup(messageState, p, msg) return m.HandleBackup(messageState, p, msg)
@ -872,7 +872,7 @@ func (m *Messenger) handleSyncActivityCenterReadProtobuf(messageState *ReceivedM
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterRead(messageState, p, msg) return m.HandleSyncActivityCenterRead(messageState, p, msg)
@ -895,7 +895,7 @@ func (m *Messenger) handleSyncActivityCenterAcceptedProtobuf(messageState *Recei
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterAccepted(messageState, p, msg) return m.HandleSyncActivityCenterAccepted(messageState, p, msg)
@ -918,7 +918,7 @@ func (m *Messenger) handleSyncActivityCenterDismissedProtobuf(messageState *Rece
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterDismissed(messageState, p, msg) return m.HandleSyncActivityCenterDismissed(messageState, p, msg)
@ -941,7 +941,7 @@ func (m *Messenger) handleSyncBookmarkProtobuf(messageState *ReceivedMessageStat
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncBookmark(messageState, p, msg) return m.HandleSyncBookmark(messageState, p, msg)
@ -964,7 +964,7 @@ func (m *Messenger) handleSyncClearHistoryProtobuf(messageState *ReceivedMessage
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncClearHistory(messageState, p, msg) return m.HandleSyncClearHistory(messageState, p, msg)
@ -987,7 +987,7 @@ func (m *Messenger) handleSyncSettingProtobuf(messageState *ReceivedMessageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncSetting(messageState, p, msg) return m.HandleSyncSetting(messageState, p, msg)
@ -1005,7 +1005,7 @@ func (m *Messenger) handleCommunityMessageArchiveMagnetlinkProtobuf(messageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityMessageArchiveMagnetlink(messageState, p, msg) return m.HandleCommunityMessageArchiveMagnetlink(messageState, p, msg)
@ -1028,7 +1028,7 @@ func (m *Messenger) handleSyncProfilePicturesProtobuf(messageState *ReceivedMess
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncProfilePictures(messageState, p, msg) return m.HandleSyncProfilePictures(messageState, p, msg)
@ -1051,7 +1051,7 @@ func (m *Messenger) handleSyncAccountProtobuf(messageState *ReceivedMessageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncAccount(messageState, p, msg) return m.HandleSyncAccount(messageState, p, msg)
@ -1069,7 +1069,7 @@ func (m *Messenger) handleAcceptContactRequestProtobuf(messageState *ReceivedMes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleAcceptContactRequest(messageState, p, msg) return m.HandleAcceptContactRequest(messageState, p, msg)
@ -1087,7 +1087,7 @@ func (m *Messenger) handleRetractContactRequestProtobuf(messageState *ReceivedMe
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleRetractContactRequest(messageState, p, msg) return m.HandleRetractContactRequest(messageState, p, msg)
@ -1105,7 +1105,7 @@ func (m *Messenger) handleCommunityRequestToJoinResponseProtobuf(messageState *R
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityRequestToJoinResponse(messageState, p, msg) return m.HandleCommunityRequestToJoinResponse(messageState, p, msg)
@ -1128,7 +1128,7 @@ func (m *Messenger) handleSyncCommunitySettingsProtobuf(messageState *ReceivedMe
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncCommunitySettings(messageState, p, msg) return m.HandleSyncCommunitySettings(messageState, p, msg)
@ -1146,7 +1146,7 @@ func (m *Messenger) handleRequestContactVerificationProtobuf(messageState *Recei
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleRequestContactVerification(messageState, p, msg) return m.HandleRequestContactVerification(messageState, p, msg)
@ -1164,7 +1164,7 @@ func (m *Messenger) handleAcceptContactVerificationProtobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleAcceptContactVerification(messageState, p, msg) return m.HandleAcceptContactVerification(messageState, p, msg)
@ -1182,7 +1182,7 @@ func (m *Messenger) handleDeclineContactVerificationProtobuf(messageState *Recei
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleDeclineContactVerification(messageState, p, msg) return m.HandleDeclineContactVerification(messageState, p, msg)
@ -1205,7 +1205,7 @@ func (m *Messenger) handleSyncTrustedUserProtobuf(messageState *ReceivedMessageS
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncTrustedUser(messageState, p, msg) return m.HandleSyncTrustedUser(messageState, p, msg)
@ -1228,7 +1228,7 @@ func (m *Messenger) handleSyncVerificationRequestProtobuf(messageState *Received
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncVerificationRequest(messageState, p, msg) return m.HandleSyncVerificationRequest(messageState, p, msg)
@ -1251,7 +1251,7 @@ func (m *Messenger) handleSyncContactRequestDecisionProtobuf(messageState *Recei
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncContactRequestDecision(messageState, p, msg) return m.HandleSyncContactRequestDecision(messageState, p, msg)
@ -1269,7 +1269,7 @@ func (m *Messenger) handleCommunityRequestToLeaveProtobuf(messageState *Received
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityRequestToLeave(messageState, p, msg) return m.HandleCommunityRequestToLeave(messageState, p, msg)
@ -1292,7 +1292,7 @@ func (m *Messenger) handleSyncDeleteForMeMessageProtobuf(messageState *ReceivedM
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncDeleteForMeMessage(messageState, p, msg) return m.HandleSyncDeleteForMeMessage(messageState, p, msg)
@ -1315,7 +1315,7 @@ func (m *Messenger) handleSyncSavedAddressProtobuf(messageState *ReceivedMessage
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncSavedAddress(messageState, p, msg) return m.HandleSyncSavedAddress(messageState, p, msg)
@ -1333,7 +1333,7 @@ func (m *Messenger) handleCommunityCancelRequestToJoinProtobuf(messageState *Rec
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityCancelRequestToJoin(messageState, p, msg) return m.HandleCommunityCancelRequestToJoin(messageState, p, msg)
@ -1351,7 +1351,7 @@ func (m *Messenger) handleCancelContactVerificationProtobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCancelContactVerification(messageState, p, msg) return m.HandleCancelContactVerification(messageState, p, msg)
@ -1374,7 +1374,7 @@ func (m *Messenger) handleSyncKeypairProtobuf(messageState *ReceivedMessageState
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncKeypair(messageState, p, msg) return m.HandleSyncKeypair(messageState, p, msg)
@ -1397,7 +1397,7 @@ func (m *Messenger) handleSyncSocialLinksProtobuf(messageState *ReceivedMessageS
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncSocialLinks(messageState, p, msg) return m.HandleSyncSocialLinks(messageState, p, msg)
@ -1420,7 +1420,7 @@ func (m *Messenger) handleSyncEnsUsernameDetailProtobuf(messageState *ReceivedMe
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncEnsUsernameDetail(messageState, p, msg) return m.HandleSyncEnsUsernameDetail(messageState, p, msg)
@ -1438,7 +1438,7 @@ func (m *Messenger) handleCommunityEventsMessageProtobuf(messageState *ReceivedM
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityEventsMessage(messageState, p, msg) return m.HandleCommunityEventsMessage(messageState, p, msg)
@ -1456,7 +1456,7 @@ func (m *Messenger) handleCommunityEditSharedAddressesProtobuf(messageState *Rec
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityEditSharedAddresses(messageState, p, msg) return m.HandleCommunityEditSharedAddresses(messageState, p, msg)
@ -1479,7 +1479,7 @@ func (m *Messenger) handleSyncAccountCustomizationColorProtobuf(messageState *Re
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncAccountCustomizationColor(messageState, p, msg) return m.HandleSyncAccountCustomizationColor(messageState, p, msg)
@ -1502,7 +1502,7 @@ func (m *Messenger) handleSyncAccountsPositionsProtobuf(messageState *ReceivedMe
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncAccountsPositions(messageState, p, msg) return m.HandleSyncAccountsPositions(messageState, p, msg)
@ -1520,7 +1520,7 @@ func (m *Messenger) handleCommunityEventsMessageRejectedProtobuf(messageState *R
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityEventsMessageRejected(messageState, p, msg) return m.HandleCommunityEventsMessageRejected(messageState, p, msg)
@ -1538,7 +1538,7 @@ func (m *Messenger) handleCommunityPrivilegedUserSyncMessageProtobuf(messageStat
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityPrivilegedUserSyncMessage(messageState, p, msg) return m.HandleCommunityPrivilegedUserSyncMessage(messageState, p, msg)
@ -1556,7 +1556,7 @@ func (m *Messenger) handleCommunityShardKeyProtobuf(messageState *ReceivedMessag
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleCommunityShardKey(messageState, p, msg) return m.HandleCommunityShardKey(messageState, p, msg)
@ -1579,7 +1579,7 @@ func (m *Messenger) handleSyncChatProtobuf(messageState *ReceivedMessageState, p
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncChat(messageState, p, msg) return m.HandleSyncChat(messageState, p, msg)
@ -1602,7 +1602,7 @@ func (m *Messenger) handleSyncActivityCenterDeletedProtobuf(messageState *Receiv
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterDeleted(messageState, p, msg) return m.HandleSyncActivityCenterDeleted(messageState, p, msg)
@ -1625,7 +1625,7 @@ func (m *Messenger) handleSyncActivityCenterUnreadProtobuf(messageState *Receive
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterUnread(messageState, p, msg) return m.HandleSyncActivityCenterUnread(messageState, p, msg)
@ -1648,7 +1648,7 @@ func (m *Messenger) handleSyncActivityCenterCommunityRequestDecisionProtobuf(mes
return err return err
} }
m.outputToCSV(msg.TransportMessage.Timestamp, msg.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.Type, p) m.outputToCSV(msg.TransportLayer.Message.Timestamp, msg.ApplicationLayer.ID, messageState.CurrentMessageState.Contact.ID, filter.ContentTopic, filter.ChatID, msg.ApplicationLayer.Type, p)
return m.HandleSyncActivityCenterCommunityRequestDecision(messageState, p, msg) return m.HandleSyncActivityCenterCommunityRequestDecision(messageState, p, msg)

View File

@ -1309,7 +1309,7 @@ func (c *Client) registerWithServer(registration *protobuf.PushNotificationRegis
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION,
// We send on personal topic to avoid a lot of traffic on the partitioned topic // We send on personal topic to avoid a lot of traffic on the partitioned topic
SendOnPersonalTopic: true, SendOnPersonalTopic: true,
SkipProtocolLayer: true, SkipEncryptionLayer: true,
} }
_, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage) _, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage)
@ -1417,8 +1417,8 @@ func (c *Client) SendNotification(publicKey *ecdsa.PublicKey, installationIDs []
Sender: ephemeralKey, Sender: ephemeralKey,
// we skip encryption as we don't want to save any key material // we skip encryption as we don't want to save any key material
// for an ephemeral key, no need to use pfs as these are throw away keys // for an ephemeral key, no need to use pfs as these are throw away keys
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
} }
_, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage) _, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage)
@ -1697,8 +1697,8 @@ func (c *Client) queryPushNotificationInfo(publicKey *ecdsa.PublicKey) error {
Payload: encodedMessage, Payload: encodedMessage,
Sender: ephemeralKey, Sender: ephemeralKey,
// we don't want to wrap in an encryption layer message // we don't want to wrap in an encryption layer message
SkipProtocolLayer: true, SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
} }
_, err = c.messageSender.AddEphemeralKey(ephemeralKey) _, err = c.messageSender.AddEphemeralKey(ephemeralKey)

View File

@ -109,7 +109,7 @@ func (s *Server) HandlePushNotificationRegistration(publicKey *ecdsa.PublicKey,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE,
// we skip encryption as might be sent from an ephemeral key // we skip encryption as might be sent from an ephemeral key
SkipProtocolLayer: true, SkipEncryptionLayer: true,
} }
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage) _, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
@ -136,7 +136,7 @@ func (s *Server) HandlePushNotificationQuery(publicKey *ecdsa.PublicKey, message
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE,
// we skip encryption as sent from an ephemeral key // we skip encryption as sent from an ephemeral key
SkipProtocolLayer: true, SkipEncryptionLayer: true,
} }
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage) _, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
@ -179,7 +179,7 @@ func (s *Server) HandlePushNotificationRequest(publicKey *ecdsa.PublicKey,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE, MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE,
// We skip encryption here as the message has been sent from an ephemeral key // We skip encryption here as the message has been sent from an ephemeral key
SkipProtocolLayer: true, SkipEncryptionLayer: true,
} }
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage) _, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)

View File

@ -18,44 +18,43 @@ import (
"github.com/status-im/status-go/protocol/protobuf" "github.com/status-im/status-go/protocol/protobuf"
) )
type StatusMessageT int // TransportLayer is the lowest layer and represents waku message.
type TransportLayer struct {
// Payload as received from the transport layer
Payload []byte `json:"-"`
Hash []byte `json:"-"`
SigPubKey *ecdsa.PublicKey `json:"-"`
Dst *ecdsa.PublicKey
Message *types.Message `json:"message"`
}
// StatusMessage is any Status Protocol message. // EncryptionLayer handles optional encryption.
type StatusMessage struct { // It is not mandatory and can be omitted,
// TransportMessage is the parsed message received from the transport layer, i.e the input // also its presence does not guarantee encryption.
TransportMessage *types.Message `json:"transportMessage"` type EncryptionLayer struct {
// Type is the type of application message contained // Payload after having been processed by the encryption layer
Type protobuf.ApplicationMetadataMessage_Type `json:"-"` Payload []byte `json:"-"`
Installations []*multidevice.Installation
// TransportPayload is the payload as received from the transport layer SharedSecrets []*sharedsecret.Secret
TransportPayload []byte `json:"-"`
// DecryptedPayload is the payload after having been processed by the encryption layer
DecryptedPayload []byte `json:"decryptedPayload"`
// UnwrappedPayload is the payload after having been unwrapped from the applicaition metadata layer
UnwrappedPayload []byte `json:"unwrappedPayload"`
// ID is the canonical ID of the message
ID types.HexBytes `json:"id"`
// Hash is the transport layer hash
Hash []byte `json:"-"`
// Dst is the targeted public key
Dst *ecdsa.PublicKey
// TransportLayerSigPubKey contains the public key provided by the transport layer
TransportLayerSigPubKey *ecdsa.PublicKey `json:"-"`
// ApplicationMetadataLayerPubKey contains the public key provided by the application metadata layer
ApplicationMetadataLayerSigPubKey *ecdsa.PublicKey `json:"-"`
// Installations is the new installations returned by the encryption layer
Installations []*multidevice.Installation
// SharedSecret is the shared secret returned by the encryption layer
SharedSecrets []*sharedsecret.Secret
// HashRatchetInfo is the information about a new hash ratchet group/key pair
HashRatchetInfo []*encryption.HashRatchetInfo HashRatchetInfo []*encryption.HashRatchetInfo
} }
// ApplicationLayer is the topmost layer and represents the application message.
type ApplicationLayer struct {
// Payload after having been unwrapped from the application layer
Payload []byte `json:"-"`
ID types.HexBytes `json:"id"`
SigPubKey *ecdsa.PublicKey `json:"-"`
Type protobuf.ApplicationMetadataMessage_Type `json:"-"`
}
// StatusMessage encapsulates all layers of the protocol
type StatusMessage struct {
TransportLayer TransportLayer `json:"transportLayer"`
EncryptionLayer EncryptionLayer `json:"encryptionLayer"`
ApplicationLayer ApplicationLayer `json:"applicationLayer"`
}
// Temporary JSON marshaling for those messages that are not yet processed // Temporary JSON marshaling for those messages that are not yet processed
// by the go code // by the go code
func (m *StatusMessage) MarshalJSON() ([]byte, error) { func (m *StatusMessage) MarshalJSON() ([]byte, error) {
@ -65,21 +64,21 @@ func (m *StatusMessage) MarshalJSON() ([]byte, error) {
From types.HexBytes `json:"from"` From types.HexBytes `json:"from"`
Timestamp uint32 `json:"timestamp"` Timestamp uint32 `json:"timestamp"`
}{ }{
ID: m.ID, ID: m.ApplicationLayer.ID,
Payload: string(m.UnwrappedPayload), Payload: string(m.ApplicationLayer.Payload),
Timestamp: m.TransportMessage.Timestamp, Timestamp: m.TransportLayer.Message.Timestamp,
From: m.TransportMessage.Sig, From: m.TransportLayer.Message.Sig,
} }
return json.Marshal(item) return json.Marshal(item)
} }
// SigPubKey returns the most important signature, from the application layer to transport // SigPubKey returns the most important signature, from the application layer to transport
func (m *StatusMessage) SigPubKey() *ecdsa.PublicKey { func (m *StatusMessage) SigPubKey() *ecdsa.PublicKey {
if m.ApplicationMetadataLayerSigPubKey != nil { if m.ApplicationLayer.SigPubKey != nil {
return m.ApplicationMetadataLayerSigPubKey return m.ApplicationLayer.SigPubKey
} }
return m.TransportLayerSigPubKey return m.TransportLayer.SigPubKey
} }
func (m *StatusMessage) Clone() (*StatusMessage, error) { func (m *StatusMessage) Clone() (*StatusMessage, error) {
@ -89,39 +88,39 @@ func (m *StatusMessage) Clone() (*StatusMessage, error) {
return copy, err return copy, err
} }
func (m *StatusMessage) HandleTransport(shhMessage *types.Message) error { func (m *StatusMessage) HandleTransportLayer(wakuMessage *types.Message) error {
publicKey, err := crypto.UnmarshalPubkey(shhMessage.Sig) publicKey, err := crypto.UnmarshalPubkey(wakuMessage.Sig)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to get signature") return errors.Wrap(err, "failed to get signature")
} }
m.TransportMessage = shhMessage m.TransportLayer.Message = wakuMessage
m.Hash = shhMessage.Hash m.TransportLayer.Hash = wakuMessage.Hash
m.TransportLayerSigPubKey = publicKey m.TransportLayer.SigPubKey = publicKey
m.TransportPayload = shhMessage.Payload m.TransportLayer.Payload = wakuMessage.Payload
if shhMessage.Dst != nil { if wakuMessage.Dst != nil {
publicKey, err := crypto.UnmarshalPubkey(shhMessage.Dst) publicKey, err := crypto.UnmarshalPubkey(wakuMessage.Dst)
if err != nil { if err != nil {
return err return err
} }
m.Dst = publicKey m.TransportLayer.Dst = publicKey
} }
return nil return nil
} }
func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecdsa.PublicKey, enc *encryption.Protocol, skipNegotiation bool) error { func (m *StatusMessage) HandleEncryptionLayer(myKey *ecdsa.PrivateKey, senderKey *ecdsa.PublicKey, enc *encryption.Protocol, skipNegotiation bool) error {
// As we handle non-encrypted messages, we make sure that DecryptPayload // As we handle non-encrypted messages, we make sure that DecryptPayload
// is set regardless of whether this step is successful // is set regardless of whether this step is successful
m.DecryptedPayload = m.TransportPayload m.EncryptionLayer.Payload = m.TransportLayer.Payload
// Nothing to do // Nothing to do
if skipNegotiation { if skipNegotiation {
return nil return nil
} }
var protocolMessage encryption.ProtocolMessage var protocolMessage encryption.ProtocolMessage
err := proto.Unmarshal(m.TransportPayload, &protocolMessage) err := proto.Unmarshal(m.TransportLayer.Payload, &protocolMessage)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to unmarshal ProtocolMessage") return errors.Wrap(err, "failed to unmarshal ProtocolMessage")
} }
@ -130,13 +129,13 @@ func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecd
myKey, myKey,
senderKey, senderKey,
&protocolMessage, &protocolMessage,
m.Hash, m.TransportLayer.Hash,
) )
if err == encryption.ErrHashRatchetGroupIDNotFound { if err == encryption.ErrHashRatchetGroupIDNotFound {
if response != nil { if response != nil {
m.HashRatchetInfo = response.HashRatchetInfo m.EncryptionLayer.HashRatchetInfo = response.HashRatchetInfo
} }
return err return err
} }
@ -145,15 +144,15 @@ func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecd
return errors.Wrap(err, "failed to handle Encryption message") return errors.Wrap(err, "failed to handle Encryption message")
} }
m.DecryptedPayload = response.DecryptedMessage m.EncryptionLayer.Payload = response.DecryptedMessage
m.Installations = response.Installations m.EncryptionLayer.Installations = response.Installations
m.SharedSecrets = response.SharedSecrets m.EncryptionLayer.SharedSecrets = response.SharedSecrets
m.HashRatchetInfo = response.HashRatchetInfo m.EncryptionLayer.HashRatchetInfo = response.HashRatchetInfo
return nil return nil
} }
func (m *StatusMessage) HandleApplicationMetadata() error { func (m *StatusMessage) HandleApplicationLayer() error {
message, err := protobuf.Unmarshal(m.DecryptedPayload) message, err := protobuf.Unmarshal(m.EncryptionLayer.Payload)
if err != nil { if err != nil {
return err return err
} }
@ -162,13 +161,13 @@ func (m *StatusMessage) HandleApplicationMetadata() error {
if err != nil { if err != nil {
return err return err
} }
m.ApplicationMetadataLayerSigPubKey = recoveredKey m.ApplicationLayer.SigPubKey = recoveredKey
// Calculate ID using the wrapped record // Calculate ID using the wrapped record
m.ID = MessageID(recoveredKey, m.DecryptedPayload) m.ApplicationLayer.ID = MessageID(recoveredKey, m.EncryptionLayer.Payload)
log.Debug("calculated ID for envelope", "envelopeHash", hexutil.Encode(m.Hash), "messageId", hexutil.Encode(m.ID)) log.Debug("calculated ID for envelope", "envelopeHash", hexutil.Encode(m.TransportLayer.Hash), "messageId", hexutil.Encode(m.ApplicationLayer.ID))
m.UnwrappedPayload = message.Payload m.ApplicationLayer.Payload = message.Payload
m.Type = message.Type m.ApplicationLayer.Type = message.Type
return nil return nil
} }

View File

@ -42,11 +42,11 @@ func (c *Client) PushReceivedMessages(filter transport.Filter, sshMessage *types
postBody = append(postBody, map[string]interface{}{ postBody = append(postBody, map[string]interface{}{
"chatId": filter.ChatID, "chatId": filter.ChatID,
"messageHash": types.EncodeHex(sshMessage.Hash), "messageHash": types.EncodeHex(sshMessage.Hash),
"messageId": message.ID, "messageId": message.ApplicationLayer.ID,
"sentAt": sshMessage.Timestamp, "sentAt": sshMessage.Timestamp,
"pubsubTopic": filter.PubsubTopic, "pubsubTopic": filter.PubsubTopic,
"topic": filter.ContentTopic.String(), "topic": filter.ContentTopic.String(),
"messageType": message.Type.String(), "messageType": message.ApplicationLayer.Type.String(),
"receiverKeyUID": c.keyUID, "receiverKeyUID": c.keyUID,
"nodeName": c.nodeName, "nodeName": c.nodeName,
"messageSize": len(sshMessage.Payload), "messageSize": len(sshMessage.Payload),