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,7 +76,7 @@ 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,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
|
||||
}
|
||||
_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
|
||||
|
@ -99,7 +99,7 @@ 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,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_INVITATION,
|
||||
}
|
||||
_, err = m.sender.SendPrivate(context.Background(), pk, &rawMessage)
|
||||
|
@ -123,7 +123,7 @@ 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,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_ADMIN_MESSAGE,
|
||||
}
|
||||
|
||||
|
@ -780,7 +780,7 @@ func (m *Messenger) RequestToJoinCommunity(request *requests.RequestToJoinCommun
|
|||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
|
||||
}
|
||||
|
||||
|
@ -951,7 +951,7 @@ func (m *Messenger) CancelRequestToJoinCommunity(request *requests.CancelRequest
|
|||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: community.ID(),
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
|
||||
}
|
||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||
|
@ -1046,7 +1046,7 @@ func (m *Messenger) AcceptRequestToJoinCommunity(request *requests.AcceptRequest
|
|||
rawMessage := &common.RawMessage{
|
||||
Payload: payload,
|
||||
Sender: community.PrivateKey(),
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
|
||||
}
|
||||
|
||||
|
@ -1158,7 +1158,7 @@ func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerRespon
|
|||
rawMessage := common.RawMessage{
|
||||
Payload: payload,
|
||||
CommunityID: communityID,
|
||||
SkipEncryption: true,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
|
||||
}
|
||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||
|
@ -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,7 +1406,7 @@ 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,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
|
||||
}
|
||||
|
||||
|
@ -1686,7 +1686,7 @@ 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,
|
||||
SkipProtocolLayer: true,
|
||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
|
||||
}
|
||||
|
||||
|
|
|
@ -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