chore: rename RawMessage.SkipEncryption->SkipProtocolLayer
`SkipEncryption` was misleading, as it wasn't really always related with encryption.
This commit is contained in:
parent
b7390f4355
commit
5bb787fadb
|
@ -98,7 +98,7 @@ func (c *Client) sendUnprocessedMetrics() {
|
|||
rawMessage := common.RawMessage{
|
||||
Payload: encodedMessage,
|
||||
Sender: ephemeralKey,
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
SendOnPersonalTopic: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_ANONYMOUS_METRIC_BATCH,
|
||||
}
|
||||
|
|
|
@ -159,7 +159,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.SkipEncryption || rawMessage.SendOnPersonalTopic) {
|
||||
if rawMessage.ResendAutomatically && (rawMessage.Sender != nil || rawMessage.SkipProtocolLayer || rawMessage.SendOnPersonalTopic) {
|
||||
return nil, errors.New("setting identity, skip-encryption or personal topic and datasync not supported")
|
||||
}
|
||||
|
||||
|
@ -395,8 +395,8 @@ func (s *MessageSender) sendPrivate(
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
} else if rawMessage.SkipEncryption {
|
||||
// When SkipEncryption is set we don't pass the message to the encryption layer
|
||||
} else if rawMessage.SkipProtocolLayer {
|
||||
// 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)
|
||||
if err != nil {
|
||||
|
@ -404,7 +404,7 @@ func (s *MessageSender) sendPrivate(
|
|||
return nil, errors.Wrap(err, "failed to send a message spec")
|
||||
}
|
||||
|
||||
s.logger.Debug("sent private message skipEncryption", zap.String("messageID", messageID.String()), zap.String("hash", types.EncodeHex(hash)))
|
||||
s.logger.Debug("sent private message skipProtocolLayer", zap.String("messageID", messageID.String()), zap.String("hash", types.EncodeHex(hash)))
|
||||
|
||||
s.transport.Track(messageIDs, hash, newMessage)
|
||||
|
||||
|
@ -571,7 +571,7 @@ func (s *MessageSender) SendPublic(
|
|||
return nil, errors.Wrap(err, "failed to wrap a public message in the encryption layer")
|
||||
}
|
||||
|
||||
if !rawMessage.SkipEncryption {
|
||||
if !rawMessage.SkipProtocolLayer {
|
||||
newMessage, err = MessageSpecToWhisper(messageSpec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -23,7 +23,7 @@ type RawMessage struct {
|
|||
SendCount int
|
||||
Sent bool
|
||||
ResendAutomatically bool
|
||||
SkipEncryption bool
|
||||
SkipProtocolLayer bool // don't wrap message into ProtocolMessage
|
||||
SendPushNotification bool
|
||||
MessageType protobuf.ApplicationMetadataMessage_Type
|
||||
Payload []byte
|
||||
|
|
|
@ -96,7 +96,7 @@ func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error {
|
|||
message.MessageType,
|
||||
message.ResendAutomatically,
|
||||
encodedRecipients.Bytes(),
|
||||
message.SkipEncryption,
|
||||
message.SkipProtocolLayer,
|
||||
message.SendPushNotification,
|
||||
message.SkipGroupMessageWrap,
|
||||
message.SendOnPersonalTopic,
|
||||
|
@ -157,7 +157,7 @@ func (db RawMessagesPersistence) rawMessageByID(tx *sql.Tx, id string) (*RawMess
|
|||
&message.MessageType,
|
||||
&message.ResendAutomatically,
|
||||
&encodedRecipients,
|
||||
&message.SkipEncryption,
|
||||
&message.SkipProtocolLayer,
|
||||
&message.SendPushNotification,
|
||||
&skipGroupMessageWrap,
|
||||
&sendOnPersonalTopic,
|
||||
|
|
|
@ -1959,7 +1959,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.SkipEncryption {
|
||||
if !common.IsPubKeyEqual(publicKey, &m.identity.PublicKey) || rawMessage.SkipProtocolLayer {
|
||||
id, err = m.sender.SendPrivate(ctx, publicKey, &rawMessage)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -229,7 +229,7 @@ func (m *Messenger) encodeAndDispatchBackupMessage(ctx context.Context, message
|
|||
_, err = m.dispatchMessage(ctx, common.RawMessage{
|
||||
LocalChatID: chatID,
|
||||
Payload: encodedMessage,
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
SendOnPersonalTopic: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_BACKUP,
|
||||
})
|
||||
|
|
|
@ -76,8 +76,8 @@ func (m *Messenger) publishOrg(org *communities.Community) error {
|
|||
Payload: payload,
|
||||
Sender: org.PrivateKey(),
|
||||
// we don't want to wrap in an encryption layer message
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
|
||||
}
|
||||
_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
|
||||
return err
|
||||
|
@ -99,8 +99,8 @@ func (m *Messenger) publishOrgInvitation(org *communities.Community, invitation
|
|||
Payload: payload,
|
||||
Sender: org.PrivateKey(),
|
||||
// we don't want to wrap in an encryption layer message
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_INVITATION,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_INVITATION,
|
||||
}
|
||||
_, err = m.sender.SendPrivate(context.Background(), pk, &rawMessage)
|
||||
return err
|
||||
|
@ -123,8 +123,8 @@ func (m *Messenger) publishCommunityAdminEvent(adminEvent *protobuf.CommunityAdm
|
|||
Payload: payload,
|
||||
Sender: m.identity,
|
||||
// we don't want to wrap in an encryption layer message
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_ADMIN_MESSAGE,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_ADMIN_MESSAGE,
|
||||
}
|
||||
|
||||
_, err = m.sender.SendPublic(context.Background(), types.EncodeHex(adminEvent.CommunityId), rawMessage)
|
||||
|
@ -778,10 +778,10 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun
|
|||
}
|
||||
|
||||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
|
||||
}
|
||||
|
||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||
|
@ -949,10 +949,10 @@ func (m *Messenger) CancelRequestToJoinCommunity(request *requests.CancelRequest
|
|||
}
|
||||
|
||||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
|
||||
}
|
||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||
|
||||
|
@ -1044,10 +1044,10 @@ func (m *Messenger) AcceptRequestToJoinCommunity(request *requests.AcceptRequest
|
|||
}
|
||||
|
||||
rawMessage := &common.RawMessage{
|
||||
Payload: payload,
|
||||
Sender: community.PrivateKey(),
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
|
||||
Payload: payload,
|
||||
Sender: community.PrivateKey(),
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
|
||||
}
|
||||
|
||||
_, err = m.sender.SendPrivate(context.Background(), pk, rawMessage)
|
||||
|
@ -1156,10 +1156,10 @@ func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerRespon
|
|||
}
|
||||
|
||||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: communityID,
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
|
||||
Payload: payload,
|
||||
CommunityID: communityID,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
|
||||
}
|
||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||
if err != nil {
|
||||
|
@ -1749,7 +1749,7 @@ func (m *Messenger) RemoveUserFromCommunity(id types.HexBytes, pkString string)
|
|||
|
||||
func (m *Messenger) SendKeyExchangeMessage(communityID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error {
|
||||
rawMessage := common.RawMessage{
|
||||
SkipEncryption: false,
|
||||
SkipProtocolLayer: false,
|
||||
CommunityID: communityID,
|
||||
CommunityKeyExMsgType: msgType,
|
||||
Recipients: pubkeys,
|
||||
|
|
|
@ -1298,7 +1298,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,
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
}
|
||||
|
||||
_, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage)
|
||||
|
@ -1406,8 +1406,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
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
|
||||
}
|
||||
|
||||
_, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage)
|
||||
|
@ -1686,8 +1686,8 @@ func (c *Client) queryPushNotificationInfo(publicKey *ecdsa.PublicKey) error {
|
|||
Payload: encodedMessage,
|
||||
Sender: ephemeralKey,
|
||||
// we don't want to wrap in an encryption layer message
|
||||
SkipEncryption: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
|
||||
}
|
||||
|
||||
_, err = c.messageSender.AddEphemeralKey(ephemeralKey)
|
||||
|
|
|
@ -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
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
}
|
||||
|
||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||
|
@ -132,7 +132,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
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
}
|
||||
|
||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||
|
@ -175,7 +175,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
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
}
|
||||
|
||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||
|
|
Loading…
Reference in New Issue