Add parsing of messages

This commit is contained in:
Andrea Maria Piana 2020-07-03 10:26:35 +02:00
parent 927f762589
commit 15a3b710a0
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
6 changed files with 134 additions and 61 deletions

View File

@ -38,14 +38,13 @@ const (
ApplicationMetadataMessage_SYNC_INSTALLATION_CONTACT ApplicationMetadataMessage_Type = 12
ApplicationMetadataMessage_SYNC_INSTALLATION_ACCOUNT ApplicationMetadataMessage_Type = 13
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_CONTACT_CODE_ADVERTISEMENT ApplicationMetadataMessage_Type = 15
ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION ApplicationMetadataMessage_Type = 16
ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE 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
ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE ApplicationMetadataMessage_Type = 19
ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST ApplicationMetadataMessage_Type = 20
ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE ApplicationMetadataMessage_Type = 21
)
var ApplicationMetadataMessage_Type_name = map[int32]string{
@ -64,14 +63,13 @@ var ApplicationMetadataMessage_Type_name = map[int32]string{
12: "SYNC_INSTALLATION_CONTACT",
13: "SYNC_INSTALLATION_ACCOUNT",
14: "SYNC_INSTALLATION_PUBLIC_CHAT",
15: "PUSH_NOTIFICATION_REGISTER",
16: "PUSH_NOTIFICATION_REGISTRATION_RESPONSE",
17: "CONTACT_CODE_ADVERTISEMENT",
15: "CONTACT_CODE_ADVERTISEMENT",
16: "PUSH_NOTIFICATION_REGISTRATION",
17: "PUSH_NOTIFICATION_REGISTRATION_RESPONSE",
18: "PUSH_NOTIFICATION_QUERY",
19: "PUSH_NOTIFICATION_QUERY_INFO",
20: "PUSH_NOTIFICATION_QUERY_RESPONSE",
21: "PUSH_NOTIFICATION_REQUEST",
22: "PUSH_NOTIFICATION_ACKNOWLEDGMENT",
19: "PUSH_NOTIFICATION_QUERY_RESPONSE",
20: "PUSH_NOTIFICATION_REQUEST",
21: "PUSH_NOTIFICATION_RESPONSE",
}
var ApplicationMetadataMessage_Type_value = map[string]int32{
@ -90,14 +88,13 @@ var ApplicationMetadataMessage_Type_value = map[string]int32{
"SYNC_INSTALLATION_CONTACT": 12,
"SYNC_INSTALLATION_ACCOUNT": 13,
"SYNC_INSTALLATION_PUBLIC_CHAT": 14,
"PUSH_NOTIFICATION_REGISTER": 15,
"PUSH_NOTIFICATION_REGISTRATION_RESPONSE": 16,
"CONTACT_CODE_ADVERTISEMENT": 17,
"CONTACT_CODE_ADVERTISEMENT": 15,
"PUSH_NOTIFICATION_REGISTRATION": 16,
"PUSH_NOTIFICATION_REGISTRATION_RESPONSE": 17,
"PUSH_NOTIFICATION_QUERY": 18,
"PUSH_NOTIFICATION_QUERY_INFO": 19,
"PUSH_NOTIFICATION_QUERY_RESPONSE": 20,
"PUSH_NOTIFICATION_REQUEST": 21,
"PUSH_NOTIFICATION_ACKNOWLEDGMENT": 22,
"PUSH_NOTIFICATION_QUERY_RESPONSE": 19,
"PUSH_NOTIFICATION_REQUEST": 20,
"PUSH_NOTIFICATION_RESPONSE": 21,
}
func (x ApplicationMetadataMessage_Type) String() string {
@ -174,35 +171,34 @@ func init() {
func init() { proto.RegisterFile("application_metadata_message.proto", fileDescriptor_ad09a6406fcf24c7) }
var fileDescriptor_ad09a6406fcf24c7 = []byte{
// 479 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xcd, 0x52, 0x13, 0x41,
0x10, 0xc7, 0x0d, 0x1f, 0x09, 0x34, 0x31, 0x0e, 0x0d, 0x48, 0xe4, 0x43, 0x62, 0xb4, 0x14, 0xb5,
0x2a, 0x07, 0x3d, 0x7b, 0x18, 0x66, 0x3b, 0xc9, 0x94, 0xd9, 0xd9, 0x65, 0x66, 0x56, 0x8b, 0xd3,
0xd4, 0x22, 0x2b, 0x95, 0x2a, 0x20, 0x5b, 0x64, 0x39, 0xe4, 0x1d, 0x7d, 0x0a, 0x9f, 0xc4, 0xda,
0x25, 0xe1, 0xc3, 0x24, 0xc5, 0x69, 0xaa, 0xff, 0xff, 0x5f, 0xf7, 0xf4, 0xf4, 0x34, 0x34, 0xe3,
0x34, 0xbd, 0xe8, 0xff, 0x8a, 0xb3, 0xfe, 0xe0, 0xca, 0x5d, 0x26, 0x59, 0x7c, 0x16, 0x67, 0xb1,
0xbb, 0x4c, 0x86, 0xc3, 0xf8, 0x3c, 0x69, 0xa5, 0xd7, 0x83, 0x6c, 0x80, 0x2b, 0xc5, 0x71, 0x7a,
0xf3, 0xbb, 0xf9, 0xb7, 0x0c, 0x3b, 0xfc, 0x3e, 0xc1, 0x1f, 0xf3, 0xfe, 0x2d, 0x8e, 0x7b, 0xb0,
0x3a, 0xec, 0x9f, 0x5f, 0xc5, 0xd9, 0xcd, 0x75, 0x52, 0x2f, 0x35, 0x4a, 0x87, 0x55, 0x7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, 0x10, 0x58, 0xcb, 0x47, 0x33, 0xf5, 0x48,
0x37, 0x1e, 0x20, 0xab, 0xce, 0xb6, 0xb9, 0x10, 0x41, 0xa4, 0x2c, 0x7b, 0x8e, 0x6f, 0x60, 0x7f,
0xda, 0x0e, 0xa3, 0xa3, 0x9e, 0x14, 0x2e, 0xff, 0x17, 0x56, 0xc3, 0xd7, 0xb0, 0x13, 0x46, 0xa6,
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,
// 463 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0x51, 0x4f, 0x13, 0x41,
0x10, 0xc7, 0x2d, 0x94, 0x16, 0x86, 0x5a, 0x97, 0x01, 0x42, 0x05, 0x81, 0x5a, 0x8d, 0xa2, 0x26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 0x11, 0x28, 0xcb, 0x85, 0x75, 0x51, 0xe8, 0x71, 0x4b, 0x6c,
0x01, 0x77, 0xe1, 0xa5, 0x4f, 0xfe, 0x21, 0x69, 0xd3, 0x91, 0xe1, 0x58, 0xfe, 0x57, 0xb2, 0x88,
0x9b, 0xb0, 0x16, 0x72, 0xa9, 0x9d, 0x54, 0xc6, 0xf2, 0x6e, 0x97, 0x5b, 0x19, 0x28, 0x56, 0xce,
0x65, 0x73, 0xaa, 0xc4, 0x7d, 0x79, 0x09, 0xdf, 0xc0, 0xbe, 0xa6, 0x93, 0x88, 0x8c, 0x75, 0xdc,
0xf3, 0x34, 0x19, 0xe3, 0x8e, 0x02, 0xed, 0xac, 0xe6, 0xca, 0x70, 0x51, 0x40, 0x15, 0xfc, 0x08,
0xef, 0xb8, 0x10, 0x14, 0x5a, 0xf7, 0x14, 0x5b, 0xc5, 0x4f, 0xf0, 0xde, 0x23, 0xd1, 0x95, 0x8a,
0x9e, 0x84, 0x97, 0x71, 0x0b, 0xd6, 0x27, 0xd0, 0x5d, 0x63, 0x05, 0x37, 0x80, 0x19, 0x52, 0xde,
0x3d, 0x15, 0x70, 0x1f, 0x76, 0xfe, 0xef, 0x7d, 0x17, 0x58, 0xcd, 0xa3, 0x99, 0x59, 0xd2, 0x8d,
0x03, 0x64, 0xb5, 0xf9, 0x36, 0x17, 0x22, 0x88, 0x94, 0x65, 0xcf, 0xf1, 0x35, 0xec, 0xce, 0xda,
0x61, 0x74, 0xd8, 0x95, 0xc2, 0xe5, 0x77, 0x61, 0x75, 0xdc, 0x83, 0xed, 0xc9, 0x3d, 0x44, 0xe0,
0x91, 0xe3, 0xde, 0x77, 0xd2, 0x56, 0x1a, 0xf2, 0x49, 0x59, 0xf6, 0x02, 0x5b, 0xb0, 0x17, 0x46,
0xa6, 0xe3, 0x54, 0x60, 0xe5, 0x91, 0x14, 0xa3, 0x16, 0x9a, 0x8e, 0xa5, 0xb1, 0x7a, 0x14, 0x39,
0xcb, 0x13, 0x7a, 0x9c, 0x71, 0x9a, 0x4c, 0x18, 0x28, 0x43, 0x6c, 0x0d, 0x77, 0x60, 0x6b, 0x16,
0x3e, 0x89, 0x48, 0x9f, 0x32, 0xc4, 0xb7, 0xd0, 0x7c, 0xc0, 0x9c, 0xb6, 0x58, 0xcf, 0xb7, 0x9e,
0x37, 0xaf, 0xc8, 0x8f, 0x6d, 0xe4, 0x2b, 0xcd, 0xb3, 0xc7, 0xe5, 0x9b, 0x67, 0x95, 0xe2, 0xd7,
0xfe, 0xf2, 0x37, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xcd, 0xf5, 0xf1, 0x77, 0x03, 0x00, 0x00,
}

View File

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

View File

@ -703,6 +703,7 @@ func (m *PushNotificationReport) GetInstallationId() string {
return ""
}
// TOP LEVEL
type PushNotificationResponse struct {
MessageId string `protobuf:"bytes,1,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
Reports []*PushNotificationReport `protobuf:"bytes,2,rep,name=reports,proto3" json:"reports,omitempty"`

View File

@ -86,6 +86,7 @@ message PushNotificationReport {
string installation_id = 4;
}
// TOP LEVEL
message PushNotificationResponse {
string message_id = 1;
repeated PushNotificationReport reports = 2;

View File

@ -164,8 +164,8 @@ func (p *Client) HandlePushNotificationQueryResponse(response *protobuf.PushNoti
return nil
}
// HandlePushNotificationAcknowledgement should set the request as processed
func (p *Client) HandlePushNotificationAcknowledgement(ack *protobuf.PushNotificationAcknowledgement) error {
// HandlePushNotificationResponse should set the request as processed
func (p *Client) HandlePushNotificationResponse(ack *protobuf.PushNotificationResponse) error {
return nil
}

View File

@ -319,6 +319,82 @@ func (m *StatusMessage) HandleApplication() error {
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION:
// This message is a bit different as it's encrypted, so we pass it straight through
m.ParsedMessage = m.DecryptedPayload
return nil
case protobuf.ApplicationMetadataMessage_CONTACT_CODE_ADVERTISEMENT:
var message protobuf.ContactCodeAdvertisement
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode ContactCodeAdvertisement: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REQUEST:
var message protobuf.PushNotificationRequest
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode PushNotificationRequest: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION_RESPONSE:
var message protobuf.PushNotificationRegistrationResponse
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode PushNotificationRegistrationResponse: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY:
var message protobuf.PushNotificationQuery
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode PushNotificationQuery: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_QUERY_RESPONSE:
var message protobuf.PushNotificationQueryResponse
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode PushNotificationQueryResponse: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_RESPONSE:
var message protobuf.PushNotificationResponse
err := proto.Unmarshal(m.DecryptedPayload, &message)
if err != nil {
m.ParsedMessage = nil
log.Printf("[message::DecodeMessage] could not decode PushNotificationResponse: %#x, err: %v", m.Hash, err.Error())
} else {
m.ParsedMessage = message
return nil
}
}
return nil
}