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{
|
rawMessage := common.RawMessage{
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
Sender: ephemeralKey,
|
Sender: ephemeralKey,
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
SendOnPersonalTopic: true,
|
SendOnPersonalTopic: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_ANONYMOUS_METRIC_BATCH,
|
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,
|
// Currently we don't support sending through datasync and setting custom waku fields,
|
||||||
// as the datasync interface is not rich enough to propagate that information, so we
|
// as the datasync interface is not rich enough to propagate that information, so we
|
||||||
// would have to add some complexity to handle this.
|
// would have to add some complexity to handle this.
|
||||||
if rawMessage.ResendAutomatically && (rawMessage.Sender != nil || rawMessage.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")
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if rawMessage.SkipEncryption {
|
} else if rawMessage.SkipProtocolLayer {
|
||||||
// When SkipEncryption is set we don't pass the message to the encryption layer
|
// When SkipProtocolLayer is set we don't pass the message to the encryption layer
|
||||||
messageIDs := [][]byte{messageID}
|
messageIDs := [][]byte{messageID}
|
||||||
hash, newMessage, err := s.sendPrivateRawMessage(ctx, rawMessage, recipient, wrappedMessage, messageIDs)
|
hash, newMessage, err := s.sendPrivateRawMessage(ctx, rawMessage, recipient, wrappedMessage, messageIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -404,7 +404,7 @@ func (s *MessageSender) sendPrivate(
|
||||||
return nil, errors.Wrap(err, "failed to send a message spec")
|
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)
|
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")
|
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)
|
newMessage, err = MessageSpecToWhisper(messageSpec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -23,7 +23,7 @@ type RawMessage struct {
|
||||||
SendCount int
|
SendCount int
|
||||||
Sent bool
|
Sent bool
|
||||||
ResendAutomatically bool
|
ResendAutomatically bool
|
||||||
SkipEncryption bool
|
SkipProtocolLayer bool // don't wrap message into ProtocolMessage
|
||||||
SendPushNotification bool
|
SendPushNotification bool
|
||||||
MessageType protobuf.ApplicationMetadataMessage_Type
|
MessageType protobuf.ApplicationMetadataMessage_Type
|
||||||
Payload []byte
|
Payload []byte
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (db RawMessagesPersistence) SaveRawMessage(message *RawMessage) error {
|
||||||
message.MessageType,
|
message.MessageType,
|
||||||
message.ResendAutomatically,
|
message.ResendAutomatically,
|
||||||
encodedRecipients.Bytes(),
|
encodedRecipients.Bytes(),
|
||||||
message.SkipEncryption,
|
message.SkipProtocolLayer,
|
||||||
message.SendPushNotification,
|
message.SendPushNotification,
|
||||||
message.SkipGroupMessageWrap,
|
message.SkipGroupMessageWrap,
|
||||||
message.SendOnPersonalTopic,
|
message.SendOnPersonalTopic,
|
||||||
|
@ -157,7 +157,7 @@ func (db RawMessagesPersistence) rawMessageByID(tx *sql.Tx, id string) (*RawMess
|
||||||
&message.MessageType,
|
&message.MessageType,
|
||||||
&message.ResendAutomatically,
|
&message.ResendAutomatically,
|
||||||
&encodedRecipients,
|
&encodedRecipients,
|
||||||
&message.SkipEncryption,
|
&message.SkipProtocolLayer,
|
||||||
&message.SendPushNotification,
|
&message.SendPushNotification,
|
||||||
&skipGroupMessageWrap,
|
&skipGroupMessageWrap,
|
||||||
&sendOnPersonalTopic,
|
&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
|
//SendPrivate will alter message identity and possibly datasyncid, so we save an unchanged
|
||||||
//message for sending to paired devices later
|
//message for sending to paired devices later
|
||||||
specCopyForPairedDevices := rawMessage
|
specCopyForPairedDevices := rawMessage
|
||||||
if !common.IsPubKeyEqual(publicKey, &m.identity.PublicKey) || rawMessage.SkipEncryption {
|
if !common.IsPubKeyEqual(publicKey, &m.identity.PublicKey) || rawMessage.SkipProtocolLayer {
|
||||||
id, err = m.sender.SendPrivate(ctx, publicKey, &rawMessage)
|
id, err = m.sender.SendPrivate(ctx, publicKey, &rawMessage)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -229,7 +229,7 @@ func (m *Messenger) encodeAndDispatchBackupMessage(ctx context.Context, message
|
||||||
_, err = m.dispatchMessage(ctx, common.RawMessage{
|
_, err = m.dispatchMessage(ctx, common.RawMessage{
|
||||||
LocalChatID: chatID,
|
LocalChatID: chatID,
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
SendOnPersonalTopic: true,
|
SendOnPersonalTopic: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_BACKUP,
|
MessageType: protobuf.ApplicationMetadataMessage_BACKUP,
|
||||||
})
|
})
|
||||||
|
|
|
@ -76,8 +76,8 @@ func (m *Messenger) publishOrg(org *communities.Community) error {
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
Sender: org.PrivateKey(),
|
Sender: org.PrivateKey(),
|
||||||
// we don't want to wrap in an encryption layer message
|
// we don't want to wrap in an encryption layer message
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_DESCRIPTION,
|
||||||
}
|
}
|
||||||
_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
|
_, err = m.sender.SendPublic(context.Background(), org.IDString(), rawMessage)
|
||||||
return err
|
return err
|
||||||
|
@ -99,8 +99,8 @@ func (m *Messenger) publishOrgInvitation(org *communities.Community, invitation
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
Sender: org.PrivateKey(),
|
Sender: org.PrivateKey(),
|
||||||
// we don't want to wrap in an encryption layer message
|
// we don't want to wrap in an encryption layer message
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_INVITATION,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_INVITATION,
|
||||||
}
|
}
|
||||||
_, err = m.sender.SendPrivate(context.Background(), pk, &rawMessage)
|
_, err = m.sender.SendPrivate(context.Background(), pk, &rawMessage)
|
||||||
return err
|
return err
|
||||||
|
@ -123,8 +123,8 @@ func (m *Messenger) publishCommunityAdminEvent(adminEvent *protobuf.CommunityAdm
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
Sender: m.identity,
|
Sender: m.identity,
|
||||||
// we don't want to wrap in an encryption layer message
|
// we don't want to wrap in an encryption layer message
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_ADMIN_MESSAGE,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_ADMIN_MESSAGE,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = m.sender.SendPublic(context.Background(), types.EncodeHex(adminEvent.CommunityId), rawMessage)
|
_, 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{
|
rawMessage := common.RawMessage{
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||||
|
@ -949,10 +949,10 @@ func (m *Messenger) CancelRequestToJoinCommunity(request *requests.CancelRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
rawMessage := common.RawMessage{
|
rawMessage := common.RawMessage{
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
CommunityID: community.ID(),
|
CommunityID: community.ID(),
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_CANCEL_REQUEST_TO_JOIN,
|
||||||
}
|
}
|
||||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||||
|
|
||||||
|
@ -1044,10 +1044,10 @@ func (m *Messenger) AcceptRequestToJoinCommunity(request *requests.AcceptRequest
|
||||||
}
|
}
|
||||||
|
|
||||||
rawMessage := &common.RawMessage{
|
rawMessage := &common.RawMessage{
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
Sender: community.PrivateKey(),
|
Sender: community.PrivateKey(),
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN_RESPONSE,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = m.sender.SendPrivate(context.Background(), pk, rawMessage)
|
_, err = m.sender.SendPrivate(context.Background(), pk, rawMessage)
|
||||||
|
@ -1156,10 +1156,10 @@ func (m *Messenger) LeaveCommunity(communityID types.HexBytes) (*MessengerRespon
|
||||||
}
|
}
|
||||||
|
|
||||||
rawMessage := common.RawMessage{
|
rawMessage := common.RawMessage{
|
||||||
Payload: payload,
|
Payload: payload,
|
||||||
CommunityID: communityID,
|
CommunityID: communityID,
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
|
MessageType: protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_LEAVE,
|
||||||
}
|
}
|
||||||
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
_, err = m.sender.SendCommunityMessage(context.Background(), rawMessage)
|
||||||
if err != nil {
|
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 {
|
func (m *Messenger) SendKeyExchangeMessage(communityID []byte, pubkeys []*ecdsa.PublicKey, msgType common.CommKeyExMsgType) error {
|
||||||
rawMessage := common.RawMessage{
|
rawMessage := common.RawMessage{
|
||||||
SkipEncryption: false,
|
SkipProtocolLayer: false,
|
||||||
CommunityID: communityID,
|
CommunityID: communityID,
|
||||||
CommunityKeyExMsgType: msgType,
|
CommunityKeyExMsgType: msgType,
|
||||||
Recipients: pubkeys,
|
Recipients: pubkeys,
|
||||||
|
|
|
@ -1298,7 +1298,7 @@ func (c *Client) registerWithServer(registration *protobuf.PushNotificationRegis
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION,
|
||||||
// We send on personal topic to avoid a lot of traffic on the partitioned topic
|
// We send on personal topic to avoid a lot of traffic on the partitioned topic
|
||||||
SendOnPersonalTopic: true,
|
SendOnPersonalTopic: true,
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage)
|
_, err = c.messageSender.SendPrivate(context.Background(), server.PublicKey, &rawMessage)
|
||||||
|
@ -1406,8 +1406,8 @@ func (c *Client) SendNotification(publicKey *ecdsa.PublicKey, installationIDs []
|
||||||
Sender: ephemeralKey,
|
Sender: ephemeralKey,
|
||||||
// we skip encryption as we don't want to save any key material
|
// we skip encryption as we don't want to save any key material
|
||||||
// for an ephemeral key, no need to use pfs as these are throw away keys
|
// for an ephemeral key, no need to use pfs as these are throw away keys
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage)
|
_, err = c.messageSender.SendPrivate(context.Background(), serverPublicKey, &rawMessage)
|
||||||
|
@ -1686,8 +1686,8 @@ func (c *Client) queryPushNotificationInfo(publicKey *ecdsa.PublicKey) error {
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
Sender: ephemeralKey,
|
Sender: ephemeralKey,
|
||||||
// we don't want to wrap in an encryption layer message
|
// we don't want to wrap in an encryption layer message
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = c.messageSender.AddEphemeralKey(ephemeralKey)
|
_, err = c.messageSender.AddEphemeralKey(ephemeralKey)
|
||||||
|
|
|
@ -109,7 +109,7 @@ func (s *Server) HandlePushNotificationRegistration(publicKey *ecdsa.PublicKey,
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE,
|
||||||
// we skip encryption as might be sent from an ephemeral key
|
// we skip encryption as might be sent from an ephemeral key
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||||
|
@ -132,7 +132,7 @@ func (s *Server) HandlePushNotificationQuery(publicKey *ecdsa.PublicKey, message
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE,
|
||||||
// we skip encryption as sent from an ephemeral key
|
// we skip encryption as sent from an ephemeral key
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||||
|
@ -175,7 +175,7 @@ func (s *Server) HandlePushNotificationRequest(publicKey *ecdsa.PublicKey,
|
||||||
Payload: encodedMessage,
|
Payload: encodedMessage,
|
||||||
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE,
|
MessageType: protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE,
|
||||||
// We skip encryption here as the message has been sent from an ephemeral key
|
// We skip encryption here as the message has been sent from an ephemeral key
|
||||||
SkipEncryption: true,
|
SkipProtocolLayer: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
_, err = s.messageSender.SendPrivate(context.Background(), publicKey, &rawMessage)
|
||||||
|
|
Loading…
Reference in New Issue