Use separate flag for allowonlyfromcontacst

This commit is contained in:
Andrea Maria Piana 2020-07-20 10:06:24 +02:00
parent bec8fbb855
commit 58817aad5b
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
7 changed files with 188 additions and 262 deletions

View File

@ -1978,6 +1978,18 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
}
// We continue in any case, no changes to messenger
continue
case protobuf.PushNotificationResponse:
logger.Debug("Received PushNotificationResponse")
if m.pushNotificationClient == nil {
continue
}
logger.Debug("Handling PushNotificationResponse")
// TODO: Compare DST with Identity
if err := m.pushNotificationClient.HandlePushNotificationResponse(publicKey, msg.ParsedMessage.(protobuf.PushNotificationResponse)); err != nil {
logger.Warn("failed to handle PushNotificationResponse", zap.Error(err))
}
// We continue in any case, no changes to messenger
continue
case protobuf.PushNotificationQueryResponse:
logger.Debug("Received PushNotificationQueryResponse")

View File

@ -114,19 +114,20 @@ func (PushNotificationReport_ErrorType) EnumDescriptor() ([]byte, []int) {
}
type PushNotificationRegistration struct {
TokenType PushNotificationRegistration_TokenType `protobuf:"varint,1,opt,name=token_type,json=tokenType,proto3,enum=protobuf.PushNotificationRegistration_TokenType" json:"token_type,omitempty"`
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
InstallationId string `protobuf:"bytes,3,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"`
Version uint64 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"`
AllowedUserList [][]byte `protobuf:"bytes,7,rep,name=allowed_user_list,json=allowedUserList,proto3" json:"allowed_user_list,omitempty"`
BlockedChatList [][]byte `protobuf:"bytes,8,rep,name=blocked_chat_list,json=blockedChatList,proto3" json:"blocked_chat_list,omitempty"`
Unregister bool `protobuf:"varint,9,opt,name=unregister,proto3" json:"unregister,omitempty"`
Grant []byte `protobuf:"bytes,10,opt,name=grant,proto3" json:"grant,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
TokenType PushNotificationRegistration_TokenType `protobuf:"varint,1,opt,name=token_type,json=tokenType,proto3,enum=protobuf.PushNotificationRegistration_TokenType" json:"token_type,omitempty"`
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
InstallationId string `protobuf:"bytes,3,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
Enabled bool `protobuf:"varint,5,opt,name=enabled,proto3" json:"enabled,omitempty"`
Version uint64 `protobuf:"varint,6,opt,name=version,proto3" json:"version,omitempty"`
AllowedUserList [][]byte `protobuf:"bytes,7,rep,name=allowed_user_list,json=allowedUserList,proto3" json:"allowed_user_list,omitempty"`
BlockedChatList [][]byte `protobuf:"bytes,8,rep,name=blocked_chat_list,json=blockedChatList,proto3" json:"blocked_chat_list,omitempty"`
Unregister bool `protobuf:"varint,9,opt,name=unregister,proto3" json:"unregister,omitempty"`
Grant []byte `protobuf:"bytes,10,opt,name=grant,proto3" json:"grant,omitempty"`
AllowFromContactsOnly bool `protobuf:"varint,11,opt,name=allow_from_contacts_only,json=allowFromContactsOnly,proto3" json:"allow_from_contacts_only,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationRegistration) Reset() { *m = PushNotificationRegistration{} }
@ -224,6 +225,13 @@ func (m *PushNotificationRegistration) GetGrant() []byte {
return nil
}
func (m *PushNotificationRegistration) GetAllowFromContactsOnly() bool {
if m != nil {
return m.AllowFromContactsOnly
}
return false
}
type PushNotificationRegistrationResponse struct {
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Error PushNotificationRegistrationResponse_ErrorType `protobuf:"varint,2,opt,name=error,proto3,enum=protobuf.PushNotificationRegistrationResponse_ErrorType" json:"error,omitempty"`
@ -794,59 +802,61 @@ func init() {
func init() { proto.RegisterFile("push_notifications.proto", fileDescriptor_200acd86044eaa5d) }
var fileDescriptor_200acd86044eaa5d = []byte{
// 858 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x51, 0x6f, 0xe3, 0x44,
0x10, 0x66, 0x9d, 0xb4, 0x89, 0xa7, 0xa1, 0xcd, 0xad, 0x7a, 0x3d, 0x73, 0xe2, 0x20, 0x67, 0x90,
0x88, 0x0e, 0x29, 0x42, 0x45, 0x82, 0x13, 0x4f, 0x84, 0xd6, 0x2d, 0x56, 0x1b, 0x3b, 0x6c, 0x5c,
0x4e, 0x48, 0x48, 0x96, 0x13, 0x6f, 0x5b, 0xab, 0x39, 0xdb, 0xec, 0xae, 0x8b, 0xf2, 0x80, 0xc4,
0x2f, 0x40, 0xe2, 0x95, 0x5f, 0x81, 0xf8, 0x3b, 0xbc, 0xf1, 0x4b, 0x90, 0xd7, 0x76, 0x70, 0x1c,
0x37, 0xcd, 0x03, 0x4f, 0xf1, 0xcc, 0xce, 0xcc, 0xee, 0x7c, 0xdf, 0xcc, 0x17, 0xd0, 0xe2, 0x84,
0xdf, 0xba, 0x61, 0x24, 0x82, 0xeb, 0x60, 0xe6, 0x89, 0x20, 0x0a, 0xf9, 0x20, 0x66, 0x91, 0x88,
0x70, 0x5b, 0xfe, 0x4c, 0x93, 0x6b, 0xfd, 0xef, 0x06, 0xbc, 0x3f, 0x4e, 0xf8, 0xad, 0x55, 0x8a,
0x22, 0xf4, 0x26, 0xe0, 0x82, 0xc9, 0x6f, 0x6c, 0x03, 0x88, 0xe8, 0x8e, 0x86, 0xae, 0x58, 0xc4,
0x54, 0x43, 0x3d, 0xd4, 0xdf, 0x3f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x49, 0x87, 0xbd, 0xe2, 0xfe, 0x05, 0xde, 0xd2, 0x34, 0x12, 0x78, 0xba, 0x2a, 0x28,
0x52, 0x15, 0xd0, 0x57, 0xd0, 0x28, 0x04, 0x82, 0x17, 0x0c, 0x9f, 0x6d, 0x50, 0xa1, 0x79, 0xec,
0x23, 0xf8, 0x8c, 0xbf, 0x54, 0x38, 0x5e, 0x3d, 0x32, 0xa1, 0x4c, 0x6c, 0x90, 0xc3, 0x6f, 0x16,
0xe5, 0xf0, 0xe5, 0x26, 0x39, 0xcc, 0xb6, 0x5a, 0x2b, 0x80, 0xef, 0x02, 0xa5, 0xf1, 0xd3, 0x36,
0x42, 0x79, 0x00, 0xcd, 0x37, 0xd8, 0xb1, 0x2f, 0xaa, 0xff, 0x12, 0x4b, 0x82, 0xa7, 0x66, 0x3e,
0xdb, 0x71, 0x3d, 0x6c, 0x5e, 0x58, 0x23, 0xd7, 0xc4, 0xe6, 0x59, 0xbb, 0x66, 0xa4, 0xa0, 0xaf,
0x16, 0x54, 0xcc, 0xf3, 0x22, 0x57, 0x65, 0x79, 0x2c, 0xbf, 0x86, 0x3d, 0x26, 0x6b, 0xe7, 0xba,
0x2a, 0xbb, 0xd5, 0x79, 0x0c, 0x12, 0x2e, 0x13, 0xc6, 0xbb, 0x32, 0xf2, 0xcb, 0xff, 0x02, 0x00,
0x00, 0xff, 0xff, 0x90, 0x90, 0x1b, 0xe9, 0xf4, 0x08, 0x00, 0x00,
}

View File

@ -18,6 +18,7 @@ message PushNotificationRegistration {
repeated bytes blocked_chat_list = 8;
bool unregister = 9;
bytes grant = 10;
bool allow_from_contacts_only = 11;
}
message PushNotificationRegistrationResponse {

View File

@ -466,14 +466,15 @@ func (c *Client) buildPushNotificationRegistrationMessage(contactIDs []*ecdsa.Pu
}
options := &protobuf.PushNotificationRegistration{
AccessToken: token,
TokenType: c.config.TokenType,
Version: c.getVersion(),
InstallationId: c.config.InstallationID,
Token: c.deviceToken,
Enabled: c.config.RemoteNotificationsEnabled,
BlockedChatList: c.mutedChatIDsHashes(mutedChatIDs),
AllowedUserList: allowedUserList,
AccessToken: token,
TokenType: c.config.TokenType,
Version: c.getVersion(),
InstallationId: c.config.InstallationID,
Token: c.deviceToken,
AllowFromContactsOnly: c.config.allowFromContactsOnly,
Enabled: c.config.RemoteNotificationsEnabled,
BlockedChatList: c.mutedChatIDsHashes(mutedChatIDs),
AllowedUserList: allowedUserList,
}
return options, nil
}
@ -847,7 +848,7 @@ func (c *Client) HandlePushNotificationQueryResponse(serverPublicKey *ecdsa.Publ
}
// HandlePushNotificationResponse should set the request as processed
func (p *Client) HandlePushNotificationResponse(ack *protobuf.PushNotificationResponse) error {
func (p *Client) HandlePushNotificationResponse(serverKey *ecdsa.PublicKey, response protobuf.PushNotificationResponse) error {
return nil
}

View File

@ -161,7 +161,7 @@ func (s *Server) HandlePushNotificationQuery(query *protobuf.PushNotificationQue
InstallationId: registration.InstallationId,
}
if len(registration.AllowedUserList) > 0 {
if len(registration.AllowedUserList) > 0 && registration.AllowFromContactsOnly {
info.AllowedUserList = registration.AllowedUserList
} else {
info.AccessToken = registration.AccessToken

View File

@ -549,13 +549,14 @@ func (s *ServerSuite) TestHandlePushNotificationQueryWithFiltering() {
// Successful
registration := &protobuf.PushNotificationRegistration{
Token: "abc",
AccessToken: s.accessToken,
Grant: s.grant,
TokenType: protobuf.PushNotificationRegistration_APN_TOKEN,
InstallationId: s.installationID,
AllowedUserList: allowedUserList,
Version: 1,
Token: "abc",
AccessToken: s.accessToken,
Grant: s.grant,
TokenType: protobuf.PushNotificationRegistration_APN_TOKEN,
InstallationId: s.installationID,
AllowFromContactsOnly: true,
AllowedUserList: allowedUserList,
Version: 1,
}
payload, err := proto.Marshal(registration)
s.Require().NoError(err)

View File

@ -7,7 +7,6 @@ import (
"io/ioutil"
"os"
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/suite"
@ -129,36 +128,16 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
err = bob1.RegisterForPushNotifications(context.Background(), bob1DeviceToken)
// Receive message, reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
// Check reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
// Pull servers and check we registered
err = tt.RetryWithBackOff(func() error {
_, err = server.RetrieveAll()
if err != nil {
return err
}
_, err = bob1.RetrieveAll()
if err != nil {
return err
}
registered, err := bob1.RegisteredForPushNotifications()
if err != nil {
return err
@ -180,35 +159,16 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
err = bob2.RegisterForPushNotifications(context.Background(), bob2DeviceToken)
s.Require().NoError(err)
// Receive message, reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
// Check reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
err = tt.RetryWithBackOff(func() error {
_, err = server.RetrieveAll()
if err != nil {
return err
}
_, err = bob2.RetrieveAll()
if err != nil {
return err
}
registered, err := bob2.RegisteredForPushNotifications()
if err != nil {
return err
@ -226,42 +186,32 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
err = alice.pushNotificationClient.QueryPushNotificationInfo(&bob2.identity.PublicKey)
s.Require().NoError(err)
// Receive push notification query
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
var info []*push_notification_client.PushNotificationInfo
err = tt.RetryWithBackOff(func() error {
_, err = server.RetrieveAll()
if err != nil {
return err
}
_, err = alice.RetrieveAll()
if err != nil {
return err
}
info, err = alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
if err != nil {
return err
}
// Check we have replies for both bob1 and bob2
if len(info) != 2 {
return errors.New("info not fetched")
}
return nil
})
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
// Receive push notification query response
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
// Here we should poll, as we don't know whether they are already there
info, err := alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
s.Require().NoError(err)
// Check we have replies for both bob1 and bob2
s.Require().NotNil(info)
s.Require().Len(info, 2)
var bob1Info, bob2Info *push_notification_client.PushNotificationInfo
if info[0].AccessToken == bob1Servers[0].AccessToken {
@ -305,37 +255,18 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationFromContactO
s.Require().NoError(err)
err = bob1.RegisterForPushNotifications(context.Background(), bob1DeviceToken)
// Receive message, reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
// Check reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob1.RetrieveAll()
s.Require().NoError(err)
// Pull servers and check we registered
err = tt.RetryWithBackOff(func() error {
_, err = server.RetrieveAll()
if err != nil {
return err
}
_, err = bob1.RetrieveAll()
if err != nil {
return err
}
registered, err := bob1.RegisteredForPushNotifications()
if err != nil {
return err
@ -357,35 +288,17 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationFromContactO
err = bob2.RegisterForPushNotifications(context.Background(), bob2DeviceToken)
s.Require().NoError(err)
// Receive message, reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
// Check reply
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = bob2.RetrieveAll()
s.Require().NoError(err)
err = tt.RetryWithBackOff(func() error {
// Fetch server messages, for the registration
_, err = server.RetrieveAll()
if err != nil {
return err
}
// Fetch bob messages, for the response
_, err = bob2.RetrieveAll()
if err != nil {
return err
}
registered, err := bob2.RegisteredForPushNotifications()
if err != nil {
return err
@ -403,42 +316,30 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationFromContactO
err = alice.pushNotificationClient.QueryPushNotificationInfo(&bob2.identity.PublicKey)
s.Require().NoError(err)
// Receive push notification query
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
var info []*push_notification_client.PushNotificationInfo
err = tt.RetryWithBackOff(func() error {
_, err = server.RetrieveAll()
if err != nil {
return err
}
_, err = alice.RetrieveAll()
if err != nil {
return err
}
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
s.Require().NoError(err)
info, err = alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
if err != nil {
return err
}
// Check we have replies for both bob1 and bob2
if len(info) != 2 {
return errors.New("info not fetched")
}
return nil
time.Sleep(500 * time.Millisecond)
_, err = server.RetrieveAll()
})
s.Require().NoError(err)
// Receive push notification query response
// TODO: find a better way to handle this waiting
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
time.Sleep(500 * time.Millisecond)
_, err = alice.RetrieveAll()
s.Require().NoError(err)
// Here we should poll, as we don't know whether they are already there
info, err := alice.pushNotificationClient.GetPushNotificationInfo(&bob1.identity.PublicKey, bobInstallationIDs)
s.Require().NoError(err)
// Check we have replies for both bob1 and bob2
s.Require().NotNil(info)
s.Require().Len(info, 2)
var bob1Info, bob2Info *push_notification_client.PushNotificationInfo
if info[0].AccessToken == bob1Servers[0].AccessToken {