Change to map in messenger response

This commit is contained in:
Andrea Maria Piana 2021-06-03 15:11:55 +02:00
parent 217bace570
commit 5d856adc0c
17 changed files with 276 additions and 233 deletions

View File

@ -135,7 +135,10 @@ type Message struct {
// CommunityID is the id of the community to advertise // CommunityID is the id of the community to advertise
CommunityID string `json:"communityId,omitempty"` CommunityID string `json:"communityId,omitempty"`
New bool `json:"new,omitempty"` // Replace indicates that this is a replacement of a message
// that has been updated
Replace string `json:"replace,omitempty"`
New bool `json:"new,omitempty"`
SigPubKey *ecdsa.PublicKey `json:"-"` SigPubKey *ecdsa.PublicKey `json:"-"`

View File

@ -141,8 +141,8 @@ func (s *MessengerCommunitiesSuite) TestRetrieveCommunity() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(communities, 2) s.Require().Len(communities, 2)
s.Require().Len(response.Communities(), 1) s.Require().Len(response.Communities(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Equal(community.IDString(), response.Messages[0].CommunityID) s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
} }
func (s *MessengerCommunitiesSuite) TestJoinCommunity() { func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
@ -241,8 +241,8 @@ func (s *MessengerCommunitiesSuite) TestJoinCommunity() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(communities, 2) s.Require().Len(communities, 2)
s.Require().Len(response.Communities(), 1) s.Require().Len(response.Communities(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Equal(community.IDString(), response.Messages[0].CommunityID) s.Require().Equal(community.IDString(), response.Messages()[0].CommunityID)
// We join the org // We join the org
response, err = s.alice.JoinCommunity(community.ID()) response, err = s.alice.JoinCommunity(community.ID())
@ -463,14 +463,14 @@ func (s *MessengerCommunitiesSuite) TestPostToCommunityChat() {
if err != nil { if err != nil {
return err return err
} }
if len(response.Messages) == 0 { if len(response.messages) == 0 {
return errors.New("message not received") return errors.New("message not received")
} }
return nil return nil
}) })
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Equal(chatID, response.Chats()[0].ID) s.Require().Equal(chatID, response.Chats()[0].ID)
} }
@ -978,7 +978,7 @@ func (s *MessengerCommunitiesSuite) TestShareCommunity() {
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
// Add bob to contacts so it does not go on activity center // Add bob to contacts so it does not go on activity center
bobPk := common.PubkeyToHex(&s.alice.identity.PublicKey) bobPk := common.PubkeyToHex(&s.alice.identity.PublicKey)
@ -991,14 +991,14 @@ func (s *MessengerCommunitiesSuite) TestShareCommunity() {
if err != nil { if err != nil {
return err return err
} }
if len(response.Messages) == 0 { if len(response.messages) == 0 {
return errors.New("community link not received") return errors.New("community link not received")
} }
return nil return nil
}) })
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
} }
func (s *MessengerCommunitiesSuite) TestBanUser() { func (s *MessengerCommunitiesSuite) TestBanUser() {

View File

@ -162,7 +162,7 @@ func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageSta
if exists { if exists {
continue continue
} }
messageState.Response.Messages = append(messageState.Response.Messages, message) messageState.Response.AddMessage(message)
} }
messageState.Response.AddChat(chat) messageState.Response.AddChat(chat)
@ -263,7 +263,7 @@ func (m *MessageHandler) handleCommandMessage(state *ReceivedMessageState, messa
// Add to response // Add to response
state.Response.AddChat(chat) state.Response.AddChat(chat)
if message != nil { if message != nil {
state.Response.Messages = append(state.Response.Messages, message) state.Response.AddMessage(message)
} }
// Set in the modified maps chat // Set in the modified maps chat
@ -623,13 +623,13 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
state.Response.CommunityChanges = append(state.Response.CommunityChanges, communityResponse.Changes) state.Response.CommunityChanges = append(state.Response.CommunityChanges, communityResponse.Changes)
} }
if len(receivedMessage.Replace) != 0 { if len(receivedMessage.OriginalMessageId) != 0 {
if receivedMessage.ContentType != protobuf.ChatMessage_EDIT { if receivedMessage.ContentType != protobuf.ChatMessage_EDIT {
return errors.New("replace can only be used with an edit content type") return errors.New("replace can only be used with an edit content type")
} }
} }
state.Response.Messages = append(state.Response.Messages, receivedMessage) state.Response.AddMessage(receivedMessage)
return nil return nil
} }

View File

@ -47,6 +47,7 @@ func (db sqlitePersistence) tableUserMessagesAllFields() string {
command_state, command_state,
command_signature, command_signature,
replace_message, replace_message,
original_message_id,
rtl, rtl,
line_count, line_count,
response_to, response_to,
@ -87,6 +88,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string {
m1.command_state, m1.command_state,
m1.command_signature, m1.command_signature,
m1.replace_message, m1.replace_message,
m1.original_message_id,
m1.rtl, m1.rtl,
m1.line_count, m1.line_count,
m1.response_to, m1.response_to,
@ -127,6 +129,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
var communityID sql.NullString var communityID sql.NullString
var gapFrom sql.NullInt64 var gapFrom sql.NullInt64
var gapTo sql.NullInt64 var gapTo sql.NullInt64
var originalMessageID sql.NullString
sticker := &protobuf.StickerMessage{} sticker := &protobuf.StickerMessage{}
command := &common.CommandParameters{} command := &common.CommandParameters{}
@ -164,6 +167,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
&command.CommandState, &command.CommandState,
&command.Signature, &command.Signature,
&message.Replace, &message.Replace,
&originalMessageID,
&message.RTL, &message.RTL,
&message.LineCount, &message.LineCount,
&message.ResponseTo, &message.ResponseTo,
@ -185,6 +189,10 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
return err return err
} }
if originalMessageID.Valid {
message.OriginalMessageId = originalMessageID.String
}
if quotedText.Valid { if quotedText.Valid {
message.QuotedMessage = &common.QuotedMessage{ message.QuotedMessage = &common.QuotedMessage{
From: quotedFrom.String, From: quotedFrom.String,
@ -318,6 +326,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message)
command.CommandState, command.CommandState,
command.Signature, command.Signature,
message.Replace, message.Replace,
message.OriginalMessageId,
message.RTL, message.RTL,
message.LineCount, message.LineCount,
message.ResponseTo, message.ResponseTo,

View File

@ -1221,8 +1221,8 @@ func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string,
chat.updateChatFromGroupMembershipChanges(group) chat.updateChatFromGroupMembershipChanges(group)
response.AddChat(&chat) response.AddChat(&chat)
response.Messages = buildSystemMessages(chat.MembershipUpdates, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages(chat.MembershipUpdates, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1296,8 +1296,8 @@ func (m *Messenger) RemoveMemberFromGroupChat(ctx context.Context, chatID string
chat.updateChatFromGroupMembershipChanges(group) chat.updateChatFromGroupMembershipChanges(group)
response.AddChat(chat) response.AddChat(chat)
response.Messages = buildSystemMessages(chat.MembershipUpdates, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages(chat.MembershipUpdates, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1382,8 +1382,8 @@ func (m *Messenger) AddMembersToGroupChat(ctx context.Context, chatID string, me
chat.updateChatFromGroupMembershipChanges(group) chat.updateChatFromGroupMembershipChanges(group)
response.AddChat(chat) response.AddChat(chat)
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1444,8 +1444,8 @@ func (m *Messenger) ChangeGroupChatName(ctx context.Context, chatID string, name
var response MessengerResponse var response MessengerResponse
response.AddChat(chat) response.AddChat(chat)
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1644,8 +1644,8 @@ func (m *Messenger) AddAdminsToGroupChat(ctx context.Context, chatID string, mem
chat.updateChatFromGroupMembershipChanges(group) chat.updateChatFromGroupMembershipChanges(group)
response.AddChat(chat) response.AddChat(chat)
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1708,8 +1708,8 @@ func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*Me
chat.Joined = int64(m.getTimesource().GetCurrentTime()) chat.Joined = int64(m.getTimesource().GetCurrentTime())
response.AddChat(chat) response.AddChat(chat)
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1768,8 +1768,8 @@ func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string, remove bo
} }
chat.updateChatFromGroupMembershipChanges(group) chat.updateChatFromGroupMembershipChanges(group)
response.Messages = buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations) response.AddMessages(buildSystemMessages([]v1protocol.MembershipUpdateEvent{event}, m.systemMessagesTranslations))
err = m.persistence.SaveMessages(response.Messages) err = m.persistence.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -2071,11 +2071,11 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
return nil, err return nil, err
} }
} else if message.ContentType == protobuf.ChatMessage_EDIT { } else if message.ContentType == protobuf.ChatMessage_EDIT {
if len(message.Replace) == 0 { if len(message.OriginalMessageId) == 0 {
return nil, errors.New("the id of the message to replace is required") return nil, errors.New("the id of the message to replace is required")
} }
msgToReplace, err := m.persistence.MessageByID(message.Replace) msgToReplace, err := m.persistence.MessageByID(message.OriginalMessageId)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -2150,10 +2150,11 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
return nil, err return nil, err
} }
response.Messages, err = m.pullMessagesAndResponsesFromDB([]*common.Message{message}) msg, err := m.pullMessagesAndResponsesFromDB([]*common.Message{message})
if err != nil { if err != nil {
return nil, err return nil, err
} }
response.SetMessages(msg)
response.AddChat(chat) response.AddChat(chat)
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
@ -2998,8 +2999,9 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
} }
} }
if len(messageState.Response.Messages) > 0 { messagesToSave := messageState.Response.Messages()
err = m.SaveMessages(messageState.Response.Messages) if len(messageState.Response.messages) > 0 {
err = m.SaveMessages(messagesToSave)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -3021,11 +3023,11 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
} }
newMessagesIds := map[string]struct{}{} newMessagesIds := map[string]struct{}{}
for _, message := range messageState.Response.Messages { for _, message := range messagesToSave {
newMessagesIds[message.ID] = struct{}{} newMessagesIds[message.ID] = struct{}{}
} }
messagesWithResponses, err := m.pullMessagesAndResponsesFromDB(messageState.Response.Messages) messagesWithResponses, err := m.pullMessagesAndResponsesFromDB(messagesToSave)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -3033,13 +3035,13 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
for _, message := range messagesWithResponses { for _, message := range messagesWithResponses {
messagesByID[message.ID] = message messagesByID[message.ID] = message
} }
messageState.Response.Messages = messagesWithResponses messageState.Response.SetMessages(messagesWithResponses)
notificationsEnabled, err := m.settings.GetNotificationsEnabled() notificationsEnabled, err := m.settings.GetNotificationsEnabled()
if err != nil { if err != nil {
return nil, err return nil, err
} }
for _, message := range messageState.Response.Messages { for _, message := range messageState.Response.messages {
if _, ok := newMessagesIds[message.ID]; ok { if _, ok := newMessagesIds[message.ID]; ok {
message.New = true message.New = true
@ -3296,7 +3298,7 @@ func (m *Messenger) RequestTransaction(ctx context.Context, chatID, value, contr
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3370,7 +3372,7 @@ func (m *Messenger) RequestAddressForTransaction(ctx context.Context, chatID, fr
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3463,7 +3465,7 @@ func (m *Messenger) AcceptRequestAddressForTransaction(ctx context.Context, mess
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3543,7 +3545,7 @@ func (m *Messenger) DeclineRequestTransaction(ctx context.Context, messageID str
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3623,7 +3625,7 @@ func (m *Messenger) DeclineRequestAddressForTransaction(ctx context.Context, mes
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3720,7 +3722,7 @@ func (m *Messenger) AcceptRequestTransaction(ctx context.Context, transactionHas
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3799,7 +3801,7 @@ func (m *Messenger) SendTransaction(ctx context.Context, chatID, value, contract
} }
response.AddChat(chat) response.AddChat(chat)
response.Messages = []*common.Message{message} response.AddMessages([]*common.Message{message})
return &response, m.saveChat(chat) return &response, m.saveChat(chat)
} }
@ -3891,7 +3893,7 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
} }
} }
response.Messages = append(response.Messages, message) response.AddMessage(message)
m.allChats.Store(chat.ID, chat) m.allChats.Store(chat.ID, chat)
response.AddChat(chat) response.AddChat(chat)
@ -3914,8 +3916,8 @@ func (m *Messenger) ValidateTransactions(ctx context.Context, addresses []types.
} }
if len(response.Messages) > 0 { if len(response.messages) > 0 {
err = m.SaveMessages(response.Messages) err = m.SaveMessages(response.Messages())
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -3,7 +3,6 @@ package protocol
import ( import (
"context" "context"
"crypto/ecdsa" "crypto/ecdsa"
"fmt"
"testing" "testing"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
@ -75,43 +74,42 @@ func (s *MessengerEditMessageSuite) TestEditMessage() {
inputMessage := buildTestMessage(*theirChat) inputMessage := buildTestMessage(*theirChat)
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.messages) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
ogMessage := sendResponse.Messages[0] ogMessage := sendResponse.Messages()[0]
editedMessage := buildTestMessage(*theirChat) editedMessage := buildTestMessage(*theirChat)
editedMessage.Replace = ogMessage.ID editedMessage.OriginalMessageId = ogMessage.ID
editedMessage.ContentType = protobuf.ChatMessage_EDIT editedMessage.ContentType = protobuf.ChatMessage_EDIT
sendResponse, err = theirMessenger.SendChatMessage(context.Background(), editedMessage) sendResponse, err = theirMessenger.SendChatMessage(context.Background(), editedMessage)
s.NoError(err) s.Require().NoError(err)
fmt.Println(sendResponse.Messages) s.Require().Len(sendResponse.Messages(), 1)
s.Require().Len(sendResponse.Messages, 1)
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.messages) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Equal(ogMessage.ID, response.Messages[0].Replace) s.Require().Equal(ogMessage.ID, response.Messages()[0].OriginalMessageId)
// Main instance user attempts to edit the message it received from theirMessenger // Main instance user attempts to edit the message it received from theirMessenger
editedMessage = buildTestMessage(*ourChat) editedMessage = buildTestMessage(*ourChat)
editedMessage.Replace = ogMessage.ID editedMessage.OriginalMessageId = ogMessage.ID
editedMessage.ContentType = protobuf.ChatMessage_EDIT editedMessage.ContentType = protobuf.ChatMessage_EDIT
_, err = s.m.SendChatMessage(context.Background(), editedMessage) _, err = s.m.SendChatMessage(context.Background(), editedMessage)

View File

@ -95,14 +95,14 @@ func (s *MessengerEmojiSuite) TestSendEmoji() {
// Wait for message to arrive to bob // Wait for message to arrive to bob
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
bob, bob,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
messageID := response.Messages[0].ID messageID := response.Messages()[0].ID
// Respond with an emoji, donald trump style // Respond with an emoji, donald trump style
@ -184,11 +184,11 @@ func (s *MessengerEmojiSuite) TestEmojiPrivateGroup() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
alice, alice,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no message received", "no message received",
) )
s.Require().NoError(err) s.Require().NoError(err)
messageID := response.Messages[0].ID messageID := response.Messages()[0].ID
_, err = bob.SendEmojiReaction(context.Background(), chat.ID, messageID, protobuf.EmojiReaction_SAD) _, err = bob.SendEmojiReaction(context.Background(), chat.ID, messageID, protobuf.EmojiReaction_SAD)
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -272,7 +272,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallationNewMessages() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
_, err = WaitOnMessengerResponse( _, err = WaitOnMessengerResponse(
bob2, bob2,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"message not received", "message not received",
) )
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -74,11 +74,11 @@ func (s *MessengerPinMessageSuite) TestPinMessage() {
inputMessage := buildTestMessage(*theirChat) inputMessage := buildTestMessage(*theirChat)
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)

View File

@ -11,7 +11,6 @@ import (
) )
type MessengerResponse struct { type MessengerResponse struct {
Messages []*common.Message
Contacts []*Contact Contacts []*Contact
Installations []*multidevice.Installation Installations []*multidevice.Installation
EmojiReactions []*EmojiReaction EmojiReactions []*EmojiReaction
@ -28,6 +27,7 @@ type MessengerResponse struct {
removedChats map[string]bool removedChats map[string]bool
communities map[string]*communities.Community communities map[string]*communities.Community
activityCenterNotifications map[string]*ActivityCenterNotification activityCenterNotifications map[string]*ActivityCenterNotification
messages map[string]*common.Message
pinMessages map[string]*common.PinMessage pinMessages map[string]*common.PinMessage
} }
@ -50,7 +50,6 @@ func (r *MessengerResponse) MarshalJSON() ([]byte, error) {
Communities []*communities.Community `json:"communities,omitempty"` Communities []*communities.Community `json:"communities,omitempty"`
ActivityCenterNotifications []*ActivityCenterNotification `json:"activityCenterNotifications,omitempty"` ActivityCenterNotifications []*ActivityCenterNotification `json:"activityCenterNotifications,omitempty"`
}{ }{
Messages: r.Messages,
Contacts: r.Contacts, Contacts: r.Contacts,
Installations: r.Installations, Installations: r.Installations,
EmojiReactions: r.EmojiReactions, EmojiReactions: r.EmojiReactions,
@ -60,6 +59,7 @@ func (r *MessengerResponse) MarshalJSON() ([]byte, error) {
Mailservers: r.Mailservers, Mailservers: r.Mailservers,
} }
responseItem.Messages = r.Messages()
responseItem.Notifications = r.Notifications() responseItem.Notifications = r.Notifications()
responseItem.Chats = r.Chats() responseItem.Chats = r.Chats()
responseItem.Communities = r.Communities() responseItem.Communities = r.Communities()
@ -112,7 +112,7 @@ func (r *MessengerResponse) PinMessages() []*common.PinMessage {
func (r *MessengerResponse) IsEmpty() bool { func (r *MessengerResponse) IsEmpty() bool {
return len(r.chats)+ return len(r.chats)+
len(r.Messages)+ len(r.messages)+
len(r.pinMessages)+ len(r.pinMessages)+
len(r.Contacts)+ len(r.Contacts)+
len(r.Installations)+ len(r.Installations)+
@ -144,29 +144,13 @@ func (r *MessengerResponse) Merge(response *MessengerResponse) error {
r.AddChats(response.Chats()) r.AddChats(response.Chats())
r.AddRemovedChats(response.RemovedChats()) r.AddRemovedChats(response.RemovedChats())
r.AddNotifications(response.Notifications()) r.AddNotifications(response.Notifications())
r.overrideMessages(response.Messages) r.AddMessages(response.Messages())
r.AddCommunities(response.Communities()) r.AddCommunities(response.Communities())
r.AddPinMessages(response.PinMessages()) r.AddPinMessages(response.PinMessages())
return nil return nil
} }
// overrideMessages append new messages and override existing ones in response.Messages
func (r *MessengerResponse) overrideMessages(messages []*common.Message) {
for _, overrideMessage := range messages {
var found = false
for idx, chat := range r.Messages {
if chat.ID == overrideMessage.ID {
r.Messages[idx] = overrideMessage
found = true
}
}
if !found {
r.Messages = append(r.Messages, overrideMessage)
}
}
}
func (r *MessengerResponse) AddCommunities(communities []*communities.Community) { func (r *MessengerResponse) AddCommunities(communities []*communities.Community) {
for _, overrideCommunity := range communities { for _, overrideCommunity := range communities {
r.AddCommunity(overrideCommunity) r.AddCommunity(overrideCommunity)
@ -263,6 +247,28 @@ func (r *MessengerResponse) AddPinMessages(pms []*common.PinMessage) {
} }
} }
func (r *MessengerResponse) AddMessage(message *common.Message) { func (r *MessengerResponse) Messages() []*common.Message {
r.Messages = append(r.Messages, message) var ms []*common.Message
for _, m := range r.messages {
ms = append(ms, m)
}
return ms
}
func (r *MessengerResponse) AddMessages(ms []*common.Message) {
for _, m := range ms {
r.AddMessage(m)
}
}
func (r *MessengerResponse) AddMessage(message *common.Message) {
if r.messages == nil {
r.messages = make(map[string]*common.Message)
}
r.messages[message.ID] = message
}
func (r *MessengerResponse) SetMessages(messages []*common.Message) {
r.messages = make(map[string]*common.Message)
r.AddMessages(messages)
} }

View File

@ -30,19 +30,18 @@ func TestMessengerResponseMergeMessages(t *testing.T) {
message1 := &common.Message{ID: "1"} message1 := &common.Message{ID: "1"}
modifiedMessage1 := &common.Message{ID: "1", From: "name"} modifiedMessage1 := &common.Message{ID: "1", From: "name"}
message2 := &common.Message{ID: "3"} message2 := &common.Message{ID: "3"}
response1 := &MessengerResponse{ response1 := &MessengerResponse{}
Messages: []*common.Message{message1}, response1.AddMessage(message1)
}
response2 := &MessengerResponse{ response2 := &MessengerResponse{}
Messages: []*common.Message{modifiedMessage1, message2}, response2.AddMessage(modifiedMessage1)
} response2.AddMessage(message2)
require.NoError(t, response1.Merge(response2)) require.NoError(t, response1.Merge(response2))
require.Len(t, response1.Messages, 2) require.Len(t, response1.Messages(), 2)
require.Equal(t, modifiedMessage1, response1.Messages[0]) require.Equal(t, modifiedMessage1, response1.Messages()[0])
require.Equal(t, message2, response1.Messages[1]) require.Equal(t, message2, response1.Messages()[1])
} }
func TestMessengerResponseMergeNotImplemented(t *testing.T) { func TestMessengerResponseMergeNotImplemented(t *testing.T) {

View File

@ -409,8 +409,8 @@ func (s *MessengerSuite) TestSendPublic() {
response, err := s.m.SendChatMessage(context.Background(), inputMessage) response, err := s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message") s.Require().Equal(1, len(response.Messages()), "it returns the message")
outputMessage := response.Messages[0] outputMessage := response.Messages()[0]
s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock") s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock")
s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value") s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value")
@ -435,8 +435,8 @@ func (s *MessengerSuite) TestSendProfile() {
response, err := s.m.SendChatMessage(context.Background(), inputMessage) response, err := s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message") s.Require().Equal(1, len(response.Messages()), "it returns the message")
outputMessage := response.Messages[0] outputMessage := response.Messages()[0]
s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock") s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock")
s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value") s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value")
@ -466,8 +466,8 @@ func (s *MessengerSuite) TestSendPrivateOneToOne() {
s.NoError(err) s.NoError(err)
response, err := s.m.SendChatMessage(context.Background(), inputMessage) response, err := s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message") s.Require().Equal(1, len(response.Messages()), "it returns the message")
outputMessage := response.Messages[0] outputMessage := response.Messages()[0]
s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock") s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock")
s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value") s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value")
@ -499,8 +499,8 @@ func (s *MessengerSuite) TestSendPrivateGroup() {
s.NoError(err) s.NoError(err)
response, err = s.m.SendChatMessage(context.Background(), inputMessage) response, err = s.m.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message") s.Require().Equal(1, len(response.Messages()), "it returns the message")
outputMessage := response.Messages[0] outputMessage := response.Messages()[0]
s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock") s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock")
s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value") s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value")
@ -527,8 +527,8 @@ func (s *MessengerSuite) TestSendPrivateEmptyGroup() {
s.NoError(err) s.NoError(err)
response, err = s.m.SendChatMessage(context.Background(), inputMessage) response, err = s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Equal(1, len(response.Messages), "it returns the message") s.Require().Equal(1, len(response.Messages()), "it returns the message")
outputMessage := response.Messages[0] outputMessage := response.Messages()[0]
s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock") s.Require().Equal(uint64(100000000000001), outputMessage.Clock, "it correctly sets the clock")
s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value") s.Require().Equal(uint64(100000000000001), chat.LastClockValue, "it correctly sets the last-clock-value")
@ -556,9 +556,9 @@ func (s *MessengerSuite) TestRetrieveOwnPublic() {
response, err := s.m.SendChatMessage(context.Background(), inputMessage) response, err := s.m.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
textMessage := response.Messages[0] textMessage := response.Messages()[0]
s.Equal(textMessage.Text, text) s.Equal(textMessage.Text, text)
s.NotNil(textMessage.ParsedText) s.NotNil(textMessage.ParsedText)
@ -596,18 +596,18 @@ func (s *MessengerSuite) TestRetrieveTheirPublic() {
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
sentMessage := sendResponse.Messages[0] sentMessage := sendResponse.Messages()[0]
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
actualChat := response.Chats()[0] actualChat := response.Chats()[0]
// It sets the unviewed messages count // It sets the unviewed messages count
@ -639,7 +639,7 @@ func (s *MessengerSuite) TestDeletedAtClockValue() {
sentResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sentResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
chat.DeletedAtClockValue = sentResponse.Messages[0].Clock chat.DeletedAtClockValue = sentResponse.Messages()[0].Clock
err = s.m.SaveChat(chat) err = s.m.SaveChat(chat)
s.Require().NoError(err) s.Require().NoError(err)
@ -647,7 +647,7 @@ func (s *MessengerSuite) TestDeletedAtClockValue() {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
response, err := s.m.RetrieveAll() response, err := s.m.RetrieveAll()
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 0) s.Require().Len(response.Messages(), 0)
s.Require().NoError(theirMessenger.Shutdown()) s.Require().NoError(theirMessenger.Shutdown())
} }
@ -685,7 +685,7 @@ func (s *MessengerSuite) TestRetrieveBlockedContact() {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
response, err := s.m.RetrieveAll() response, err := s.m.RetrieveAll()
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 0) s.Require().Len(response.Messages(), 0)
} }
// Resend their public message, receive only once // Resend their public message, receive only once
@ -709,7 +709,7 @@ func (s *MessengerSuite) TestResendPublicMessage() {
sendResponse1, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse1, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
sentMessage := sendResponse1.Messages[0] sentMessage := sendResponse1.Messages()[0]
err = theirMessenger.ReSendChatMessage(context.Background(), sentMessage.ID) err = theirMessenger.ReSendChatMessage(context.Background(), sentMessage.ID)
s.Require().NoError(err) s.Require().NoError(err)
@ -717,12 +717,12 @@ func (s *MessengerSuite) TestResendPublicMessage() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
actualChat := response.Chats()[0] actualChat := response.Chats()[0]
// It sets the unviewed messages count // It sets the unviewed messages count
@ -740,7 +740,7 @@ func (s *MessengerSuite) TestResendPublicMessage() {
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
response, err = s.m.RetrieveAll() response, err = s.m.RetrieveAll()
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Messages, 0) s.Require().Len(response.Messages(), 0)
} }
// Test receiving a message on an existing private chat // Test receiving a message on an existing private chat
@ -763,13 +763,13 @@ func (s *MessengerSuite) TestRetrieveTheirPrivateChatExisting() {
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
sentMessage := sendResponse.Messages[0] sentMessage := sendResponse.Messages()[0]
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
@ -800,14 +800,14 @@ func (s *MessengerSuite) TestRetrieveTheirPrivateChatNonExisting() {
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
sentMessage := sendResponse.Messages[0] sentMessage := sendResponse.Messages()[0]
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err := WaitOnMessengerResponse( response, err := WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
@ -839,14 +839,14 @@ func (s *MessengerSuite) TestRetrieveTheirPublicChatNonExisting() {
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
// Wait for the message to reach its destination // Wait for the message to reach its destination
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
response, err := s.m.RetrieveAll() response, err := s.m.RetrieveAll()
s.NoError(err) s.NoError(err)
s.Require().Equal(len(response.Messages), 0) s.Require().Equal(len(response.Messages()), 0)
s.Require().Equal(len(response.Chats()), 0) s.Require().Equal(len(response.Chats()), 0)
s.Require().NoError(theirMessenger.Shutdown()) s.Require().NoError(theirMessenger.Shutdown())
} }
@ -896,13 +896,13 @@ func (s *MessengerSuite) TestRetrieveTheirPrivateGroupChat() {
sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage) sendResponse, err := theirMessenger.SendChatMessage(context.Background(), inputMessage)
s.NoError(err) s.NoError(err)
s.Require().Len(sendResponse.Messages, 1) s.Require().Len(sendResponse.Messages(), 1)
sentMessage := sendResponse.Messages[0] sentMessage := sendResponse.Messages()[0]
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
@ -1552,7 +1552,7 @@ func (s *MessengerSuite) TestAddMembersToChat() {
response, err = s.m.AddMembersToGroupChat(context.Background(), chat.ID, members) response, err = s.m.AddMembersToGroupChat(context.Background(), chat.ID, members)
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
chat = response.Chats()[0] chat = response.Chats()[0]
@ -1579,9 +1579,9 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
initialCommandID := senderMessage.ID initialCommandID := senderMessage.ID
@ -1595,16 +1595,16 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
theirMessenger, theirMessenger,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request address for transaction", receiverMessage.Text) s.Require().Equal("Request address for transaction", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -1617,9 +1617,9 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
response, err = theirMessenger.DeclineRequestAddressForTransaction(context.Background(), receiverMessage.ID) response, err = theirMessenger.DeclineRequestAddressForTransaction(context.Background(), receiverMessage.ID)
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage = response.Messages[0] senderMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Request address for transaction declined", senderMessage.Text) s.Require().Equal("Request address for transaction declined", senderMessage.Text)
s.Require().NotNil(senderMessage.CommandParameters) s.Require().NotNil(senderMessage.CommandParameters)
@ -1632,15 +1632,15 @@ func (s *MessengerSuite) TestDeclineRequestAddressForTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage = response.Messages[0] receiverMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request address for transaction declined", receiverMessage.Text) s.Require().Equal("Request address for transaction declined", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -1676,9 +1676,9 @@ func (s *MessengerSuite) TestSendEthTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Transaction sent", senderMessage.Text) s.Require().Equal("Transaction sent", senderMessage.Text)
s.Require().NotNil(senderMessage.CommandParameters) s.Require().NotNil(senderMessage.CommandParameters)
@ -1738,9 +1738,9 @@ func (s *MessengerSuite) TestSendEthTransaction() {
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Transaction received", receiverMessage.Text) s.Require().Equal("Transaction received", receiverMessage.Text)
@ -1780,9 +1780,9 @@ func (s *MessengerSuite) TestSendTokenTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Transaction sent", senderMessage.Text) s.Require().Equal("Transaction sent", senderMessage.Text)
s.Require().NotNil(senderMessage.CommandParameters) s.Require().NotNil(senderMessage.CommandParameters)
@ -1842,9 +1842,9 @@ func (s *MessengerSuite) TestSendTokenTransaction() {
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Transaction received", receiverMessage.Text) s.Require().Equal("Transaction received", receiverMessage.Text)
@ -1878,9 +1878,9 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
initialCommandID := senderMessage.ID initialCommandID := senderMessage.ID
@ -1894,16 +1894,16 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
theirMessenger, theirMessenger,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request address for transaction", receiverMessage.Text) s.Require().Equal("Request address for transaction", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -1916,9 +1916,9 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
response, err = theirMessenger.AcceptRequestAddressForTransaction(context.Background(), receiverMessage.ID, "some-address") response, err = theirMessenger.AcceptRequestAddressForTransaction(context.Background(), receiverMessage.ID, "some-address")
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage = response.Messages[0] senderMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Request address for transaction accepted", senderMessage.Text) s.Require().Equal("Request address for transaction accepted", senderMessage.Text)
s.Require().NotNil(senderMessage.CommandParameters) s.Require().NotNil(senderMessage.CommandParameters)
@ -1932,15 +1932,15 @@ func (s *MessengerSuite) TestAcceptRequestAddressForTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage = response.Messages[0] receiverMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request address for transaction accepted", receiverMessage.Text) s.Require().Equal("Request address for transaction accepted", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -1971,9 +1971,9 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
initialCommandID := senderMessage.ID initialCommandID := senderMessage.ID
@ -1988,16 +1988,16 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
theirMessenger, theirMessenger,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request transaction", receiverMessage.Text) s.Require().Equal("Request transaction", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -2011,9 +2011,9 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage = response.Messages[0] senderMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Transaction request declined", senderMessage.Text) s.Require().Equal("Transaction request declined", senderMessage.Text)
@ -2024,16 +2024,16 @@ func (s *MessengerSuite) TestDeclineRequestTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
s.m, s.m,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage = response.Messages[0] receiverMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Transaction request declined", receiverMessage.Text) s.Require().Equal("Transaction request declined", receiverMessage.Text)
@ -2061,9 +2061,9 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage := response.Messages[0] senderMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
initialCommandID := senderMessage.ID initialCommandID := senderMessage.ID
@ -2078,16 +2078,16 @@ func (s *MessengerSuite) TestRequestTransaction() {
// Wait for the message to reach its destination // Wait for the message to reach its destination
response, err = WaitOnMessengerResponse( response, err = WaitOnMessengerResponse(
theirMessenger, theirMessenger,
func(r *MessengerResponse) bool { return len(r.Messages) > 0 }, func(r *MessengerResponse) bool { return len(r.Messages()) > 0 },
"no messages", "no messages",
) )
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage := response.Messages[0] receiverMessage := response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Request transaction", receiverMessage.Text) s.Require().Equal("Request transaction", receiverMessage.Text)
s.Require().NotNil(receiverMessage.CommandParameters) s.Require().NotNil(receiverMessage.CommandParameters)
@ -2104,9 +2104,9 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().NoError(err) s.Require().NoError(err)
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
senderMessage = response.Messages[0] senderMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, senderMessage.ContentType)
s.Require().Equal("Transaction sent", senderMessage.Text) s.Require().Equal("Transaction sent", senderMessage.Text)
@ -2171,9 +2171,9 @@ func (s *MessengerSuite) TestRequestTransaction() {
s.Require().NotNil(response) s.Require().NotNil(response)
s.Require().Len(response.Chats(), 1) s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages, 1) s.Require().Len(response.Messages(), 1)
receiverMessage = response.Messages[0] receiverMessage = response.Messages()[0]
s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType) s.Require().Equal(protobuf.ChatMessage_TRANSACTION_COMMAND, receiverMessage.ContentType)
s.Require().Equal("Transaction received", receiverMessage.Text) s.Require().Equal("Transaction received", receiverMessage.Text)

View File

@ -36,6 +36,7 @@
// 1622464518_set_synced_to_from.up.sql (105B) // 1622464518_set_synced_to_from.up.sql (105B)
// 1622464519_add_chat_description.up.sql (93B) // 1622464519_add_chat_description.up.sql (93B)
// 1622622253_add_pinned_by_to_pin_messages.up.sql (52B) // 1622622253_add_pinned_by_to_pin_messages.up.sql (52B)
// 1622722745_add_original_message_id.up.sql (66B)
// 1623938329_add_author_activity_center_notification_field.up.sql (66B) // 1623938329_add_author_activity_center_notification_field.up.sql (66B)
// README.md (554B) // README.md (554B)
// doc.go (850B) // doc.go (850B)
@ -827,6 +828,26 @@ func _1622622253_add_pinned_by_to_pin_messagesUpSql() (*asset, error) {
return a, nil return a, nil
} }
var __1622722745_add_original_message_idUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x28\x2d\x4e\x2d\x8a\xcf\x4d\x2d\x2e\x4e\x4c\x4f\x2d\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\xc8\x2f\xca\x4c\xcf\xcc\x4b\xcc\x81\x49\xc6\x67\xa6\x28\x84\x39\x06\x39\x7b\x38\x06\x59\x73\x01\x02\x00\x00\xff\xff\x37\x5e\xdc\xd4\x42\x00\x00\x00")
func _1622722745_add_original_message_idUpSqlBytes() ([]byte, error) {
return bindataRead(
__1622722745_add_original_message_idUpSql,
"1622722745_add_original_message_id.up.sql",
)
}
func _1622722745_add_original_message_idUpSql() (*asset, error) {
bytes, err := _1622722745_add_original_message_idUpSqlBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "1622722745_add_original_message_id.up.sql", size: 66, mode: os.FileMode(0644), modTime: time.Unix(1624368024, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x94, 0x88, 0x73, 0xf6, 0x8e, 0x7f, 0xb1, 0xf2, 0xe, 0x6d, 0x30, 0x7c, 0xfd, 0x69, 0x26, 0xf5, 0x6, 0x97, 0x1d, 0x6f, 0xfb, 0x4b, 0xff, 0x9e, 0xcc, 0xa3, 0x5a, 0xac, 0xcc, 0x37, 0x63, 0xa4}}
return a, nil
}
var __1623938329_add_author_activity_center_notification_fieldUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4c\x2e\xc9\x2c\xcb\x2c\xa9\x8c\x4f\x4e\xcd\x2b\x49\x2d\x8a\xcf\xcb\x2f\xc9\x4c\xcb\x4c\x4e\x2c\xc9\xcc\xcf\x2b\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x48\x2c\x2d\xc9\xc8\x2f\x52\x08\x71\x8d\x08\xb1\xe6\x02\x04\x00\x00\xff\xff\xc4\xaa\x64\x1f\x42\x00\x00\x00") var __1623938329_add_author_activity_center_notification_fieldUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x72\xf4\x09\x71\x0d\x52\x08\x71\x74\xf2\x71\x55\x48\x4c\x2e\xc9\x2c\xcb\x2c\xa9\x8c\x4f\x4e\xcd\x2b\x49\x2d\x8a\xcf\xcb\x2f\xc9\x4c\xcb\x4c\x4e\x2c\xc9\xcc\xcf\x2b\x56\x70\x74\x71\x51\x70\xf6\xf7\x09\xf5\xf5\x53\x48\x2c\x2d\xc9\xc8\x2f\x52\x08\x71\x8d\x08\xb1\xe6\x02\x04\x00\x00\xff\xff\xc4\xaa\x64\x1f\x42\x00\x00\x00")
func _1623938329_add_author_activity_center_notification_fieldUpSqlBytes() ([]byte, error) { func _1623938329_add_author_activity_center_notification_fieldUpSqlBytes() ([]byte, error) {
@ -1050,6 +1071,8 @@ var _bindata = map[string]func() (*asset, error){
"1622622253_add_pinned_by_to_pin_messages.up.sql": _1622622253_add_pinned_by_to_pin_messagesUpSql, "1622622253_add_pinned_by_to_pin_messages.up.sql": _1622622253_add_pinned_by_to_pin_messagesUpSql,
"1622722745_add_original_message_id.up.sql": _1622722745_add_original_message_idUpSql,
"1623938329_add_author_activity_center_notification_field.up.sql": _1623938329_add_author_activity_center_notification_fieldUpSql, "1623938329_add_author_activity_center_notification_field.up.sql": _1623938329_add_author_activity_center_notification_fieldUpSql,
"README.md": readmeMd, "README.md": readmeMd,
@ -1134,6 +1157,7 @@ var _bintree = &bintree{nil, map[string]*bintree{
"1622464518_set_synced_to_from.up.sql": &bintree{_1622464518_set_synced_to_fromUpSql, map[string]*bintree{}}, "1622464518_set_synced_to_from.up.sql": &bintree{_1622464518_set_synced_to_fromUpSql, map[string]*bintree{}},
"1622464519_add_chat_description.up.sql": &bintree{_1622464519_add_chat_descriptionUpSql, map[string]*bintree{}}, "1622464519_add_chat_description.up.sql": &bintree{_1622464519_add_chat_descriptionUpSql, map[string]*bintree{}},
"1622622253_add_pinned_by_to_pin_messages.up.sql": &bintree{_1622622253_add_pinned_by_to_pin_messagesUpSql, map[string]*bintree{}}, "1622622253_add_pinned_by_to_pin_messages.up.sql": &bintree{_1622622253_add_pinned_by_to_pin_messagesUpSql, map[string]*bintree{}},
"1622722745_add_original_message_id.up.sql": &bintree{_1622722745_add_original_message_idUpSql, map[string]*bintree{}},
"1623938329_add_author_activity_center_notification_field.up.sql": &bintree{_1623938329_add_author_activity_center_notification_fieldUpSql, map[string]*bintree{}}, "1623938329_add_author_activity_center_notification_field.up.sql": &bintree{_1623938329_add_author_activity_center_notification_fieldUpSql, map[string]*bintree{}},
"README.md": &bintree{readmeMd, map[string]*bintree{}}, "README.md": &bintree{readmeMd, map[string]*bintree{}},
"doc.go": &bintree{docGo, map[string]*bintree{}}, "doc.go": &bintree{docGo, map[string]*bintree{}},

View File

@ -0,0 +1 @@
ALTER TABLE user_messages ADD COLUMN original_message_id VARCHAR;

View File

@ -283,9 +283,9 @@ type ChatMessage struct {
Payload isChatMessage_Payload `protobuf_oneof:"payload"` Payload isChatMessage_Payload `protobuf_oneof:"payload"`
// Grant for community chat messages // Grant for community chat messages
Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"` Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"`
// Replace indicates that this is a replacement of a message // original_message_id indicates that this is a edit of a message
// that has been updated // that has been updated
Replace string `protobuf:"bytes,14,opt,name=replace,proto3" json:"replace,omitempty"` OriginalMessageId string `protobuf:"bytes,14,opt,name=original_message_id,json=originalMessageId,proto3" json:"original_message_id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -442,9 +442,9 @@ func (m *ChatMessage) GetGrant() []byte {
return nil return nil
} }
func (m *ChatMessage) GetReplace() string { func (m *ChatMessage) GetOriginalMessageId() string {
if m != nil { if m != nil {
return m.Replace return m.OriginalMessageId
} }
return "" return ""
} }
@ -473,46 +473,47 @@ func init() {
} }
var fileDescriptor_263952f55fd35689 = []byte{ var fileDescriptor_263952f55fd35689 = []byte{
// 652 bytes of a gzipped FileDescriptorProto // 661 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xd1, 0x6e, 0xd3, 0x30,
0x14, 0xad, 0x5b, 0x27, 0x8e, 0xaf, 0xd3, 0xc8, 0x9a, 0xf6, 0x6b, 0xe7, 0x43, 0x08, 0x42, 0x84, 0x14, 0x5d, 0xb6, 0xb4, 0x69, 0x6e, 0xba, 0x2a, 0x78, 0x63, 0x33, 0x08, 0x41, 0xa9, 0x90, 0xe8,
0x44, 0x56, 0x59, 0x94, 0x22, 0x75, 0x6b, 0x12, 0x2b, 0x35, 0xc5, 0x4e, 0x18, 0x4f, 0x80, 0xae, 0x53, 0x1f, 0xc6, 0x90, 0xf6, 0x1a, 0xda, 0xa8, 0x0b, 0x23, 0x69, 0x71, 0x5c, 0x60, 0x4f, 0x91,
0xac, 0xa9, 0x33, 0x34, 0x56, 0xeb, 0x1f, 0xc5, 0x13, 0x89, 0xac, 0x79, 0x27, 0xde, 0x88, 0xf7, 0x97, 0x9a, 0x36, 0xda, 0x92, 0x54, 0x8d, 0x2b, 0xd1, 0x4f, 0xe1, 0x47, 0xf8, 0x23, 0xfe, 0x03,
0x40, 0x33, 0xae, 0xeb, 0xb4, 0x1b, 0x56, 0xb9, 0xf7, 0xce, 0x39, 0xc7, 0x37, 0x67, 0xce, 0x00, 0xd9, 0x59, 0x96, 0x6e, 0x2f, 0x3c, 0xf5, 0xde, 0xeb, 0x73, 0x8e, 0x6f, 0x4f, 0x8e, 0x01, 0xc5,
0x8a, 0x57, 0x4c, 0x44, 0x29, 0x2f, 0x4b, 0x76, 0xcb, 0x47, 0xc5, 0x3a, 0x17, 0x39, 0xea, 0xa8, 0x4b, 0x26, 0xa2, 0x94, 0x17, 0x05, 0x5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x30, 0x05, 0xdc, 0x7f, 0x04, 0x00, 0x00, 0x87, 0x87, 0x7b, 0xd3, 0x54, 0xc6, 0x7f, 0xf8, 0x17, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x0e, 0x5a,
0x91, 0x95, 0x04, 0x00, 0x00,
} }

View File

@ -58,9 +58,9 @@ message ChatMessage {
// Grant for community chat messages // Grant for community chat messages
bytes grant = 13; bytes grant = 13;
// Replace indicates that this is a replacement of a message // original_message_id indicates that this is a edit of a message
// that has been updated // that has been updated
string replace = 14; string original_message_id = 14;
enum ContentType { enum ContentType {
UNKNOWN_CONTENT_TYPE = 0; UNKNOWN_CONTENT_TYPE = 0;

View File

@ -191,7 +191,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotification() {
inputMessage := buildTestMessage(*chat) inputMessage := buildTestMessage(*chat)
response, err := alice.SendChatMessage(context.Background(), inputMessage) response, err := alice.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
messageIDString := response.Messages[0].ID messageIDString := response.Messages()[0].ID
messageID, err := hex.DecodeString(messageIDString[2:]) messageID, err := hex.DecodeString(messageIDString[2:])
s.Require().NoError(err) s.Require().NoError(err)
@ -350,7 +350,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationFromContactO
inputMessage := buildTestMessage(*chat) inputMessage := buildTestMessage(*chat)
response, err := alice.SendChatMessage(context.Background(), inputMessage) response, err := alice.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
messageIDString := response.Messages[0].ID messageIDString := response.Messages()[0].ID
messageID, err := hex.DecodeString(messageIDString[2:]) messageID, err := hex.DecodeString(messageIDString[2:])
s.Require().NoError(err) s.Require().NoError(err)
@ -576,7 +576,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationRetries() {
inputMessage = buildTestMessage(*chat) inputMessage = buildTestMessage(*chat)
response, err := alice.SendChatMessage(context.Background(), inputMessage) response, err := alice.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
messageIDString := response.Messages[0].ID messageIDString := response.Messages()[0].ID
messageID, err := hex.DecodeString(messageIDString[2:]) messageID, err := hex.DecodeString(messageIDString[2:])
s.Require().NoError(err) s.Require().NoError(err)
@ -779,7 +779,7 @@ func (s *MessengerPushNotificationSuite) TestReceivePushNotificationMention() {
inputMessage.Text = "Hey @" + types.EncodeHex(crypto.FromECDSAPub(&bob.identity.PublicKey)) inputMessage.Text = "Hey @" + types.EncodeHex(crypto.FromECDSAPub(&bob.identity.PublicKey))
response, err := alice.SendChatMessage(context.Background(), inputMessage) response, err := alice.SendChatMessage(context.Background(), inputMessage)
s.Require().NoError(err) s.Require().NoError(err)
messageIDString := response.Messages[0].ID messageIDString := response.Messages()[0].ID
messageID, err := hex.DecodeString(messageIDString[2:]) messageID, err := hex.DecodeString(messageIDString[2:])
s.Require().NoError(err) s.Require().NoError(err)