Add push notification register message

This commit is contained in:
Andrea Maria Piana 2020-06-30 09:50:59 +02:00
parent c4fa9825a9
commit 92b699b59d
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
16 changed files with 1568 additions and 168 deletions

View File

@ -1,85 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: message.proto
package applicationmetadata
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type Message struct {
Signature []byte `protobuf:"bytes,4001,opt,name=signature,proto3" json:"signature,omitempty"`
Payload []byte `protobuf:"bytes,4002,opt,name=payload,proto3" json:"payload,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{0}
}
func (m *Message) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Message.Unmarshal(m, b)
}
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
}
func (m *Message) XXX_Merge(src proto.Message) {
xxx_messageInfo_Message.Merge(m, src)
}
func (m *Message) XXX_Size() int {
return xxx_messageInfo_Message.Size(m)
}
func (m *Message) XXX_DiscardUnknown() {
xxx_messageInfo_Message.DiscardUnknown(m)
}
var xxx_messageInfo_Message proto.InternalMessageInfo
func (m *Message) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
func (m *Message) GetPayload() []byte {
if m != nil {
return m.Payload
}
return nil
}
func init() {
proto.RegisterType((*Message)(nil), "applicationmetadata.Message")
}
func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) }
var fileDescriptor_33c57e4bae7b9afd = []byte{
// 112 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xcd, 0x4d, 0x2d, 0x2e,
0x4e, 0x4c, 0x4f, 0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4e, 0x2c, 0x28, 0xc8, 0xc9,
0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0xcb, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0x54, 0x72,
0xe6, 0x62, 0xf7, 0x85, 0xa8, 0x12, 0x92, 0xe5, 0xe2, 0x2c, 0xce, 0x4c, 0xcf, 0x4b, 0x2c, 0x29,
0x2d, 0x4a, 0x95, 0x58, 0x28, 0xaf, 0xc0, 0xa8, 0xc1, 0x13, 0x84, 0x10, 0x11, 0x92, 0xe4, 0x62,
0x2f, 0x48, 0xac, 0xcc, 0xc9, 0x4f, 0x4c, 0x91, 0x58, 0x04, 0x91, 0x84, 0xf1, 0x93, 0xd8, 0xc0,
0x16, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xb0, 0x7f, 0x4a, 0x96, 0x71, 0x00, 0x00, 0x00,
}

View File

@ -1,8 +0,0 @@
syntax = "proto3";
package applicationmetadata;
message Message {
bytes signature = 4001;
bytes payload = 4002;
}

View File

@ -1,23 +0,0 @@
package applicationmetadata
import (
"crypto/ecdsa"
"github.com/status-im/status-go/eth-node/crypto"
)
func (m *Message) RecoverKey() (*ecdsa.PublicKey, error) {
if m.Signature == nil {
return nil, nil
}
recoveredKey, err := crypto.SigToPub(
crypto.Keccak256(m.Payload),
m.Signature,
)
if err != nil {
return nil, err
}
return recoveredKey, nil
}

View File

@ -1,17 +0,0 @@
package applicationmetadata
import (
"github.com/golang/protobuf/proto"
)
//go:generate protoc --go_out=. ./message.proto
func Unmarshal(payload []byte) (*Message, error) {
var message Message
err := proto.Unmarshal(payload, &message)
if err != nil {
return nil, err
}
return &message, nil
}

View File

@ -42,6 +42,11 @@ type messageProcessor struct {
logger *zap.Logger logger *zap.Logger
featureFlags featureFlags featureFlags featureFlags
// onMessageSpecSent is a callback that is to be called when
// a message spec is sent.
// The reason is a callback is that datasync dispatches things asynchronously
// through a callback, and therefore return values can't be used
onMessageSpecSent func(*ecdsa.PublicKey, *encryption.ProtocolMessageSpec, [][]byte) error
} }
func newMessageProcessor( func newMessageProcessor(
@ -51,6 +56,7 @@ func newMessageProcessor(
transport transport.Transport, transport transport.Transport,
logger *zap.Logger, logger *zap.Logger,
features featureFlags, features featureFlags,
onMessageSpecSent func(*ecdsa.PublicKey, *encryption.ProtocolMessageSpec, [][]byte) error,
) (*messageProcessor, error) { ) (*messageProcessor, error) {
dataSyncTransport := datasync.NewNodeTransport() dataSyncTransport := datasync.NewNodeTransport()
dataSyncNode, err := datasyncnode.NewPersistentNode( dataSyncNode, err := datasyncnode.NewPersistentNode(
@ -161,12 +167,13 @@ func (p *messageProcessor) sendPrivate(
return nil, errors.Wrap(err, "failed to encrypt message") return nil, errors.Wrap(err, "failed to encrypt message")
} }
hash, newMessage, err := p.sendMessageSpec(ctx, recipient, messageSpec) messageIDs := [][]byte{messageID}
hash, newMessage, err := p.sendMessageSpec(ctx, recipient, messageSpec, messageIDs)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to send a message spec") return nil, errors.Wrap(err, "failed to send a message spec")
} }
p.transport.Track([][]byte{messageID}, hash, newMessage) p.transport.Track(messageIDs, hash, newMessage)
} }
return messageID, nil return messageID, nil
@ -190,13 +197,15 @@ func (p *messageProcessor) SendPairInstallation(
return nil, errors.Wrap(err, "failed to encrypt message") return nil, errors.Wrap(err, "failed to encrypt message")
} }
hash, newMessage, err := p.sendMessageSpec(ctx, recipient, messageSpec) messageID := v1protocol.MessageID(&p.identity.PublicKey, wrappedMessage)
messageIDs := [][]byte{messageID}
hash, newMessage, err := p.sendMessageSpec(ctx, recipient, messageSpec, messageIDs)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to send a message spec") return nil, errors.Wrap(err, "failed to send a message spec")
} }
messageID := v1protocol.MessageID(&p.identity.PublicKey, wrappedMessage) p.transport.Track(messageIDs, hash, newMessage)
p.transport.Track([][]byte{messageID}, hash, newMessage)
return messageID, nil return messageID, nil
} }
@ -330,7 +339,9 @@ func (p *messageProcessor) handleErrDeviceNotFound(ctx context.Context, publicKe
ctx, cancel := context.WithTimeout(ctx, time.Second) ctx, cancel := context.WithTimeout(ctx, time.Second)
defer cancel() defer cancel()
_, _, err = p.sendMessageSpec(ctx, publicKey, messageSpec) // We don't pass an array of messageIDs as no action needs to be taken
// when sending a bundle
_, _, err = p.sendMessageSpec(ctx, publicKey, messageSpec, nil)
if err != nil { if err != nil {
return err return err
} }
@ -381,7 +392,7 @@ func (p *messageProcessor) sendDataSync(ctx context.Context, publicKey *ecdsa.Pu
return errors.Wrap(err, "failed to encrypt message") return errors.Wrap(err, "failed to encrypt message")
} }
hash, newMessage, err := p.sendMessageSpec(ctx, publicKey, messageSpec) hash, newMessage, err := p.sendMessageSpec(ctx, publicKey, messageSpec, messageIDs)
if err != nil { if err != nil {
return err return err
} }
@ -392,7 +403,7 @@ func (p *messageProcessor) sendDataSync(ctx context.Context, publicKey *ecdsa.Pu
} }
// sendMessageSpec analyses the spec properties and selects a proper transport method. // sendMessageSpec analyses the spec properties and selects a proper transport method.
func (p *messageProcessor) sendMessageSpec(ctx context.Context, publicKey *ecdsa.PublicKey, messageSpec *encryption.ProtocolMessageSpec) ([]byte, *types.NewMessage, error) { func (p *messageProcessor) sendMessageSpec(ctx context.Context, publicKey *ecdsa.PublicKey, messageSpec *encryption.ProtocolMessageSpec, messageIDs [][]byte) ([]byte, *types.NewMessage, error) {
newMessage, err := messageSpecToWhisper(messageSpec) newMessage, err := messageSpecToWhisper(messageSpec)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
@ -414,6 +425,13 @@ func (p *messageProcessor) sendMessageSpec(ctx context.Context, publicKey *ecdsa
return nil, nil, err return nil, nil, err
} }
if p.onMessageSpecSent != nil {
if err := p.onMessageSpecSent(publicKey, messageSpec, messageIDs); err != nil {
return nil, nil, err
}
}
return hash, newMessage, nil return hash, newMessage, nil
} }

View File

@ -101,6 +101,7 @@ func (s *MessageProcessorSuite) SetupTest() {
whisperTransport, whisperTransport,
s.logger, s.logger,
featureFlags{}, featureFlags{},
nil,
) )
s.Require().NoError(err) s.Require().NoError(err)
} }

View File

@ -57,6 +57,7 @@ type Messenger struct {
encryptor *encryption.Protocol encryptor *encryption.Protocol
processor *messageProcessor processor *messageProcessor
handler *MessageHandler handler *MessageHandler
pushNotificationService *PushNotificationService
logger *zap.Logger logger *zap.Logger
verifyTransactionClient EthClient verifyTransactionClient EthClient
featureFlags featureFlags featureFlags featureFlags
@ -328,6 +329,9 @@ func NewMessenger(
logger, logger,
) )
pushNotificationPersistence := NewPushNotificationPersistence(database)
pushNotificationService := NewPushNotificationService(pushNotificationPersistence)
processor, err := newMessageProcessor( processor, err := newMessageProcessor(
identity, identity,
database, database,
@ -335,6 +339,7 @@ func NewMessenger(
transp, transp,
logger, logger,
c.featureFlags, c.featureFlags,
pushNotificationService.HandleMessageSent,
) )
if err != nil { if err != nil {
return nil, errors.Wrap(err, "failed to create messageProcessor") return nil, errors.Wrap(err, "failed to create messageProcessor")
@ -350,6 +355,7 @@ func NewMessenger(
encryptor: encryptionProtocol, encryptor: encryptionProtocol,
processor: processor, processor: processor,
handler: handler, handler: handler,
pushNotificationService: pushNotificationService,
featureFlags: c.featureFlags, featureFlags: c.featureFlags,
systemMessagesTranslations: c.systemMessagesTranslations, systemMessagesTranslations: c.systemMessagesTranslations,
allChats: make(map[string]*Chat), allChats: make(map[string]*Chat),
@ -1466,6 +1472,14 @@ func (m *Messenger) SendChatMessage(ctx context.Context, message *Message) (*Mes
return nil, err return nil, err
} }
// If the chat is not public, we instruct the pushNotificationService to send a notification
if !chat.Public() && m.pushNotificationService != nil {
if err := m.pushNotificationService.NotifyOnMessageID(id); err != nil {
return nil, err
}
}
message.ID = types.EncodeHex(id) message.ID = types.EncodeHex(id)
err = message.PrepareContent() err = message.PrepareContent()
if err != nil { if err != nil {

View File

@ -1,7 +1,6 @@
package protocol package protocol
import ( import (
"context"
"crypto/ecdsa" "crypto/ecdsa"
"io/ioutil" "io/ioutil"
"os" "os"

View File

@ -38,6 +38,14 @@ const (
ApplicationMetadataMessage_SYNC_INSTALLATION_CONTACT ApplicationMetadataMessage_Type = 12 ApplicationMetadataMessage_SYNC_INSTALLATION_CONTACT ApplicationMetadataMessage_Type = 12
ApplicationMetadataMessage_SYNC_INSTALLATION_ACCOUNT ApplicationMetadataMessage_Type = 13 ApplicationMetadataMessage_SYNC_INSTALLATION_ACCOUNT ApplicationMetadataMessage_Type = 13
ApplicationMetadataMessage_SYNC_INSTALLATION_PUBLIC_CHAT ApplicationMetadataMessage_Type = 14 ApplicationMetadataMessage_SYNC_INSTALLATION_PUBLIC_CHAT ApplicationMetadataMessage_Type = 14
ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTER ApplicationMetadataMessage_Type = 15
ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE ApplicationMetadataMessage_Type = 16
ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT ApplicationMetadataMessage_Type = 17
ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY ApplicationMetadataMessage_Type = 18
ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_INFO ApplicationMetadataMessage_Type = 19
ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE ApplicationMetadataMessage_Type = 20
ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST ApplicationMetadataMessage_Type = 21
ApplicationMetadataMessage_PUSH_NOTIFICATION_ACKNOWLEDGMENT ApplicationMetadataMessage_Type = 22
) )
var ApplicationMetadataMessage_Type_name = map[int32]string{ var ApplicationMetadataMessage_Type_name = map[int32]string{
@ -56,6 +64,14 @@ var ApplicationMetadataMessage_Type_name = map[int32]string{
12: "SYNC_INSTALLATION_CONTACT", 12: "SYNC_INSTALLATION_CONTACT",
13: "SYNC_INSTALLATION_ACCOUNT", 13: "SYNC_INSTALLATION_ACCOUNT",
14: "SYNC_INSTALLATION_PUBLIC_CHAT", 14: "SYNC_INSTALLATION_PUBLIC_CHAT",
15: "PUSH_NOTIFICATION_REGISTER",
16: "PUSH_NOTIFICATION_REGISTRATION_RESPONSE",
17: "CONTACT_CODE_ADVERTISEMENT",
18: "PUSH_NOTIFICATION_QUERY",
19: "PUSH_NOTIFICATION_QUERY_INFO",
20: "PUSH_NOTIFICATION_QUERY_RESPONSE",
21: "PUSH_NOTIFICATION_REQUEST",
22: "PUSH_NOTIFICATION_ACKNOWLEDGMENT",
} }
var ApplicationMetadataMessage_Type_value = map[string]int32{ var ApplicationMetadataMessage_Type_value = map[string]int32{
@ -74,6 +90,14 @@ var ApplicationMetadataMessage_Type_value = map[string]int32{
"SYNC_INSTALLATION_CONTACT": 12, "SYNC_INSTALLATION_CONTACT": 12,
"SYNC_INSTALLATION_ACCOUNT": 13, "SYNC_INSTALLATION_ACCOUNT": 13,
"SYNC_INSTALLATION_PUBLIC_CHAT": 14, "SYNC_INSTALLATION_PUBLIC_CHAT": 14,
"PUSH_NOTIFICATION_REGISTER": 15,
"PUSH_NOTIFICATION_REGISTRATION_RESPONSE": 16,
"CONTACT_CODE_ADVERTISEMENT": 17,
"PUSH_NOTIFICATION_QUERY": 18,
"PUSH_NOTIFICATION_QUERY_INFO": 19,
"PUSH_NOTIFICATION_QUERY_RESPONSE": 20,
"PUSH_NOTIFICATION_REQUEST": 21,
"PUSH_NOTIFICATION_ACKNOWLEDGMENT": 22,
} }
func (x ApplicationMetadataMessage_Type) String() string { func (x ApplicationMetadataMessage_Type) String() string {
@ -150,29 +174,35 @@ func init() {
func init() { proto.RegisterFile("application_metadata_message.proto", fileDescriptor_ad09a6406fcf24c7) } func init() { proto.RegisterFile("application_metadata_message.proto", fileDescriptor_ad09a6406fcf24c7) }
var fileDescriptor_ad09a6406fcf24c7 = []byte{ var fileDescriptor_ad09a6406fcf24c7 = []byte{
// 377 bytes of a gzipped FileDescriptorProto // 479 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xcf, 0x8e, 0xd3, 0x30, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x52, 0x13, 0x41,
0x10, 0xc6, 0xc9, 0x36, 0x6c, 0x77, 0x67, 0x4b, 0x65, 0x06, 0x10, 0xe1, 0xcf, 0x6a, 0x97, 0x22, 0x10, 0xc7, 0x0d, 0x1f, 0x09, 0x34, 0x31, 0x0e, 0x0d, 0x48, 0xe4, 0x43, 0x62, 0xb4, 0x14, 0xb5,
0xc1, 0x02, 0x52, 0x0e, 0x70, 0xe6, 0xe0, 0x75, 0x0c, 0x1b, 0x91, 0x38, 0xc1, 0x76, 0x84, 0x38, 0x2a, 0x07, 0x3d, 0x7b, 0x18, 0x66, 0x3b, 0xc9, 0x94, 0xd9, 0xd9, 0x65, 0x66, 0x56, 0x8b, 0xd3,
0x59, 0x2e, 0x0d, 0x55, 0xa5, 0xb6, 0x89, 0xda, 0xf4, 0xd0, 0x07, 0xe3, 0x29, 0x78, 0x29, 0x94, 0xd4, 0x22, 0x2b, 0x95, 0x2a, 0x20, 0x5b, 0x64, 0x39, 0xe4, 0x1d, 0x7d, 0x0a, 0x9f, 0xc4, 0xda,
0xd0, 0xd2, 0x96, 0x82, 0x7a, 0xb2, 0xe6, 0xfb, 0x7e, 0x9f, 0x47, 0x33, 0x03, 0x3d, 0x5b, 0x96, 0x25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7b, 0x8e, 0x6f, 0x60, 0x7f,
0x14, 0x32, 0x53, 0xdf, 0x85, 0x74, 0xfb, 0xc7, 0xcd, 0x9d, 0xdf, 0xfd, 0x0a, 0x00, 0x00, 0xff, 0xda, 0x0e, 0xa3, 0xa3, 0x9e, 0x14, 0x2e, 0xff, 0x17, 0x56, 0xc3, 0xd7, 0xb0, 0x13, 0x46, 0xa6,
0xff, 0xb7, 0x6c, 0xd6, 0xba, 0x84, 0x02, 0x00, 0x00, 0xeb, 0x54, 0x60, 0x65, 0x5b, 0x8a, 0x5b, 0x44, 0x53, 0x47, 0x1a, 0x4b, 0x9a, 0xbd, 0xc8, 0x5f,
0x3f, 0xcf, 0xd7, 0x93, 0xc0, 0x84, 0x81, 0x32, 0xc4, 0x58, 0x5e, 0x6c, 0xf2, 0xb9, 0x22, 0xf0,
0xc8, 0x71, 0xef, 0x07, 0x69, 0x2b, 0x0d, 0xf9, 0xa4, 0x2c, 0x5b, 0xc7, 0x5d, 0xd8, 0x9e, 0x2e,
0x76, 0x1c, 0x91, 0x3e, 0x61, 0x88, 0x0d, 0xd8, 0x9b, 0x63, 0x3a, 0xa9, 0xda, 0x01, 0xdb, 0xc0,
0x77, 0xd0, 0x98, 0x47, 0xdc, 0x35, 0xb1, 0x99, 0xcf, 0x64, 0x56, 0xc7, 0xc5, 0x74, 0xd9, 0xd6,
0xec, 0x22, 0x5c, 0xe4, 0x1b, 0xdb, 0x23, 0xaf, 0x53, 0x74, 0xfa, 0xf2, 0xb4, 0x5c, 0xac, 0xff,
0xd7, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x68, 0x53, 0x0e, 0x30, 0x9b, 0x03, 0x00, 0x00,
} }

View File

@ -27,5 +27,13 @@ message ApplicationMetadataMessage {
SYNC_INSTALLATION_CONTACT = 12; SYNC_INSTALLATION_CONTACT = 12;
SYNC_INSTALLATION_ACCOUNT = 13; SYNC_INSTALLATION_ACCOUNT = 13;
SYNC_INSTALLATION_PUBLIC_CHAT = 14; SYNC_INSTALLATION_PUBLIC_CHAT = 14;
PUSH_NOTIFICATION_REGISTER = 15;
PUSH_NOTIFICATION_REGISTRATION_RESPONSE = 16;
CONTACT_CODE_ADVERTISEMENT = 17;
PUSH_NOTIFICATION_QUERY = 18;
PUSH_NOTIFICATION_QUERY_INFO = 19;
PUSH_NOTIFICATION_QUERY_RESPONSE = 20;
PUSH_NOTIFICATION_REQUEST = 21;
PUSH_NOTIFICATION_ACKNOWLEDGMENT = 22;
} }
} }

View File

@ -0,0 +1,845 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// source: push_notifications.proto
package protobuf
import (
fmt "fmt"
proto "github.com/golang/protobuf/proto"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
type PushNotificationOptions_TokenType int32
const (
PushNotificationOptions_UNKNOWN_TOKEN_TYPE PushNotificationOptions_TokenType = 0
PushNotificationOptions_APN_TOKEN PushNotificationOptions_TokenType = 1
PushNotificationOptions_FIREBASE_TOKEN PushNotificationOptions_TokenType = 2
)
var PushNotificationOptions_TokenType_name = map[int32]string{
0: "UNKNOWN_TOKEN_TYPE",
1: "APN_TOKEN",
2: "FIREBASE_TOKEN",
}
var PushNotificationOptions_TokenType_value = map[string]int32{
"UNKNOWN_TOKEN_TYPE": 0,
"APN_TOKEN": 1,
"FIREBASE_TOKEN": 2,
}
func (x PushNotificationOptions_TokenType) String() string {
return proto.EnumName(PushNotificationOptions_TokenType_name, int32(x))
}
func (PushNotificationOptions_TokenType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{1, 0}
}
type PushNotificationRegistrationResponse_ErrorType int32
const (
PushNotificationRegistrationResponse_UNKNOWN_ERROR_TYPE PushNotificationRegistrationResponse_ErrorType = 0
PushNotificationRegistrationResponse_MALFORMED_MESSAGE PushNotificationRegistrationResponse_ErrorType = 1
PushNotificationRegistrationResponse_VERSION_MISMATCH PushNotificationRegistrationResponse_ErrorType = 2
PushNotificationRegistrationResponse_UNSUPPORTED_TOKEN_TYPE PushNotificationRegistrationResponse_ErrorType = 3
PushNotificationRegistrationResponse_INTERNAL_ERROR PushNotificationRegistrationResponse_ErrorType = 4
)
var PushNotificationRegistrationResponse_ErrorType_name = map[int32]string{
0: "UNKNOWN_ERROR_TYPE",
1: "MALFORMED_MESSAGE",
2: "VERSION_MISMATCH",
3: "UNSUPPORTED_TOKEN_TYPE",
4: "INTERNAL_ERROR",
}
var PushNotificationRegistrationResponse_ErrorType_value = map[string]int32{
"UNKNOWN_ERROR_TYPE": 0,
"MALFORMED_MESSAGE": 1,
"VERSION_MISMATCH": 2,
"UNSUPPORTED_TOKEN_TYPE": 3,
"INTERNAL_ERROR": 4,
}
func (x PushNotificationRegistrationResponse_ErrorType) String() string {
return proto.EnumName(PushNotificationRegistrationResponse_ErrorType_name, int32(x))
}
func (PushNotificationRegistrationResponse_ErrorType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{4, 0}
}
type PushNotificationTokenPair struct {
Token []byte `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
PublicKey []byte `protobuf:"bytes,2,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationTokenPair) Reset() { *m = PushNotificationTokenPair{} }
func (m *PushNotificationTokenPair) String() string { return proto.CompactTextString(m) }
func (*PushNotificationTokenPair) ProtoMessage() {}
func (*PushNotificationTokenPair) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{0}
}
func (m *PushNotificationTokenPair) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationTokenPair.Unmarshal(m, b)
}
func (m *PushNotificationTokenPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationTokenPair.Marshal(b, m, deterministic)
}
func (m *PushNotificationTokenPair) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationTokenPair.Merge(m, src)
}
func (m *PushNotificationTokenPair) XXX_Size() int {
return xxx_messageInfo_PushNotificationTokenPair.Size(m)
}
func (m *PushNotificationTokenPair) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationTokenPair.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationTokenPair proto.InternalMessageInfo
func (m *PushNotificationTokenPair) GetToken() []byte {
if m != nil {
return m.Token
}
return nil
}
func (m *PushNotificationTokenPair) GetPublicKey() []byte {
if m != nil {
return m.PublicKey
}
return nil
}
type PushNotificationOptions struct {
TokenType PushNotificationOptions_TokenType `protobuf:"varint,1,opt,name=token_type,json=tokenType,proto3,enum=protobuf.PushNotificationOptions_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"`
Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"`
AllowedUserList []*PushNotificationTokenPair `protobuf:"bytes,5,rep,name=allowed_user_list,json=allowedUserList,proto3" json:"allowed_user_list,omitempty"`
BlockedChatList [][]byte `protobuf:"bytes,6,rep,name=blocked_chat_list,json=blockedChatList,proto3" json:"blocked_chat_list,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationOptions) Reset() { *m = PushNotificationOptions{} }
func (m *PushNotificationOptions) String() string { return proto.CompactTextString(m) }
func (*PushNotificationOptions) ProtoMessage() {}
func (*PushNotificationOptions) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{1}
}
func (m *PushNotificationOptions) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationOptions.Unmarshal(m, b)
}
func (m *PushNotificationOptions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationOptions.Marshal(b, m, deterministic)
}
func (m *PushNotificationOptions) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationOptions.Merge(m, src)
}
func (m *PushNotificationOptions) XXX_Size() int {
return xxx_messageInfo_PushNotificationOptions.Size(m)
}
func (m *PushNotificationOptions) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationOptions.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationOptions proto.InternalMessageInfo
func (m *PushNotificationOptions) GetTokenType() PushNotificationOptions_TokenType {
if m != nil {
return m.TokenType
}
return PushNotificationOptions_UNKNOWN_TOKEN_TYPE
}
func (m *PushNotificationOptions) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
func (m *PushNotificationOptions) GetInstallationId() string {
if m != nil {
return m.InstallationId
}
return ""
}
func (m *PushNotificationOptions) GetEnabled() bool {
if m != nil {
return m.Enabled
}
return false
}
func (m *PushNotificationOptions) GetAllowedUserList() []*PushNotificationTokenPair {
if m != nil {
return m.AllowedUserList
}
return nil
}
func (m *PushNotificationOptions) GetBlockedChatList() [][]byte {
if m != nil {
return m.BlockedChatList
}
return nil
}
type PushNotificationPreferences struct {
Options []*PushNotificationOptions `protobuf:"bytes,1,rep,name=options,proto3" json:"options,omitempty"`
Version uint64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
Unregister bool `protobuf:"varint,3,opt,name=unregister,proto3" json:"unregister,omitempty"`
AccessToken string `protobuf:"bytes,4,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationPreferences) Reset() { *m = PushNotificationPreferences{} }
func (m *PushNotificationPreferences) String() string { return proto.CompactTextString(m) }
func (*PushNotificationPreferences) ProtoMessage() {}
func (*PushNotificationPreferences) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{2}
}
func (m *PushNotificationPreferences) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationPreferences.Unmarshal(m, b)
}
func (m *PushNotificationPreferences) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationPreferences.Marshal(b, m, deterministic)
}
func (m *PushNotificationPreferences) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationPreferences.Merge(m, src)
}
func (m *PushNotificationPreferences) XXX_Size() int {
return xxx_messageInfo_PushNotificationPreferences.Size(m)
}
func (m *PushNotificationPreferences) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationPreferences.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationPreferences proto.InternalMessageInfo
func (m *PushNotificationPreferences) GetOptions() []*PushNotificationOptions {
if m != nil {
return m.Options
}
return nil
}
func (m *PushNotificationPreferences) GetVersion() uint64 {
if m != nil {
return m.Version
}
return 0
}
func (m *PushNotificationPreferences) GetUnregister() bool {
if m != nil {
return m.Unregister
}
return false
}
func (m *PushNotificationPreferences) GetAccessToken() string {
if m != nil {
return m.AccessToken
}
return ""
}
type PushNotificationRegister struct {
Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationRegister) Reset() { *m = PushNotificationRegister{} }
func (m *PushNotificationRegister) String() string { return proto.CompactTextString(m) }
func (*PushNotificationRegister) ProtoMessage() {}
func (*PushNotificationRegister) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{3}
}
func (m *PushNotificationRegister) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationRegister.Unmarshal(m, b)
}
func (m *PushNotificationRegister) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationRegister.Marshal(b, m, deterministic)
}
func (m *PushNotificationRegister) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationRegister.Merge(m, src)
}
func (m *PushNotificationRegister) XXX_Size() int {
return xxx_messageInfo_PushNotificationRegister.Size(m)
}
func (m *PushNotificationRegister) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationRegister.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationRegister proto.InternalMessageInfo
func (m *PushNotificationRegister) GetPayload() []byte {
if m != nil {
return m.Payload
}
return nil
}
func (m *PushNotificationRegister) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
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"`
RequestId []byte `protobuf:"bytes,3,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
Preferences *PushNotificationPreferences `protobuf:"bytes,4,opt,name=preferences,proto3" json:"preferences,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationRegistrationResponse) Reset() { *m = PushNotificationRegistrationResponse{} }
func (m *PushNotificationRegistrationResponse) String() string { return proto.CompactTextString(m) }
func (*PushNotificationRegistrationResponse) ProtoMessage() {}
func (*PushNotificationRegistrationResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{4}
}
func (m *PushNotificationRegistrationResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationRegistrationResponse.Unmarshal(m, b)
}
func (m *PushNotificationRegistrationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationRegistrationResponse.Marshal(b, m, deterministic)
}
func (m *PushNotificationRegistrationResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationRegistrationResponse.Merge(m, src)
}
func (m *PushNotificationRegistrationResponse) XXX_Size() int {
return xxx_messageInfo_PushNotificationRegistrationResponse.Size(m)
}
func (m *PushNotificationRegistrationResponse) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationRegistrationResponse.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationRegistrationResponse proto.InternalMessageInfo
func (m *PushNotificationRegistrationResponse) GetSuccess() bool {
if m != nil {
return m.Success
}
return false
}
func (m *PushNotificationRegistrationResponse) GetError() PushNotificationRegistrationResponse_ErrorType {
if m != nil {
return m.Error
}
return PushNotificationRegistrationResponse_UNKNOWN_ERROR_TYPE
}
func (m *PushNotificationRegistrationResponse) GetRequestId() []byte {
if m != nil {
return m.RequestId
}
return nil
}
func (m *PushNotificationRegistrationResponse) GetPreferences() *PushNotificationPreferences {
if m != nil {
return m.Preferences
}
return nil
}
type PushNotificationAdvertisementInfo struct {
PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
AccessToken string `protobuf:"bytes,2,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
InstallationId string `protobuf:"bytes,3,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationAdvertisementInfo) Reset() { *m = PushNotificationAdvertisementInfo{} }
func (m *PushNotificationAdvertisementInfo) String() string { return proto.CompactTextString(m) }
func (*PushNotificationAdvertisementInfo) ProtoMessage() {}
func (*PushNotificationAdvertisementInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{5}
}
func (m *PushNotificationAdvertisementInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationAdvertisementInfo.Unmarshal(m, b)
}
func (m *PushNotificationAdvertisementInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationAdvertisementInfo.Marshal(b, m, deterministic)
}
func (m *PushNotificationAdvertisementInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationAdvertisementInfo.Merge(m, src)
}
func (m *PushNotificationAdvertisementInfo) XXX_Size() int {
return xxx_messageInfo_PushNotificationAdvertisementInfo.Size(m)
}
func (m *PushNotificationAdvertisementInfo) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationAdvertisementInfo.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationAdvertisementInfo proto.InternalMessageInfo
func (m *PushNotificationAdvertisementInfo) GetPublicKey() []byte {
if m != nil {
return m.PublicKey
}
return nil
}
func (m *PushNotificationAdvertisementInfo) GetAccessToken() string {
if m != nil {
return m.AccessToken
}
return ""
}
func (m *PushNotificationAdvertisementInfo) GetInstallationId() string {
if m != nil {
return m.InstallationId
}
return ""
}
type ContactCodeAdvertisement struct {
PushNotificationInfo []*PushNotificationAdvertisementInfo `protobuf:"bytes,1,rep,name=push_notification_info,json=pushNotificationInfo,proto3" json:"push_notification_info,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ContactCodeAdvertisement) Reset() { *m = ContactCodeAdvertisement{} }
func (m *ContactCodeAdvertisement) String() string { return proto.CompactTextString(m) }
func (*ContactCodeAdvertisement) ProtoMessage() {}
func (*ContactCodeAdvertisement) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{6}
}
func (m *ContactCodeAdvertisement) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ContactCodeAdvertisement.Unmarshal(m, b)
}
func (m *ContactCodeAdvertisement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_ContactCodeAdvertisement.Marshal(b, m, deterministic)
}
func (m *ContactCodeAdvertisement) XXX_Merge(src proto.Message) {
xxx_messageInfo_ContactCodeAdvertisement.Merge(m, src)
}
func (m *ContactCodeAdvertisement) XXX_Size() int {
return xxx_messageInfo_ContactCodeAdvertisement.Size(m)
}
func (m *ContactCodeAdvertisement) XXX_DiscardUnknown() {
xxx_messageInfo_ContactCodeAdvertisement.DiscardUnknown(m)
}
var xxx_messageInfo_ContactCodeAdvertisement proto.InternalMessageInfo
func (m *ContactCodeAdvertisement) GetPushNotificationInfo() []*PushNotificationAdvertisementInfo {
if m != nil {
return m.PushNotificationInfo
}
return nil
}
type PushNotificationQuery struct {
PublicKeys [][]byte `protobuf:"bytes,1,rep,name=public_keys,json=publicKeys,proto3" json:"public_keys,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationQuery) Reset() { *m = PushNotificationQuery{} }
func (m *PushNotificationQuery) String() string { return proto.CompactTextString(m) }
func (*PushNotificationQuery) ProtoMessage() {}
func (*PushNotificationQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{7}
}
func (m *PushNotificationQuery) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationQuery.Unmarshal(m, b)
}
func (m *PushNotificationQuery) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationQuery.Marshal(b, m, deterministic)
}
func (m *PushNotificationQuery) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationQuery.Merge(m, src)
}
func (m *PushNotificationQuery) XXX_Size() int {
return xxx_messageInfo_PushNotificationQuery.Size(m)
}
func (m *PushNotificationQuery) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationQuery.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationQuery proto.InternalMessageInfo
func (m *PushNotificationQuery) GetPublicKeys() [][]byte {
if m != nil {
return m.PublicKeys
}
return nil
}
type PushNotificationQueryInfo struct {
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
InstallationId string `protobuf:"bytes,2,opt,name=installation_id,json=installationId,proto3" json:"installation_id,omitempty"`
PublicKey []byte `protobuf:"bytes,3,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
AllowedUserList []byte `protobuf:"bytes,4,opt,name=allowed_user_list,json=allowedUserList,proto3" json:"allowed_user_list,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationQueryInfo) Reset() { *m = PushNotificationQueryInfo{} }
func (m *PushNotificationQueryInfo) String() string { return proto.CompactTextString(m) }
func (*PushNotificationQueryInfo) ProtoMessage() {}
func (*PushNotificationQueryInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{8}
}
func (m *PushNotificationQueryInfo) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationQueryInfo.Unmarshal(m, b)
}
func (m *PushNotificationQueryInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationQueryInfo.Marshal(b, m, deterministic)
}
func (m *PushNotificationQueryInfo) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationQueryInfo.Merge(m, src)
}
func (m *PushNotificationQueryInfo) XXX_Size() int {
return xxx_messageInfo_PushNotificationQueryInfo.Size(m)
}
func (m *PushNotificationQueryInfo) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationQueryInfo.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationQueryInfo proto.InternalMessageInfo
func (m *PushNotificationQueryInfo) GetAccessToken() string {
if m != nil {
return m.AccessToken
}
return ""
}
func (m *PushNotificationQueryInfo) GetInstallationId() string {
if m != nil {
return m.InstallationId
}
return ""
}
func (m *PushNotificationQueryInfo) GetPublicKey() []byte {
if m != nil {
return m.PublicKey
}
return nil
}
func (m *PushNotificationQueryInfo) GetAllowedUserList() []byte {
if m != nil {
return m.AllowedUserList
}
return nil
}
type PushNotificationQueryResponse struct {
Info []*PushNotificationQueryInfo `protobuf:"bytes,1,rep,name=info,proto3" json:"info,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationQueryResponse) Reset() { *m = PushNotificationQueryResponse{} }
func (m *PushNotificationQueryResponse) String() string { return proto.CompactTextString(m) }
func (*PushNotificationQueryResponse) ProtoMessage() {}
func (*PushNotificationQueryResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{9}
}
func (m *PushNotificationQueryResponse) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationQueryResponse.Unmarshal(m, b)
}
func (m *PushNotificationQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationQueryResponse.Marshal(b, m, deterministic)
}
func (m *PushNotificationQueryResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationQueryResponse.Merge(m, src)
}
func (m *PushNotificationQueryResponse) XXX_Size() int {
return xxx_messageInfo_PushNotificationQueryResponse.Size(m)
}
func (m *PushNotificationQueryResponse) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationQueryResponse.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationQueryResponse proto.InternalMessageInfo
func (m *PushNotificationQueryResponse) GetInfo() []*PushNotificationQueryInfo {
if m != nil {
return m.Info
}
return nil
}
type PushNotification struct {
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
ChatId string `protobuf:"bytes,2,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotification) Reset() { *m = PushNotification{} }
func (m *PushNotification) String() string { return proto.CompactTextString(m) }
func (*PushNotification) ProtoMessage() {}
func (*PushNotification) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{10}
}
func (m *PushNotification) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotification.Unmarshal(m, b)
}
func (m *PushNotification) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotification.Marshal(b, m, deterministic)
}
func (m *PushNotification) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotification.Merge(m, src)
}
func (m *PushNotification) XXX_Size() int {
return xxx_messageInfo_PushNotification.Size(m)
}
func (m *PushNotification) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotification.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotification proto.InternalMessageInfo
func (m *PushNotification) GetAccessToken() string {
if m != nil {
return m.AccessToken
}
return ""
}
func (m *PushNotification) GetChatId() string {
if m != nil {
return m.ChatId
}
return ""
}
type PushNotificationRequest struct {
Requests []*PushNotification `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"`
Message []byte `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
MessageId string `protobuf:"bytes,3,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
AckRequired string `protobuf:"bytes,4,opt,name=ack_required,json=ackRequired,proto3" json:"ack_required,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationRequest) Reset() { *m = PushNotificationRequest{} }
func (m *PushNotificationRequest) String() string { return proto.CompactTextString(m) }
func (*PushNotificationRequest) ProtoMessage() {}
func (*PushNotificationRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{11}
}
func (m *PushNotificationRequest) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationRequest.Unmarshal(m, b)
}
func (m *PushNotificationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationRequest.Marshal(b, m, deterministic)
}
func (m *PushNotificationRequest) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationRequest.Merge(m, src)
}
func (m *PushNotificationRequest) XXX_Size() int {
return xxx_messageInfo_PushNotificationRequest.Size(m)
}
func (m *PushNotificationRequest) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationRequest.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationRequest proto.InternalMessageInfo
func (m *PushNotificationRequest) GetRequests() []*PushNotification {
if m != nil {
return m.Requests
}
return nil
}
func (m *PushNotificationRequest) GetMessage() []byte {
if m != nil {
return m.Message
}
return nil
}
func (m *PushNotificationRequest) GetMessageId() string {
if m != nil {
return m.MessageId
}
return ""
}
func (m *PushNotificationRequest) GetAckRequired() string {
if m != nil {
return m.AckRequired
}
return ""
}
type PushNotificationAcknowledgement struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *PushNotificationAcknowledgement) Reset() { *m = PushNotificationAcknowledgement{} }
func (m *PushNotificationAcknowledgement) String() string { return proto.CompactTextString(m) }
func (*PushNotificationAcknowledgement) ProtoMessage() {}
func (*PushNotificationAcknowledgement) Descriptor() ([]byte, []int) {
return fileDescriptor_200acd86044eaa5d, []int{12}
}
func (m *PushNotificationAcknowledgement) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_PushNotificationAcknowledgement.Unmarshal(m, b)
}
func (m *PushNotificationAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_PushNotificationAcknowledgement.Marshal(b, m, deterministic)
}
func (m *PushNotificationAcknowledgement) XXX_Merge(src proto.Message) {
xxx_messageInfo_PushNotificationAcknowledgement.Merge(m, src)
}
func (m *PushNotificationAcknowledgement) XXX_Size() int {
return xxx_messageInfo_PushNotificationAcknowledgement.Size(m)
}
func (m *PushNotificationAcknowledgement) XXX_DiscardUnknown() {
xxx_messageInfo_PushNotificationAcknowledgement.DiscardUnknown(m)
}
var xxx_messageInfo_PushNotificationAcknowledgement proto.InternalMessageInfo
func (m *PushNotificationAcknowledgement) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func init() {
proto.RegisterEnum("protobuf.PushNotificationOptions_TokenType", PushNotificationOptions_TokenType_name, PushNotificationOptions_TokenType_value)
proto.RegisterEnum("protobuf.PushNotificationRegistrationResponse_ErrorType", PushNotificationRegistrationResponse_ErrorType_name, PushNotificationRegistrationResponse_ErrorType_value)
proto.RegisterType((*PushNotificationTokenPair)(nil), "protobuf.PushNotificationTokenPair")
proto.RegisterType((*PushNotificationOptions)(nil), "protobuf.PushNotificationOptions")
proto.RegisterType((*PushNotificationPreferences)(nil), "protobuf.PushNotificationPreferences")
proto.RegisterType((*PushNotificationRegister)(nil), "protobuf.PushNotificationRegister")
proto.RegisterType((*PushNotificationRegistrationResponse)(nil), "protobuf.PushNotificationRegistrationResponse")
proto.RegisterType((*PushNotificationAdvertisementInfo)(nil), "protobuf.PushNotificationAdvertisementInfo")
proto.RegisterType((*ContactCodeAdvertisement)(nil), "protobuf.ContactCodeAdvertisement")
proto.RegisterType((*PushNotificationQuery)(nil), "protobuf.PushNotificationQuery")
proto.RegisterType((*PushNotificationQueryInfo)(nil), "protobuf.PushNotificationQueryInfo")
proto.RegisterType((*PushNotificationQueryResponse)(nil), "protobuf.PushNotificationQueryResponse")
proto.RegisterType((*PushNotification)(nil), "protobuf.PushNotification")
proto.RegisterType((*PushNotificationRequest)(nil), "protobuf.PushNotificationRequest")
proto.RegisterType((*PushNotificationAcknowledgement)(nil), "protobuf.PushNotificationAcknowledgement")
}
func init() { proto.RegisterFile("push_notifications.proto", fileDescriptor_200acd86044eaa5d) }
var fileDescriptor_200acd86044eaa5d = []byte{
// 876 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xdf, 0x6f, 0xe3, 0x44,
0x10, 0xc6, 0x49, 0xda, 0xc6, 0x93, 0x90, 0xa6, 0xab, 0x5e, 0xcf, 0x1c, 0x1c, 0xd7, 0x1a, 0x10,
0xd5, 0x21, 0x45, 0xa2, 0x48, 0x70, 0x12, 0x4f, 0xa1, 0xe7, 0x1e, 0xa6, 0x8d, 0x13, 0x36, 0x29,
0x3f, 0x9e, 0x2c, 0xc7, 0xde, 0xb4, 0xab, 0xf8, 0xbc, 0x66, 0x77, 0x7d, 0xa7, 0x3c, 0x20, 0x21,
0xf1, 0xce, 0x7f, 0xc2, 0x0b, 0x2f, 0xfc, 0x71, 0xbc, 0x20, 0xaf, 0x7f, 0xd4, 0x75, 0xd2, 0x5e,
0x9f, 0xe2, 0x99, 0xdd, 0x99, 0x9d, 0xf9, 0xe6, 0x9b, 0x2f, 0x60, 0xc4, 0x89, 0xb8, 0x76, 0x23,
0x26, 0xe9, 0x82, 0xfa, 0x9e, 0xa4, 0x2c, 0x12, 0x83, 0x98, 0x33, 0xc9, 0x50, 0x5b, 0xfd, 0xcc,
0x93, 0x85, 0x39, 0x81, 0x0f, 0x26, 0x89, 0xb8, 0x76, 0x2a, 0x97, 0x66, 0x6c, 0x49, 0xa2, 0x89,
0x47, 0x39, 0xda, 0x87, 0x2d, 0x99, 0x1a, 0x86, 0x76, 0xa8, 0x1d, 0x77, 0x71, 0x66, 0xa0, 0xa7,
0x00, 0x71, 0x32, 0x0f, 0xa9, 0xef, 0x2e, 0xc9, 0xca, 0x68, 0xa8, 0x23, 0x3d, 0xf3, 0x9c, 0x93,
0x95, 0xf9, 0x67, 0x13, 0x1e, 0xd7, 0x53, 0x8e, 0x63, 0xf5, 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 0x79, 0xbc, 0x3d, 0x8d, 0x66, 0x7d, 0x1a, 0xcf, 0x37, 0x69, 0x64, 0x4b, 0xdd, 0xaa,
0xcb, 0x9f, 0xf9, 0x0b, 0x3c, 0xdd, 0x58, 0x73, 0xb9, 0x74, 0xdf, 0x40, 0xab, 0x02, 0xf0, 0x3d,
0x1a, 0x5b, 0xb6, 0x8a, 0x55, 0x80, 0xe9, 0x40, 0xbf, 0x7e, 0xe5, 0x21, 0x20, 0x3c, 0x86, 0x1d,
0xa5, 0xc3, 0x65, 0xf3, 0xdb, 0xa9, 0x69, 0x07, 0xe6, 0xdf, 0xda, 0xfa, 0x5f, 0x17, 0xce, 0x56,
0x12, 0x7d, 0x0d, 0xed, 0x7c, 0x3b, 0x0b, 0xc5, 0x7c, 0x72, 0x8f, 0x04, 0x94, 0x77, 0x53, 0x45,
0x79, 0x4d, 0x84, 0xf0, 0xae, 0x0a, 0x59, 0x2a, 0xcc, 0x14, 0xe2, 0xfc, 0xf3, 0x86, 0xa9, 0x7a,
0xee, 0xb1, 0x83, 0xac, 0x91, 0xa5, 0x9b, 0x26, 0xa2, 0x3c, 0xff, 0x97, 0x52, 0x8d, 0x2c, 0x71,
0xee, 0x32, 0xbf, 0x84, 0x67, 0x6b, 0x1c, 0xf4, 0x97, 0x11, 0x7b, 0x1b, 0x92, 0xe0, 0x2a, 0xa3,
0x73, 0x0f, 0x1a, 0x34, 0xc8, 0x41, 0x68, 0xd0, 0x60, 0xbe, 0xad, 0x6a, 0xfe, 0xea, 0xff, 0x00,
0x00, 0x00, 0xff, 0xff, 0xc3, 0x71, 0xe1, 0x4f, 0x1c, 0x08, 0x00, 0x00,
}

View File

@ -0,0 +1,91 @@
syntax = "proto3";
package protobuf;
message PushNotificationTokenPair {
bytes token = 1;
bytes public_key = 2;
}
message PushNotificationOptions {
enum TokenType {
UNKNOWN_TOKEN_TYPE = 0;
APN_TOKEN = 1;
FIREBASE_TOKEN = 2;
}
TokenType token_type = 1;
string token = 2;
string installation_id = 3;
bool enabled = 4;
repeated PushNotificationTokenPair allowed_user_list = 5;
repeated bytes blocked_chat_list = 6;
}
message PushNotificationPreferences {
repeated PushNotificationOptions options = 1;
uint64 version = 2;
bool unregister = 3;
string access_token = 4;
}
message PushNotificationRegister {
bytes payload = 1;
bytes signature = 2;
}
message PushNotificationRegistrationResponse {
bool success = 1;
ErrorType error = 2;
bytes request_id = 3;
PushNotificationPreferences preferences = 4;
enum ErrorType {
UNKNOWN_ERROR_TYPE = 0;
MALFORMED_MESSAGE = 1;
VERSION_MISMATCH = 2;
UNSUPPORTED_TOKEN_TYPE = 3;
INTERNAL_ERROR = 4;
}
}
message PushNotificationAdvertisementInfo {
bytes public_key = 1;
string access_token = 2;
string installation_id = 3;
}
message ContactCodeAdvertisement {
repeated PushNotificationAdvertisementInfo push_notification_info = 1;
}
message PushNotificationQuery {
repeated bytes public_keys = 1;
}
message PushNotificationQueryInfo {
string access_token = 1;
string installation_id = 2;
bytes public_key = 3;
bytes allowed_user_list = 4;
}
message PushNotificationQueryResponse {
repeated PushNotificationQueryInfo info = 1;
}
message PushNotification {
string access_token = 1;
string chat_id = 2;
}
message PushNotificationRequest {
repeated PushNotification requests = 1;
bytes message = 2;
string message_id = 3;
string ack_required = 4;
}
message PushNotificationAcknowledgement {
string id = 1;
}

View File

@ -4,7 +4,7 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
//go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto //go:generate protoc --go_out=. ./chat_message.proto ./application_metadata_message.proto ./membership_update_message.proto ./command.proto ./contact.proto ./pairing.proto ./push_notifications.proto
func Unmarshal(payload []byte) (*ApplicationMetadataMessage, error) { func Unmarshal(payload []byte) (*ApplicationMetadataMessage, error) {
var message ApplicationMetadataMessage var message ApplicationMetadataMessage

View File

@ -0,0 +1,282 @@
package protocol
import (
"crypto/aes"
"crypto/cipher"
"crypto/ecdsa"
"crypto/rand"
"io"
"golang.org/x/crypto/sha3"
"github.com/golang/protobuf/proto"
"github.com/google/uuid"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/crypto/ecies"
"github.com/status-im/status-go/protocol/encryption"
"github.com/status-im/status-go/protocol/protobuf"
)
const accessTokenKeyLength = 16
type PushNotificationServer struct {
key *ecdsa.PublicKey
registered bool
}
type PushNotificationConfig struct {
// Identity is our identity key
Identity *ecdsa.PrivateKey
// SendEnabled indicates whether we should be sending push notifications
SendEnabled bool
// RemoteNotificationsEnabled is whether we should register with a remote server for push notifications
RemoteNotificationsEnabled bool
// AllowOnlyFromContacts indicates whether we should be receiving push notifications
// only from contacts
AllowOnlyFromContacts bool
// ContactIDs is the public keys for each contact that we allow notifications from
ContactIDs []*ecdsa.PublicKey
// MutedChatIDs is the IDs of the chats we don't want to receive notifications from
MutedChatIDs []string
// PushNotificationServers is an array of push notification servers we want to register with
PushNotificationServers []*PushNotificationServer
// InstallationID is the installation-id for this device
InstallationID string
}
type PushNotificationService struct {
persistence *PushNotificationPersistence
config *PushNotificationConfig
// lastPushNotificationRegister is the latest known push notification register message
lastPushNotificationRegister *protobuf.PushNotificationRegister
// AccessToken is the access token that is currently being used
AccessToken string
// DeviceToken is the device token for this device
DeviceToken string
// randomReader only used for testing so we have deterministic encryption
reader io.Reader
}
func NewPushNotificationService(persistence *PushNotificationPersistence) *PushNotificationService {
return &PushNotificationService{persistence: persistence, reader: rand.Reader}
}
// This likely will return a channel as it's an asynchrous operation
func fetchNotificationInfoFor(publicKey *ecdsa.PublicKey) error {
return nil
}
// Sends an actual push notification, where do we get the chatID?
func sendPushNotificationTo(publicKey *ecdsa.PublicKey, chatID string) error {
return nil
}
// This should schedule:
// 1) Check we have reasonably fresh push notifications info
// 2) Otherwise it should fetch them
// 3) Send a push notification to the devices in question
func (p *PushNotificationService) HandleMessageSent(publicKey *ecdsa.PublicKey, spec *encryption.ProtocolMessageSpec, messageIDs [][]byte) error {
return nil
}
func (p *PushNotificationService) NotifyOnMessageID(messageID []byte) error {
return nil
}
func (p *PushNotificationService) mutedChatIDsHashes() [][]byte {
var mutedChatListHashes [][]byte
for _, chatID := range p.config.MutedChatIDs {
mutedChatListHashes = append(mutedChatListHashes, shake256(chatID))
}
return mutedChatListHashes
}
func (p *PushNotificationService) reEncryptTokenPair(token []byte, pair *protobuf.PushNotificationTokenPair) (*protobuf.PushNotificationTokenPair, error) {
publicKey, err := crypto.DecompressPubkey(pair.PublicKey)
if err != nil {
return nil, err
}
return p.encryptTokenPair(publicKey, token)
}
func (p *PushNotificationService) encryptTokenPair(publicKey *ecdsa.PublicKey, token []byte) (*protobuf.PushNotificationTokenPair, error) {
sharedKey, err := ecies.ImportECDSA(p.config.Identity).GenerateShared(
ecies.ImportECDSAPublic(publicKey),
accessTokenKeyLength,
accessTokenKeyLength,
)
if err != nil {
return nil, err
}
encryptedToken, err := encryptAccessToken(token, sharedKey, p.reader)
if err != nil {
return nil, err
}
return &protobuf.PushNotificationTokenPair{
Token: encryptedToken,
PublicKey: crypto.CompressPubkey(publicKey),
}, nil
}
func (p *PushNotificationService) allowedUserList(token []byte) ([]*protobuf.PushNotificationTokenPair, error) {
var tokenPairs []*protobuf.PushNotificationTokenPair
for _, publicKey := range p.config.ContactIDs {
tokenPair, err := p.encryptTokenPair(publicKey, token)
if err != nil {
return nil, err
}
tokenPairs = append(tokenPairs, tokenPair)
}
return tokenPairs, nil
}
func (p *PushNotificationService) reEncryptAllowedUserList(token []byte, oldTokenPairs []*protobuf.PushNotificationTokenPair) ([]*protobuf.PushNotificationTokenPair, error) {
var tokenPairs []*protobuf.PushNotificationTokenPair
for _, tokenPair := range oldTokenPairs {
tokenPair, err := p.reEncryptTokenPair(token, tokenPair)
if err != nil {
return nil, err
}
tokenPairs = append(tokenPairs, tokenPair)
}
return tokenPairs, nil
}
func (p *PushNotificationService) buildPushNotificationOptionsMessage(token string) (*protobuf.PushNotificationOptions, error) {
allowedUserList, err := p.allowedUserList([]byte(token))
if err != nil {
return nil, err
}
options := &protobuf.PushNotificationOptions{
InstallationId: p.config.InstallationID,
Token: p.DeviceToken,
Enabled: p.config.RemoteNotificationsEnabled,
BlockedChatList: p.mutedChatIDsHashes(),
AllowedUserList: allowedUserList,
}
return options, nil
}
func (p *PushNotificationService) buildPushNotificationRegisterMessage() (*protobuf.PushNotificationRegister, error) {
pushNotificationPreferences := &protobuf.PushNotificationPreferences{}
if p.lastPushNotificationRegister != nil {
if err := proto.Unmarshal(p.lastPushNotificationRegister.Payload, pushNotificationPreferences); err != nil {
return nil, err
}
}
// Increment version
pushNotificationPreferences.Version += 1
// Generate new token
token := uuid.New().String()
pushNotificationPreferences.AccessToken = token
// build options for this device
ourOptions, err := p.buildPushNotificationOptionsMessage(token)
if err != nil {
return nil, err
}
options := []*protobuf.PushNotificationOptions{ourOptions}
// Re-encrypt token for previous options that don't belong to this
// device
for _, option := range pushNotificationPreferences.Options {
if option.InstallationId != p.config.InstallationID {
newAllowedUserList, err := p.reEncryptAllowedUserList([]byte(token), option.AllowedUserList)
if err != nil {
return nil, err
}
option.AllowedUserList = newAllowedUserList
options = append(options, option)
}
}
pushNotificationPreferences.Options = options
// Marshal
payload, err := proto.Marshal(pushNotificationPreferences)
if err != nil {
return nil, err
}
message := &protobuf.PushNotificationRegister{Payload: payload}
return message, nil
}
func (p *PushNotificationService) Register(deviceToken string) error {
return nil
}
// HandlePushNotificationRegistrationResponse should check whether the response was successful or not, retry if necessary otherwise store the result in the database
func (p *PushNotificationService) HandlePushNotificationRegistrationResponse(response *protobuf.PushNotificationRegistrationResponse) error {
return nil
}
// HandlePushNotificationAdvertisement should store any info related to push notifications
func (p *PushNotificationService) HandlePushNotificationAdvertisement(info *protobuf.PushNotificationAdvertisementInfo) error {
return nil
}
// HandlePushNotificationQueryResponse should update the data in the database for a given user
func (p *PushNotificationService) HandlePushNotificationQueryResponse(response *protobuf.PushNotificationQueryResponse) error {
return nil
}
// HandlePushNotificationAcknowledgement should set the request as processed
func (p *PushNotificationService) HandlePushNotificationAcknowledgement(ack *protobuf.PushNotificationAcknowledgement) error {
return nil
}
func (p *PushNotificationService) SetContactIDs(contactIDs []*ecdsa.PublicKey) error {
p.config.ContactIDs = contactIDs
// Update or schedule update
return nil
}
func (p *PushNotificationService) SetMutedChatIDs(chatIDs []string) error {
p.config.MutedChatIDs = chatIDs
// Update or schedule update
return nil
}
func encryptAccessToken(plaintext []byte, key []byte, reader io.Reader) ([]byte, error) {
c, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
gcm, err := cipher.NewGCM(c)
if err != nil {
return nil, err
}
nonce := make([]byte, gcm.NonceSize())
if _, err = io.ReadFull(reader, nonce); err != nil {
return nil, err
}
return gcm.Seal(nonce, nonce, plaintext, nil), nil
}
func shake256(input string) []byte {
buf := []byte(input)
h := make([]byte, 64)
sha3.ShakeSum256(h, buf)
return h
}

View File

@ -0,0 +1,26 @@
package protocol
import (
"crypto/ecdsa"
"database/sql"
)
type PushNotificationPersistence struct {
db *sql.DB
}
func NewPushNotificationPersistence(db *sql.DB) *PushNotificationPersistence {
return &PushNotificationPersistence{db: db}
}
func (p *PushNotificationPersistence) TrackPushNotification(messageID []byte) error {
return nil
}
func (p *PushNotificationPersistence) ShouldSentNotificationFor(publicKey *ecdsa.PublicKey, messageID []byte) (bool, error) {
return false, nil
}
func (p *PushNotificationPersistence) PushNotificationSentFor(publicKey *ecdsa.PublicKey, messageID []byte) error {
return nil
}

View File

@ -0,0 +1,219 @@
package protocol
import (
"bytes"
"crypto/ecdsa"
"math/rand"
"testing"
"github.com/golang/protobuf/proto"
"github.com/google/uuid"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/crypto/ecies"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/stretchr/testify/require"
)
func TestBuildPushNotificationRegisterMessage(t *testing.T) {
myDeviceToken := "device-token"
myInstallationID := "installationID"
mutedChatList := []string{"a", "b"}
// build chat lish hashes
var mutedChatListHashes [][]byte
for _, chatID := range mutedChatList {
mutedChatListHashes = append(mutedChatListHashes, shake256(chatID))
}
identity, err := crypto.GenerateKey()
contactKey, err := crypto.GenerateKey()
require.NoError(t, err)
contactIDs := []*ecdsa.PublicKey{&contactKey.PublicKey}
// Set random generator for uuid
var seed int64 = 1
uuid.SetRand(rand.New(rand.NewSource(seed)))
// Get token
expectedUUID := uuid.New().String()
// set up reader
reader := bytes.NewReader([]byte(expectedUUID))
sharedKey, err := ecies.ImportECDSA(identity).GenerateShared(
ecies.ImportECDSAPublic(&contactKey.PublicKey),
accessTokenKeyLength,
accessTokenKeyLength,
)
require.NoError(t, err)
// build encrypted token
encryptedToken, err := encryptAccessToken([]byte(expectedUUID), sharedKey, reader)
require.NoError(t, err)
tokenPair := &protobuf.PushNotificationTokenPair{
Token: encryptedToken,
PublicKey: crypto.CompressPubkey(&contactKey.PublicKey),
}
// Reset random generator
uuid.SetRand(rand.New(rand.NewSource(seed)))
config := &PushNotificationConfig{
Identity: identity,
RemoteNotificationsEnabled: true,
MutedChatIDs: mutedChatList,
ContactIDs: contactIDs,
InstallationID: myInstallationID,
}
service := &PushNotificationService{}
service.config = config
service.DeviceToken = myDeviceToken
// Set reader
service.reader = bytes.NewReader([]byte(expectedUUID))
options := &protobuf.PushNotificationOptions{
Token: myDeviceToken,
InstallationId: myInstallationID,
Enabled: true,
BlockedChatList: mutedChatListHashes,
AllowedUserList: []*protobuf.PushNotificationTokenPair{tokenPair},
}
preferences := &protobuf.PushNotificationPreferences{
Options: []*protobuf.PushNotificationOptions{options},
Version: 1,
AccessToken: expectedUUID,
}
// Marshal message
marshaledPreferences, err := proto.Marshal(preferences)
require.NoError(t, err)
expectedMessage := &protobuf.PushNotificationRegister{Payload: marshaledPreferences}
actualMessage, err := service.buildPushNotificationRegisterMessage()
require.NoError(t, err)
require.Equal(t, expectedMessage, actualMessage)
}
func TestBuildPushNotificationRegisterMessageWithPrevious(t *testing.T) {
deviceToken1 := "device-token-1"
deviceToken2 := "device-token-2"
installationID1 := "installationID-1"
installationID2 := "installationID-2"
contactKey, err := crypto.GenerateKey()
require.NoError(t, err)
// build previous push notification options
options2 := &protobuf.PushNotificationOptions{
Token: deviceToken2,
InstallationId: installationID2,
Enabled: true,
AllowedUserList: []*protobuf.PushNotificationTokenPair{{
Token: []byte{0x01},
PublicKey: crypto.CompressPubkey(&contactKey.PublicKey),
}},
}
preferences2 := &protobuf.PushNotificationPreferences{
Options: []*protobuf.PushNotificationOptions{options2},
Version: 1,
AccessToken: "some-token",
}
// Marshal message
marshaledPreferences2, err := proto.Marshal(preferences2)
require.NoError(t, err)
lastPushNotificationRegister := &protobuf.PushNotificationRegister{Payload: marshaledPreferences2}
mutedChatList := []string{"a", "b"}
// build chat lish hashes
var mutedChatListHashes [][]byte
for _, chatID := range mutedChatList {
mutedChatListHashes = append(mutedChatListHashes, shake256(chatID))
}
identity, err := crypto.GenerateKey()
contactIDs := []*ecdsa.PublicKey{&contactKey.PublicKey}
// Set random generator for uuid
var seed int64 = 1
uuid.SetRand(rand.New(rand.NewSource(seed)))
// Get token
expectedUUID := uuid.New().String()
// set up reader
reader := bytes.NewReader([]byte(expectedUUID))
sharedKey, err := ecies.ImportECDSA(identity).GenerateShared(
ecies.ImportECDSAPublic(&contactKey.PublicKey),
accessTokenKeyLength,
accessTokenKeyLength,
)
require.NoError(t, err)
// build encrypted token
encryptedToken1, err := encryptAccessToken([]byte(expectedUUID), sharedKey, reader)
require.NoError(t, err)
encryptedToken2, err := encryptAccessToken([]byte(expectedUUID), sharedKey, reader)
require.NoError(t, err)
tokenPair1 := &protobuf.PushNotificationTokenPair{
Token: encryptedToken1,
PublicKey: crypto.CompressPubkey(&contactKey.PublicKey),
}
tokenPair2 := &protobuf.PushNotificationTokenPair{
Token: encryptedToken2,
PublicKey: crypto.CompressPubkey(&contactKey.PublicKey),
}
// Reset random generator
uuid.SetRand(rand.New(rand.NewSource(seed)))
config := &PushNotificationConfig{
Identity: identity,
RemoteNotificationsEnabled: true,
MutedChatIDs: mutedChatList,
ContactIDs: contactIDs,
InstallationID: installationID1,
}
service := &PushNotificationService{}
service.config = config
service.DeviceToken = deviceToken1
service.lastPushNotificationRegister = lastPushNotificationRegister
// Set reader
service.reader = bytes.NewReader([]byte(expectedUUID))
options1 := &protobuf.PushNotificationOptions{
Token: deviceToken1,
InstallationId: installationID1,
Enabled: true,
BlockedChatList: mutedChatListHashes,
AllowedUserList: []*protobuf.PushNotificationTokenPair{tokenPair1},
}
options2.AllowedUserList = []*protobuf.PushNotificationTokenPair{tokenPair2}
preferences := &protobuf.PushNotificationPreferences{
Options: []*protobuf.PushNotificationOptions{options1, options2},
Version: 2,
AccessToken: expectedUUID,
}
// Marshal message
marshaledPreferences, err := proto.Marshal(preferences)
require.NoError(t, err)
expectedMessage := &protobuf.PushNotificationRegister{Payload: marshaledPreferences}
actualMessage, err := service.buildPushNotificationRegisterMessage()
require.NoError(t, err)
require.Equal(t, expectedMessage, actualMessage)
}