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
// Code generated by generate_handlers.go. DO NOT EDIT.
// source: geneate_handlers.go
// source: generate_handlers.go
package protocol
@ -17,13 +17,13 @@ import (
)
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 .}}
case protobuf.ApplicationMetadataMessage_{{.EnumValue}}:
return m.{{.MethodName}}(messageState, protoBytes, msg, filter{{ if .FromArchiveArg }}, fromArchive{{ end }})
{{ end }}
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 nil
@ -48,7 +48,7 @@ func (m *Messenger) {{.MethodName}}(messageState *ReceivedMessageState, protoByt
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 }})
{{ end }}

View File

@ -98,7 +98,7 @@ func (c *Client) sendUnprocessedMetrics() {
rawMessage := common.RawMessage{
Payload: encodedMessage,
Sender: ephemeralKey,
SkipProtocolLayer: true,
SkipEncryptionLayer: true,
SendOnPersonalTopic: true,
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,
// as the datasync interface is not rich enough to propagate that information, so we
// 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")
}
@ -489,7 +489,7 @@ func (s *MessageSender) sendPrivate(
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
messageIDs := [][]byte{messageID}
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")
}
if !rawMessage.SkipProtocolLayer {
if !rawMessage.SkipEncryptionLayer {
newMessage, err = MessageSpecToWhisper(messageSpec)
if err != nil {
return nil, err
@ -721,7 +721,7 @@ func unwrapDatasyncMessage(m *v1protocol.StatusMessage, datasync *datasync.DataS
payloads, acks, err := datasync.UnwrapPayloadsAndAcks(
m.SigPubKey(),
m.DecryptedPayload,
m.EncryptionLayer.Payload,
)
if err != nil {
return nil, nil, err
@ -732,7 +732,7 @@ func unwrapDatasyncMessage(m *v1protocol.StatusMessage, datasync *datasync.DataS
if err != nil {
return nil, nil, err
}
message.DecryptedPayload = payload
message.EncryptionLayer.Payload = payload
statusMessages = append(statusMessages, message)
}
return statusMessages, acks, nil
@ -750,7 +750,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
var statusMessages []*v1protocol.StatusMessage
var acks [][]byte
err := statusMessage.HandleTransport(shhMessage)
err := statusMessage.HandleTransportLayer(shhMessage)
if err != nil {
hlogger.Error("failed to handle transport layer message", zap.Error(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
if err == encryption.ErrHashRatchetGroupIDNotFound && len(statusMessage.HashRatchetInfo) == 1 {
info := statusMessage.HashRatchetInfo[0]
if err == encryption.ErrHashRatchetGroupIDNotFound && len(statusMessage.EncryptionLayer.HashRatchetInfo) == 1 {
info := statusMessage.EncryptionLayer.HashRatchetInfo[0]
err := s.persistence.SaveHashRatchetMessage(info.GroupID, info.KeyID, shhMessage)
return nil, nil, err
}
// Check if there are undecrypted message
for _, hashRatchetInfo := range statusMessage.HashRatchetInfo {
for _, hashRatchetInfo := range statusMessage.EncryptionLayer.HashRatchetInfo {
messages, err := s.persistence.GetHashRatchetMessages(hashRatchetInfo.KeyID)
if err != nil {
return nil, nil, err
@ -778,7 +778,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
var processedIds [][]byte
for _, message := range messages {
var statusMessage v1protocol.StatusMessage
err := statusMessage.HandleTransport(message)
err := statusMessage.HandleTransportLayer(message)
if err != nil {
hlogger.Error("failed to handle transport layer message", zap.Error(err))
return nil, nil, err
@ -820,7 +820,7 @@ func (s *MessageSender) HandleMessages(shhMessage *types.Message) ([]*v1protocol
}
for _, statusMessage := range statusMessages {
err := statusMessage.HandleApplicationMetadata()
err := statusMessage.HandleApplicationLayer()
if err != nil {
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()
// 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 err == encryption.ErrDeviceNotFound && !skipNegotiation {

View File

@ -120,9 +120,9 @@ func (s *MessageSenderSuite) TestHandleDecodedMessagesWrapped() {
s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type)
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
}
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
s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type)
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
}
func (s *MessageSenderSuite) CalculatePoWTest() {
@ -221,9 +221,9 @@ func (s *MessageSenderSuite) TestHandleDecodedMessagesDatasyncEncrypted() {
// while the wrapped one will be attributed to the author.
s.Require().Equal(1, len(decodedMessages))
s.Require().Equal(&authorKey.PublicKey, decodedMessages[0].SigPubKey())
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ID)
s.Require().Equal(encodedPayload, decodedMessages[0].UnwrappedPayload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].Type)
s.Require().Equal(v1protocol.MessageID(&authorKey.PublicKey, wrappedPayload), decodedMessages[0].ApplicationLayer.ID)
s.Require().Equal(encodedPayload, decodedMessages[0].ApplicationLayer.Payload)
s.Require().Equal(protobuf.ApplicationMetadataMessage_CHAT_MESSAGE, decodedMessages[0].ApplicationLayer.Type)
}
func (s *MessageSenderSuite) TestHandleOutOfOrderHashRatchet() {

View File

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

View File

@ -97,7 +97,7 @@ func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error {
message.MessageType,
message.ResendAutomatically,
encodedRecipients.Bytes(),
message.SkipProtocolLayer,
message.SkipEncryptionLayer,
message.SendPushNotification,
message.SkipGroupMessageWrap,
message.SendOnPersonalTopic,
@ -158,7 +158,7 @@ func (db RawMessagesPersistence) rawMessageByID(tx *sql.Tx, id string) (*RawMess
&message.MessageType,
&message.ResendAutomatically,
&encodedRecipients,
&message.SkipProtocolLayer,
&message.SkipEncryptionLayer,
&message.SendPushNotification,
&skipGroupMessageWrap,
&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 {
rawMessage := common.RawMessage{
Sender: community.PrivateKey(),
SkipProtocolLayer: false,
SkipEncryptionLayer: false,
CommunityID: community.ID(),
CommunityKeyExMsgType: msgType,
Recipients: pubkeys,

View File

@ -3269,9 +3269,8 @@ func (s *MessengerCommunitiesSuite) TestCommunityBanUserRequestToJoin() {
messageState.CurrentMessageState.PublicKey = &s.alice.identity.PublicKey
statusMessage := v1protocol.StatusMessage{
Dst: community.PublicKey(),
}
statusMessage := v1protocol.StatusMessage{}
statusMessage.TransportLayer.Dst = community.PublicKey()
err = s.owner.HandleCommunityRequestToJoin(messageState, requestToJoinProto, &statusMessage)
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
//message for sending to paired devices later
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)
if err != nil {
@ -3482,14 +3482,14 @@ func (m *Messenger) handleImportedMessages(messagesToHandle map[transport.Filter
}
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")
publicKey := msg.SigPubKey()
senderID := contactIDFromPublicKey(publicKey)
// Don't process duplicates
messageID := msg.TransportMessage.ThirdPartyID
messageID := msg.TransportLayer.Message.ThirdPartyID
exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap)
if err != nil {
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{
MessageID: messageID,
WhisperTimestamp: uint64(msg.TransportMessage.Timestamp) * 1000,
WhisperTimestamp: uint64(msg.TransportLayer.Message.Timestamp) * 1000,
Contact: contact,
PublicKey: publicKey,
}
if msg.UnwrappedPayload != nil {
if msg.ApplicationLayer.Payload != nil {
logger.Debug("Handling parsed message")
switch msg.Type {
switch msg.ApplicationLayer.Type {
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 {
logger.Warn("failed to handle ChatMessage", zap.Error(err))
continue
}
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 {
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)))
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")
publicKey := msg.SigPubKey()
m.handleInstallations(msg.Installations)
err := m.handleSharedSecrets(msg.SharedSecrets)
m.handleInstallations(msg.EncryptionLayer.Installations)
err := m.handleSharedSecrets(msg.EncryptionLayer.SharedSecrets)
if err != nil {
// log and continue, non-critical error
logger.Warn("failed to handle shared secrets")
@ -3657,11 +3657,11 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
senderID := contactIDFromPublicKey(publicKey)
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 {
// Skip own messages of certain types
if msg.Type == protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT {
if msg.ApplicationLayer.Type == protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT {
continue
}
}
@ -3676,7 +3676,7 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
}
// Don't process duplicates
messageID := types.EncodeHex(msg.ID)
messageID := types.EncodeHex(msg.ApplicationLayer.ID)
exists, err := m.messageExists(messageID, messageState.ExistingMessagesMap)
if err != nil {
logger.Warn("failed to check message exists", zap.Error(err))
@ -3694,21 +3694,21 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
continue
}
contact = c
if msg.Type != protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY {
if msg.ApplicationLayer.Type != protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY {
messageState.AllContacts.Store(senderID, contact)
m.forgetContactInfoRequest(senderID)
}
}
messageState.CurrentMessageState = &CurrentMessageState{
MessageID: messageID,
WhisperTimestamp: uint64(msg.TransportMessage.Timestamp) * 1000,
WhisperTimestamp: uint64(msg.TransportLayer.Message.Timestamp) * 1000,
Contact: contact,
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 {
allMessagesProcessed = false
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{
LocalChatID: chatID,
Payload: encodedMessage,
SkipProtocolLayer: true,
SkipEncryptionLayer: true,
SendOnPersonalTopic: true,
MessageType: protobuf.ApplicationMetadataMessage_BACKUP,
})

View File

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

View File

@ -1,6 +1,6 @@
//nolint
// Code generated by generate_handlers.go. DO NOT EDIT.
// source: geneate_handlers.go
// source: generate_handlers.go
package protocol
@ -17,7 +17,7 @@ import (
)
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:
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)
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 nil
@ -251,7 +251,7 @@ func (m *Messenger) handleChatMessageProtobuf(messageState *ReceivedMessageState
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 )
@ -269,7 +269,7 @@ func (m *Messenger) handleContactUpdateProtobuf(messageState *ReceivedMessageSta
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)
@ -287,7 +287,7 @@ func (m *Messenger) handleMembershipUpdateMessageProtobuf(messageState *Received
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)
@ -310,7 +310,7 @@ func (m *Messenger) handleSyncPairInstallationProtobuf(messageState *ReceivedMes
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)
@ -328,7 +328,7 @@ func (m *Messenger) handleRequestAddressForTransactionProtobuf(messageState *Rec
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)
@ -346,7 +346,7 @@ func (m *Messenger) handleAcceptRequestAddressForTransactionProtobuf(messageStat
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)
@ -364,7 +364,7 @@ func (m *Messenger) handleDeclineRequestAddressForTransactionProtobuf(messageSta
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)
@ -382,7 +382,7 @@ func (m *Messenger) handleRequestTransactionProtobuf(messageState *ReceivedMessa
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)
@ -400,7 +400,7 @@ func (m *Messenger) handleSendTransactionProtobuf(messageState *ReceivedMessageS
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)
@ -418,7 +418,7 @@ func (m *Messenger) handleDeclineRequestTransactionProtobuf(messageState *Receiv
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)
@ -441,7 +441,7 @@ func (m *Messenger) handleSyncInstallationContactV2Protobuf(messageState *Receiv
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)
@ -464,7 +464,7 @@ func (m *Messenger) handleSyncInstallationAccountProtobuf(messageState *Received
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)
@ -482,7 +482,7 @@ func (m *Messenger) handleContactCodeAdvertisementProtobuf(messageState *Receive
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)
@ -510,7 +510,7 @@ func (m *Messenger) handlePushNotificationRegistrationResponseProtobuf(messageSt
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)
@ -528,7 +528,7 @@ func (m *Messenger) handlePushNotificationQueryProtobuf(messageState *ReceivedMe
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)
@ -546,7 +546,7 @@ func (m *Messenger) handlePushNotificationQueryResponseProtobuf(messageState *Re
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)
@ -564,7 +564,7 @@ func (m *Messenger) handlePushNotificationRequestProtobuf(messageState *Received
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)
@ -582,7 +582,7 @@ func (m *Messenger) handlePushNotificationResponseProtobuf(messageState *Receive
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)
@ -600,7 +600,7 @@ func (m *Messenger) handleEmojiReactionProtobuf(messageState *ReceivedMessageSta
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)
@ -618,7 +618,7 @@ func (m *Messenger) handleGroupChatInvitationProtobuf(messageState *ReceivedMess
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)
@ -636,7 +636,7 @@ func (m *Messenger) handleChatIdentityProtobuf(messageState *ReceivedMessageStat
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)
@ -654,7 +654,7 @@ func (m *Messenger) handleCommunityDescriptionProtobuf(messageState *ReceivedMes
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)
@ -672,7 +672,7 @@ func (m *Messenger) handleCommunityRequestToJoinProtobuf(messageState *ReceivedM
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)
@ -690,7 +690,7 @@ func (m *Messenger) handlePinMessageProtobuf(messageState *ReceivedMessageState,
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 )
@ -708,7 +708,7 @@ func (m *Messenger) handleEditMessageProtobuf(messageState *ReceivedMessageState
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)
@ -726,7 +726,7 @@ func (m *Messenger) handleStatusUpdateProtobuf(messageState *ReceivedMessageStat
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)
@ -744,7 +744,7 @@ func (m *Messenger) handleDeleteMessageProtobuf(messageState *ReceivedMessageSta
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)
@ -767,7 +767,7 @@ func (m *Messenger) handleSyncInstallationCommunityProtobuf(messageState *Receiv
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)
@ -785,7 +785,7 @@ func (m *Messenger) handleAnonymousMetricBatchProtobuf(messageState *ReceivedMes
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)
@ -808,7 +808,7 @@ func (m *Messenger) handleSyncChatRemovedProtobuf(messageState *ReceivedMessageS
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)
@ -831,7 +831,7 @@ func (m *Messenger) handleSyncChatMessagesReadProtobuf(messageState *ReceivedMes
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)
@ -849,7 +849,7 @@ func (m *Messenger) handleBackupProtobuf(messageState *ReceivedMessageState, pro
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)
@ -872,7 +872,7 @@ func (m *Messenger) handleSyncActivityCenterReadProtobuf(messageState *ReceivedM
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)
@ -895,7 +895,7 @@ func (m *Messenger) handleSyncActivityCenterAcceptedProtobuf(messageState *Recei
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)
@ -918,7 +918,7 @@ func (m *Messenger) handleSyncActivityCenterDismissedProtobuf(messageState *Rece
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)
@ -941,7 +941,7 @@ func (m *Messenger) handleSyncBookmarkProtobuf(messageState *ReceivedMessageStat
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)
@ -964,7 +964,7 @@ func (m *Messenger) handleSyncClearHistoryProtobuf(messageState *ReceivedMessage
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)
@ -987,7 +987,7 @@ func (m *Messenger) handleSyncSettingProtobuf(messageState *ReceivedMessageState
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)
@ -1005,7 +1005,7 @@ func (m *Messenger) handleCommunityMessageArchiveMagnetlinkProtobuf(messageState
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)
@ -1028,7 +1028,7 @@ func (m *Messenger) handleSyncProfilePicturesProtobuf(messageState *ReceivedMess
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)
@ -1051,7 +1051,7 @@ func (m *Messenger) handleSyncAccountProtobuf(messageState *ReceivedMessageState
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)
@ -1069,7 +1069,7 @@ func (m *Messenger) handleAcceptContactRequestProtobuf(messageState *ReceivedMes
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)
@ -1087,7 +1087,7 @@ func (m *Messenger) handleRetractContactRequestProtobuf(messageState *ReceivedMe
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)
@ -1105,7 +1105,7 @@ func (m *Messenger) handleCommunityRequestToJoinResponseProtobuf(messageState *R
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)
@ -1128,7 +1128,7 @@ func (m *Messenger) handleSyncCommunitySettingsProtobuf(messageState *ReceivedMe
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)
@ -1146,7 +1146,7 @@ func (m *Messenger) handleRequestContactVerificationProtobuf(messageState *Recei
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)
@ -1164,7 +1164,7 @@ func (m *Messenger) handleAcceptContactVerificationProtobuf(messageState *Receiv
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)
@ -1182,7 +1182,7 @@ func (m *Messenger) handleDeclineContactVerificationProtobuf(messageState *Recei
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)
@ -1205,7 +1205,7 @@ func (m *Messenger) handleSyncTrustedUserProtobuf(messageState *ReceivedMessageS
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)
@ -1228,7 +1228,7 @@ func (m *Messenger) handleSyncVerificationRequestProtobuf(messageState *Received
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)
@ -1251,7 +1251,7 @@ func (m *Messenger) handleSyncContactRequestDecisionProtobuf(messageState *Recei
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)
@ -1269,7 +1269,7 @@ func (m *Messenger) handleCommunityRequestToLeaveProtobuf(messageState *Received
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)
@ -1292,7 +1292,7 @@ func (m *Messenger) handleSyncDeleteForMeMessageProtobuf(messageState *ReceivedM
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)
@ -1315,7 +1315,7 @@ func (m *Messenger) handleSyncSavedAddressProtobuf(messageState *ReceivedMessage
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)
@ -1333,7 +1333,7 @@ func (m *Messenger) handleCommunityCancelRequestToJoinProtobuf(messageState *Rec
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)
@ -1351,7 +1351,7 @@ func (m *Messenger) handleCancelContactVerificationProtobuf(messageState *Receiv
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)
@ -1374,7 +1374,7 @@ func (m *Messenger) handleSyncKeypairProtobuf(messageState *ReceivedMessageState
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)
@ -1397,7 +1397,7 @@ func (m *Messenger) handleSyncSocialLinksProtobuf(messageState *ReceivedMessageS
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)
@ -1420,7 +1420,7 @@ func (m *Messenger) handleSyncEnsUsernameDetailProtobuf(messageState *ReceivedMe
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)
@ -1438,7 +1438,7 @@ func (m *Messenger) handleCommunityEventsMessageProtobuf(messageState *ReceivedM
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)
@ -1456,7 +1456,7 @@ func (m *Messenger) handleCommunityEditSharedAddressesProtobuf(messageState *Rec
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)
@ -1479,7 +1479,7 @@ func (m *Messenger) handleSyncAccountCustomizationColorProtobuf(messageState *Re
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)
@ -1502,7 +1502,7 @@ func (m *Messenger) handleSyncAccountsPositionsProtobuf(messageState *ReceivedMe
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)
@ -1520,7 +1520,7 @@ func (m *Messenger) handleCommunityEventsMessageRejectedProtobuf(messageState *R
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)
@ -1538,7 +1538,7 @@ func (m *Messenger) handleCommunityPrivilegedUserSyncMessageProtobuf(messageStat
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)
@ -1556,7 +1556,7 @@ func (m *Messenger) handleCommunityShardKeyProtobuf(messageState *ReceivedMessag
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)
@ -1579,7 +1579,7 @@ func (m *Messenger) handleSyncChatProtobuf(messageState *ReceivedMessageState, p
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)
@ -1602,7 +1602,7 @@ func (m *Messenger) handleSyncActivityCenterDeletedProtobuf(messageState *Receiv
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)
@ -1625,7 +1625,7 @@ func (m *Messenger) handleSyncActivityCenterUnreadProtobuf(messageState *Receive
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)
@ -1648,7 +1648,7 @@ func (m *Messenger) handleSyncActivityCenterCommunityRequestDecisionProtobuf(mes
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)

View File

@ -1309,7 +1309,7 @@ func (c *Client) registerWithServer(registration *protobuf.PushNotificationRegis
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION,
// We send on personal topic to avoid a lot of traffic on the partitioned topic
SendOnPersonalTopic: true,
SkipProtocolLayer: true,
SkipEncryptionLayer: true,
}
_, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage)
@ -1417,8 +1417,8 @@ func (c *Client) SendNotification(publicKey *ecdsa.PublicKey, installationIDs []
Sender: ephemeralKey,
// 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
SkipProtocolLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
}
_, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage)
@ -1697,8 +1697,8 @@ func (c *Client) queryPushNotificationInfo(publicKey *ecdsa.PublicKey) error {
Payload: encodedMessage,
Sender: ephemeralKey,
// we don't want to wrap in an encryption layer message
SkipProtocolLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
SkipEncryptionLayer: true,
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
}
_, err = c.messageSender.AddEphemeralKey(ephemeralKey)

View File

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

View File

@ -18,44 +18,43 @@ import (
"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.
type StatusMessage struct {
// TransportMessage is the parsed message received from the transport layer, i.e the input
TransportMessage *types.Message `json:"transportMessage"`
// Type is the type of application message contained
Type protobuf.ApplicationMetadataMessage_Type `json:"-"`
// TransportPayload is the payload as received from the transport layer
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
// EncryptionLayer handles optional encryption.
// It is not mandatory and can be omitted,
// also its presence does not guarantee encryption.
type EncryptionLayer struct {
// Payload after having been processed by the encryption layer
Payload []byte `json:"-"`
Installations []*multidevice.Installation
SharedSecrets []*sharedsecret.Secret
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
// by the go code
func (m *StatusMessage) MarshalJSON() ([]byte, error) {
@ -65,21 +64,21 @@ func (m *StatusMessage) MarshalJSON() ([]byte, error) {
From types.HexBytes `json:"from"`
Timestamp uint32 `json:"timestamp"`
}{
ID: m.ID,
Payload: string(m.UnwrappedPayload),
Timestamp: m.TransportMessage.Timestamp,
From: m.TransportMessage.Sig,
ID: m.ApplicationLayer.ID,
Payload: string(m.ApplicationLayer.Payload),
Timestamp: m.TransportLayer.Message.Timestamp,
From: m.TransportLayer.Message.Sig,
}
return json.Marshal(item)
}
// SigPubKey returns the most important signature, from the application layer to transport
func (m *StatusMessage) SigPubKey() *ecdsa.PublicKey {
if m.ApplicationMetadataLayerSigPubKey != nil {
return m.ApplicationMetadataLayerSigPubKey
if m.ApplicationLayer.SigPubKey != nil {
return m.ApplicationLayer.SigPubKey
}
return m.TransportLayerSigPubKey
return m.TransportLayer.SigPubKey
}
func (m *StatusMessage) Clone() (*StatusMessage, error) {
@ -89,39 +88,39 @@ func (m *StatusMessage) Clone() (*StatusMessage, error) {
return copy, err
}
func (m *StatusMessage) HandleTransport(shhMessage *types.Message) error {
publicKey, err := crypto.UnmarshalPubkey(shhMessage.Sig)
func (m *StatusMessage) HandleTransportLayer(wakuMessage *types.Message) error {
publicKey, err := crypto.UnmarshalPubkey(wakuMessage.Sig)
if err != nil {
return errors.Wrap(err, "failed to get signature")
}
m.TransportMessage = shhMessage
m.Hash = shhMessage.Hash
m.TransportLayerSigPubKey = publicKey
m.TransportPayload = shhMessage.Payload
m.TransportLayer.Message = wakuMessage
m.TransportLayer.Hash = wakuMessage.Hash
m.TransportLayer.SigPubKey = publicKey
m.TransportLayer.Payload = wakuMessage.Payload
if shhMessage.Dst != nil {
publicKey, err := crypto.UnmarshalPubkey(shhMessage.Dst)
if wakuMessage.Dst != nil {
publicKey, err := crypto.UnmarshalPubkey(wakuMessage.Dst)
if err != nil {
return err
}
m.Dst = publicKey
m.TransportLayer.Dst = publicKey
}
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
// is set regardless of whether this step is successful
m.DecryptedPayload = m.TransportPayload
m.EncryptionLayer.Payload = m.TransportLayer.Payload
// Nothing to do
if skipNegotiation {
return nil
}
var protocolMessage encryption.ProtocolMessage
err := proto.Unmarshal(m.TransportPayload, &protocolMessage)
err := proto.Unmarshal(m.TransportLayer.Payload, &protocolMessage)
if err != nil {
return errors.Wrap(err, "failed to unmarshal ProtocolMessage")
}
@ -130,13 +129,13 @@ func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecd
myKey,
senderKey,
&protocolMessage,
m.Hash,
m.TransportLayer.Hash,
)
if err == encryption.ErrHashRatchetGroupIDNotFound {
if response != nil {
m.HashRatchetInfo = response.HashRatchetInfo
m.EncryptionLayer.HashRatchetInfo = response.HashRatchetInfo
}
return err
}
@ -145,15 +144,15 @@ func (m *StatusMessage) HandleEncryption(myKey *ecdsa.PrivateKey, senderKey *ecd
return errors.Wrap(err, "failed to handle Encryption message")
}
m.DecryptedPayload = response.DecryptedMessage
m.Installations = response.Installations
m.SharedSecrets = response.SharedSecrets
m.HashRatchetInfo = response.HashRatchetInfo
m.EncryptionLayer.Payload = response.DecryptedMessage
m.EncryptionLayer.Installations = response.Installations
m.EncryptionLayer.SharedSecrets = response.SharedSecrets
m.EncryptionLayer.HashRatchetInfo = response.HashRatchetInfo
return nil
}
func (m *StatusMessage) HandleApplicationMetadata() error {
message, err := protobuf.Unmarshal(m.DecryptedPayload)
func (m *StatusMessage) HandleApplicationLayer() error {
message, err := protobuf.Unmarshal(m.EncryptionLayer.Payload)
if err != nil {
return err
}
@ -162,13 +161,13 @@ func (m *StatusMessage) HandleApplicationMetadata() error {
if err != nil {
return err
}
m.ApplicationMetadataLayerSigPubKey = recoveredKey
m.ApplicationLayer.SigPubKey = recoveredKey
// Calculate ID using the wrapped record
m.ID = MessageID(recoveredKey, m.DecryptedPayload)
log.Debug("calculated ID for envelope", "envelopeHash", hexutil.Encode(m.Hash), "messageId", hexutil.Encode(m.ID))
m.ApplicationLayer.ID = MessageID(recoveredKey, m.EncryptionLayer.Payload)
log.Debug("calculated ID for envelope", "envelopeHash", hexutil.Encode(m.TransportLayer.Hash), "messageId", hexutil.Encode(m.ApplicationLayer.ID))
m.UnwrappedPayload = message.Payload
m.Type = message.Type
m.ApplicationLayer.Payload = message.Payload
m.ApplicationLayer.Type = message.Type
return nil
}

View File

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