dont use nullint64 as not available on 1.12

This commit is contained in:
Andrea Maria Piana 2019-11-20 15:51:34 +01:00
parent 3a02498080
commit 0446f00e9b
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
7 changed files with 251 additions and 108 deletions

View File

@ -609,12 +609,12 @@ func timestampInMs() uint64 {
return uint64(time.Now().UnixNano()) / (uint64(time.Millisecond) / uint64(time.Nanosecond))
}
func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text string, responseTo string, ensName string, contentType protobuf.ChatMessage_ContentType) (*MessengerResponse, error) {
logger := m.logger.With(zap.String("site", "Send"), zap.String("chatID", chatID))
var response *MessengerResponse
func (m *Messenger) SendChatMessage(ctx context.Context, message *protocol.Message) (*MessengerResponse, error) {
logger := m.logger.With(zap.String("site", "Send"), zap.String("chatID", message.ChatId))
var response MessengerResponse
// A valid added chat is required.
chat, err := m.chatByID(chatID)
chat, err := m.chatByID(message.ChatId)
if err != nil {
return nil, err
}
@ -627,24 +627,18 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
clock = clock + 1
}
message := protobuf.ChatMessage{
ChatId: chatID,
Text: text,
Clock: clock,
ResponseTo: responseTo,
EnsName: ensName,
ContentType: contentType,
}
message.Clock = clock
message.Timestamp = timestamp
responseMessage := &Message{
From: hex.EncodeToString(crypto.FromECDSAPub(&m.identity.PublicKey)),
WhisperTimestamp: timestamp,
Timestamp: timestamp,
ContentType: int32(contentType),
ChatID: chatID,
ContentType: int32(message.ContentType),
ChatID: message.ChatId,
ClockValue: clock,
Seen: true,
ReplyTo: responseTo,
ReplyTo: message.ResponseTo,
OutgoingStatus: "sending",
}
@ -657,7 +651,7 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
message.MessageType = protobuf.ChatMessage_ONE_TO_ONE
responseMessage.MessageType = int32(message.MessageType)
responseMessage.To = publicKey
encodedMessage, err := proto.Marshal(&message)
encodedMessage, err := proto.Marshal(message)
if err != nil {
return nil, err
}
@ -671,7 +665,7 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
logger.Debug("sending public message", zap.String("chatName", chat.Name))
message.MessageType = protobuf.ChatMessage_PUBLIC_GROUP
responseMessage.MessageType = int32(message.MessageType)
encodedMessage, err := proto.Marshal(&message)
encodedMessage, err := proto.Marshal(message)
if err != nil {
return nil, err
}
@ -685,7 +679,7 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
logger.Debug("sending public message", zap.String("chatName", chat.Name))
message.MessageType = protobuf.ChatMessage_PRIVATE_GROUP
responseMessage.MessageType = int32(message.MessageType)
encodedMessage, err := proto.Marshal(&message)
encodedMessage, err := proto.Marshal(message)
if err != nil {
return nil, err
}
@ -700,14 +694,14 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
return nil, errors.New("chat is neither public nor private")
}
chat.LastClockValue = clock
chat.LastMessageContent = text
chat.LastMessageContentType = int32(contentType)
chat.LastMessageContent = message.Text
chat.LastMessageContentType = int32(message.ContentType)
chat.LastMessageClockValue = int64(clock)
if err := m.SaveChat(*chat); err != nil {
return nil, err
}
content, err := json.Marshal(protocol.PrepareContent(protocol.Content{
Text: text,
Text: message.Text,
}))
if err != nil {
return nil, err
@ -717,7 +711,7 @@ func (m *Messenger) SendChatMessage(ctx context.Context, chatID string, text str
response.Chats = []*Chat{chat}
response.Messages = []*Message{responseMessage}
return response, nil
return &response, nil
}
func (m *Messenger) Send(ctx context.Context, chatID string, data []byte) ([][]byte, error) {

View File

@ -114,7 +114,7 @@ func _000001_initUpDbSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "000001_init.up.db.sql", size: 832, mode: os.FileMode(0644), modTime: time.Unix(1574166620, 0)}
info := bindataFileInfo{name: "000001_init.up.db.sql", size: 832, mode: os.FileMode(0644), modTime: time.Unix(1574167726, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x1c, 0xa4, 0xac, 0x0, 0xd3, 0x19, 0x53, 0x35, 0x91, 0x1c, 0x94, 0xea, 0xde, 0xa7, 0x75, 0xb6, 0x73, 0x1d, 0x42, 0x14, 0xca, 0x84, 0x5b, 0xdb, 0x10, 0x94, 0x28, 0xc0, 0x33, 0x95, 0x7f, 0xf}}
return a, nil
}
@ -154,7 +154,7 @@ func _000002_add_chatsUpDbSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "000002_add_chats.up.db.sql", size: 595, mode: os.FileMode(0644), modTime: time.Unix(1574164899, 0)}
info := bindataFileInfo{name: "000002_add_chats.up.db.sql", size: 595, mode: os.FileMode(0644), modTime: time.Unix(1574167726, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x99, 0xf3, 0x37, 0x1f, 0x39, 0xc6, 0x43, 0xf8, 0xa7, 0x93, 0x3d, 0x9a, 0x56, 0x97, 0xa1, 0x9a, 0x27, 0xfe, 0xc, 0xd0, 0xde, 0x6b, 0x4b, 0xe1, 0xe, 0x81, 0x8d, 0xdb, 0x6b, 0x51, 0x51, 0xb3}}
return a, nil
}
@ -234,7 +234,7 @@ func _000004_user_messages_compatibilityUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "000004_user_messages_compatibility.up.sql", size: 892, mode: os.FileMode(0644), modTime: time.Unix(1574165955, 0)}
info := bindataFileInfo{name: "000004_user_messages_compatibility.up.sql", size: 892, mode: os.FileMode(0644), modTime: time.Unix(1574167726, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x87, 0x5, 0x28, 0xa5, 0x78, 0x4e, 0x72, 0xcc, 0x1d, 0xe7, 0x74, 0x13, 0x4a, 0xf5, 0x45, 0x31, 0x96, 0xb7, 0x77, 0xdf, 0xea, 0xbb, 0x8b, 0x17, 0xc6, 0x61, 0xe5, 0xad, 0xfc, 0xcc, 0x37, 0x9d}}
return a, nil
}
@ -274,7 +274,7 @@ func _1567112142_user_messagesUpSql() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "1567112142_user_messages.up.sql", size: 543, mode: os.FileMode(0644), modTime: time.Unix(1574166647, 0)}
info := bindataFileInfo{name: "1567112142_user_messages.up.sql", size: 543, mode: os.FileMode(0644), modTime: time.Unix(1574167726, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xff, 0xc0, 0x47, 0x32, 0xa9, 0xa4, 0x6, 0x63, 0x6b, 0xe7, 0x79, 0x2b, 0x80, 0x52, 0x2b, 0x6f, 0xf9, 0x9d, 0x9a, 0xc2, 0xa9, 0x7a, 0xf7, 0x4d, 0x14, 0x12, 0x21, 0x10, 0xc4, 0x30, 0x42, 0xaa}}
return a, nil
}

View File

@ -157,7 +157,7 @@ func (db sqlitePersistence) chats(tx *sql.Tx) (chats []*Chat, err error) {
for rows.Next() {
var (
lastMessageContentType sql.NullInt32
lastMessageContentType sql.NullInt64
lastMessageContent sql.NullString
lastMessageTimestamp sql.NullInt64
lastMessageClockValue sql.NullInt64
@ -189,7 +189,7 @@ func (db sqlitePersistence) chats(tx *sql.Tx) (chats []*Chat, err error) {
return
}
chat.LastMessageContent = lastMessageContent.String
chat.LastMessageContentType = lastMessageContentType.Int32
chat.LastMessageContentType = int32(lastMessageContentType.Int64)
chat.LastMessageTimestamp = lastMessageTimestamp.Int64
chat.LastMessageClockValue = lastMessageClockValue.Int64

View File

@ -141,7 +141,7 @@ func (x ChatMessage_MessageType) String() string {
}
func (ChatMessage_MessageType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{9, 0}
return fileDescriptor_33c57e4bae7b9afd, []int{10, 0}
}
type ChatMessage_ContentType int32
@ -178,7 +178,7 @@ func (x ChatMessage_ContentType) String() string {
}
func (ChatMessage_ContentType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{9, 1}
return fileDescriptor_33c57e4bae7b9afd, []int{10, 1}
}
type ApplicationMetadataMessage_MessageType int32
@ -212,7 +212,7 @@ func (x ApplicationMetadataMessage_MessageType) String() string {
}
func (ApplicationMetadataMessage_MessageType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{10, 0}
return fileDescriptor_33c57e4bae7b9afd, []int{11, 0}
}
type SyncContact struct {
@ -710,6 +710,53 @@ func (m *MembershipUpdate) GetEvents() [][]byte {
return nil
}
type StickerMessage struct {
Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
Pack int32 `protobuf:"varint,2,opt,name=pack,proto3" json:"pack,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *StickerMessage) Reset() { *m = StickerMessage{} }
func (m *StickerMessage) String() string { return proto.CompactTextString(m) }
func (*StickerMessage) ProtoMessage() {}
func (*StickerMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{9}
}
func (m *StickerMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_StickerMessage.Unmarshal(m, b)
}
func (m *StickerMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_StickerMessage.Marshal(b, m, deterministic)
}
func (m *StickerMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_StickerMessage.Merge(m, src)
}
func (m *StickerMessage) XXX_Size() int {
return xxx_messageInfo_StickerMessage.Size(m)
}
func (m *StickerMessage) XXX_DiscardUnknown() {
xxx_messageInfo_StickerMessage.DiscardUnknown(m)
}
var xxx_messageInfo_StickerMessage proto.InternalMessageInfo
func (m *StickerMessage) GetHash() string {
if m != nil {
return m.Hash
}
return ""
}
func (m *StickerMessage) GetPack() int32 {
if m != nil {
return m.Pack
}
return 0
}
type ChatMessage struct {
// Lamport timestamp of the chat message
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
@ -730,17 +777,20 @@ type ChatMessage struct {
// The type of message (public/one-to-one/private-group-chat)
MessageType ChatMessage_MessageType `protobuf:"varint,7,opt,name=message_type,json=messageType,proto3,enum=protobuf.ChatMessage_MessageType" json:"message_type,omitempty"`
// The type of the content of the message
ContentType ChatMessage_ContentType `protobuf:"varint,8,opt,name=content_type,json=contentType,proto3,enum=protobuf.ChatMessage_ContentType" json:"content_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
ContentType ChatMessage_ContentType `protobuf:"varint,8,opt,name=content_type,json=contentType,proto3,enum=protobuf.ChatMessage_ContentType" json:"content_type,omitempty"`
// Types that are valid to be assigned to Payload:
// *ChatMessage_Sticker
Payload isChatMessage_Payload `protobuf_oneof:"payload"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *ChatMessage) Reset() { *m = ChatMessage{} }
func (m *ChatMessage) String() string { return proto.CompactTextString(m) }
func (*ChatMessage) ProtoMessage() {}
func (*ChatMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{9}
return fileDescriptor_33c57e4bae7b9afd, []int{10}
}
func (m *ChatMessage) XXX_Unmarshal(b []byte) error {
@ -817,6 +867,37 @@ func (m *ChatMessage) GetContentType() ChatMessage_ContentType {
return ChatMessage_TEXT_PLAIN
}
type isChatMessage_Payload interface {
isChatMessage_Payload()
}
type ChatMessage_Sticker struct {
Sticker *StickerMessage `protobuf:"bytes,9,opt,name=sticker,proto3,oneof"`
}
func (*ChatMessage_Sticker) isChatMessage_Payload() {}
func (m *ChatMessage) GetPayload() isChatMessage_Payload {
if m != nil {
return m.Payload
}
return nil
}
func (m *ChatMessage) GetSticker() *StickerMessage {
if x, ok := m.GetPayload().(*ChatMessage_Sticker); ok {
return x.Sticker
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*ChatMessage) XXX_OneofWrappers() []interface{} {
return []interface{}{
(*ChatMessage_Sticker)(nil),
}
}
type ApplicationMetadataMessage struct {
// Signature of the payload field
Signature []byte `protobuf:"bytes,1,opt,name=signature,proto3" json:"signature,omitempty"`
@ -833,7 +914,7 @@ func (m *ApplicationMetadataMessage) Reset() { *m = ApplicationMetadataM
func (m *ApplicationMetadataMessage) String() string { return proto.CompactTextString(m) }
func (*ApplicationMetadataMessage) ProtoMessage() {}
func (*ApplicationMetadataMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{10}
return fileDescriptor_33c57e4bae7b9afd, []int{11}
}
func (m *ApplicationMetadataMessage) XXX_Unmarshal(b []byte) error {
@ -889,7 +970,7 @@ func (m *StatusMessage) Reset() { *m = StatusMessage{} }
func (m *StatusMessage) String() string { return proto.CompactTextString(m) }
func (*StatusMessage) ProtoMessage() {}
func (*StatusMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_33c57e4bae7b9afd, []int{11}
return fileDescriptor_33c57e4bae7b9afd, []int{12}
}
func (m *StatusMessage) XXX_Unmarshal(b []byte) error {
@ -971,6 +1052,7 @@ func init() {
proto.RegisterType((*GroupChatEvent)(nil), "protobuf.GroupChatEvent")
proto.RegisterType((*MembershipUpdateMessage)(nil), "protobuf.MembershipUpdateMessage")
proto.RegisterType((*MembershipUpdate)(nil), "protobuf.MembershipUpdate")
proto.RegisterType((*StickerMessage)(nil), "protobuf.StickerMessage")
proto.RegisterType((*ChatMessage)(nil), "protobuf.ChatMessage")
proto.RegisterType((*ApplicationMetadataMessage)(nil), "protobuf.ApplicationMetadataMessage")
proto.RegisterType((*StatusMessage)(nil), "protobuf.StatusMessage")
@ -979,74 +1061,77 @@ func init() {
func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) }
var fileDescriptor_33c57e4bae7b9afd = []byte{
// 1101 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0xc1, 0x72, 0xe3, 0x44,
0x13, 0x8e, 0x6c, 0xc7, 0x8e, 0x5b, 0x8e, 0xa3, 0x9d, 0xff, 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x7a, 0x21, 0x57, 0xe1, 0x17, 0x35, 0x8b, 0x0f, 0xe7, 0x7c,
0xb0, 0x35, 0xfa, 0x7a, 0x97, 0x54, 0x0d, 0x7a, 0x82, 0x10, 0xd7, 0x0e, 0x02, 0xe3, 0x82, 0xd3,
0x2a, 0x8a, 0xf5, 0x42, 0xc3, 0x0c, 0x37, 0xc5, 0x2a, 0xe8, 0x31, 0x3c, 0x2a, 0x17, 0xc1, 0xd8,
0x99, 0x44, 0xd3, 0x89, 0x65, 0x84, 0xb6, 0xd6, 0xe0, 0xf0, 0xc4, 0x70, 0x70, 0xe4, 0x78, 0x41,
0x68, 0x5c, 0x5d, 0x19, 0xa1, 0xe3, 0x7b, 0x5a, 0x93, 0xc3, 0xc1, 0x4b, 0xcf, 0xdc, 0x85, 0x5b,
0xfa, 0x1f, 0x0a, 0x1c, 0x06, 0x8c, 0xb0, 0x55, 0x51, 0x31, 0x73, 0x0b, 0x27, 0xa4, 0xae, 0x21,
0x5a, 0x94, 0x45, 0x44, 0xd5, 0xa8, 0x2a, 0x62, 0x54, 0x3f, 0x7e, 0x97, 0x8a, 0xc7, 0x7b, 0xf8,
0x98, 0x3c, 0xdc, 0x83, 0xcf, 0x41, 0xe3, 0x66, 0xb1, 0x4e, 0xe3, 0x4d, 0x74, 0x41, 0xf7, 0x78,
0x0f, 0x1f, 0x55, 0x37, 0xa5, 0xf3, 0xa8, 0xbb, 0x69, 0xc9, 0x75, 0x5b, 0xa4, 0xfe, 0xea, 0xdf,
0x00, 0x00, 0x00, 0xff, 0xff, 0x51, 0x26, 0x34, 0xec, 0x37, 0x09, 0x00, 0x00,
// 1151 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x51, 0x6f, 0xe3, 0x44,
0x10, 0xae, 0x93, 0xb4, 0x69, 0xc6, 0x69, 0xea, 0x5b, 0x38, 0x2e, 0x9c, 0x0e, 0xd1, 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0xfe,
0xea, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x27, 0x42, 0x44, 0x1b, 0xb2, 0x09, 0x00, 0x00,
}

View File

@ -98,6 +98,11 @@ message MembershipUpdate {
repeated bytes events = 2;
}
message StickerMessage {
string hash = 1;
int32 pack = 2;
}
message ChatMessage {
// Lamport timestamp of the chat message
uint64 clock = 1;
@ -121,6 +126,10 @@ message ChatMessage {
// The type of the content of the message
ContentType content_type = 8;
oneof payload {
StickerMessage sticker = 9;
}
enum MessageType {
ONE_TO_ONE = 0;
PUBLIC_GROUP = 1;

View File

@ -73,6 +73,31 @@ func (m *Message) MarshalJSON() ([]byte, error) {
return json.Marshal(item)
}
func (m *Message) UnmarshalJSON(data []byte) error {
type Alias Message
aux := &struct {
*Alias
ResponseTo string `json:"responseTo"`
EnsName string `json:"ensName"`
ChatID string `json:"chatId"`
Sticker *protobuf.StickerMessage `json:"sticker"`
ContentType protobuf.ChatMessage_ContentType `json:"contentType"`
}{
Alias: (*Alias)(m),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if aux.ContentType == protobuf.ChatMessage_STICKER {
m.Payload = &protobuf.ChatMessage_Sticker{Sticker: aux.Sticker}
}
m.ResponseTo = aux.ResponseTo
m.EnsName = aux.EnsName
m.ChatId = aux.ChatID
m.ContentType = aux.ContentType
return nil
}
// createTextMessage creates a Message.
func createTextMessage(data []byte, lastClock int64, chatID string, messageType protobuf.ChatMessage_MessageType) Message {
text := strings.TrimSpace(string(data))

View File

@ -1,10 +1,12 @@
package statusproto
import (
"encoding/json"
"testing"
"time"
"github.com/ethereum/go-ethereum/crypto"
"github.com/status-im/status-protocol-go/protobuf"
statusproto "github.com/status-im/status-protocol-go/types"
"github.com/stretchr/testify/require"
)
@ -26,3 +28,31 @@ func TestTimestampInMs(t *testing.T) {
require.Equal(t, tt.UnixNano(), 1555274502548*int64(time.Millisecond))
require.Equal(t, ts, TimestampInMsFromTime(tt))
}
func TestUnmarshalJSON(t *testing.T) {
jsonString := `{
"text": "some-text",
"ensName": "ens-name",
"contentType": 1,
"chatId": "chat-id",
"sticker": {
"hash": "hash",
"pack": 1
},
"responseTo": "response-to"
}`
messageJSON := []byte(jsonString)
expected := &Message{}
expected.Text = "some-text"
expected.ResponseTo = "response-to"
expected.EnsName = "ens-name"
expected.ChatId = "chat-id"
expected.ContentType = 1
expected.Payload = &protobuf.ChatMessage_Sticker{Sticker: &protobuf.StickerMessage{Hash: "hash", Pack: 1}}
actual := &Message{}
err := json.Unmarshal(messageJSON, actual)
require.NoError(t, err)
require.Equal(t, expected, actual)
}