Separate edit message protocol message

This commit is contained in:
Andrea Maria Piana 2021-06-07 10:31:27 +02:00
parent dbdf2565ae
commit 7bac25c8e0
15 changed files with 421 additions and 227 deletions

View File

@ -150,6 +150,9 @@ type Message struct {
// Links is an array of links within given message
Links []string
// EditedAt indicates the clock value it was edited
EditedAt uint64 `json:"editedAt"`
}
func (m *Message) MarshalJSON() ([]byte, error) {
@ -190,6 +193,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
Mentions []string `json:"mentions,omitempty"`
Mentioned bool `json:"mentioned,omitempty"`
Links []string `json:"links,omitempty"`
EditedAt uint64 `json:"editedAt,omitempty"`
}{
ID: m.ID,
WhisperTimestamp: m.WhisperTimestamp,
@ -221,6 +225,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
MessageType: m.MessageType,
CommandParameters: m.CommandParameters,
GapParameters: m.GapParameters,
EditedAt: m.EditedAt,
}
if sticker := m.GetSticker(); sticker != nil {
item.Sticker = &StickerAlias{

47
protocol/edit_message.go Normal file
View File

@ -0,0 +1,47 @@
package protocol
import (
"crypto/ecdsa"
"github.com/golang/protobuf/proto"
"github.com/status-im/status-go/protocol/protobuf"
)
// EditMessage represents an edit of a message from a user in the application layer, used for persistence, querying and
// signaling
type EditMessage struct {
protobuf.EditMessage
// From is a public key of the author of the edit reaction.
From string `json:"from,omitempty"`
// SigPubKey is the ecdsa encoded public key of the edit author
SigPubKey *ecdsa.PublicKey `json:"-"`
// LocalChatID is the chatID of the local chat (one-to-one are not symmetric)
LocalChatID string `json:"localChatId"`
}
// GetSigPubKey returns an ecdsa encoded public key
// this function is required to implement the ChatEntity interface
func (e EditMessage) GetSigPubKey() *ecdsa.PublicKey {
return e.SigPubKey
}
// GetProtoBuf returns the struct's embedded protobuf struct
// this function is required to implement the ChatEntity interface
func (e EditMessage) GetProtobuf() proto.Message {
return &e.EditMessage
}
// SetMessageType a setter for the MessageType field
// this function is required to implement the ChatEntity interface
func (e *EditMessage) SetMessageType(messageType protobuf.MessageType) {
e.MessageType = messageType
}
// WrapGroupMessage indicates whether we should wrap this in membership information
func (e EditMessage) WrapGroupMessage() bool {
return false
}

View File

@ -512,6 +512,10 @@ func (m *MessageHandler) handleWrappedCommunityDescriptionMessage(payload []byte
return m.communitiesManager.HandleWrappedCommunityDescriptionMessage(payload)
}
func (m *MessageHandler) HandleEditMessage(state *ReceivedMessageState) error {
return nil
}
func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
logger := m.logger.With(zap.String("site", "handleChatMessage"))
if err := ValidateReceivedChatMessage(&state.CurrentMessageState.Message, state.CurrentMessageState.WhisperTimestamp); err != nil {
@ -585,20 +589,6 @@ func (m *MessageHandler) HandleChatMessage(state *ReceivedMessageState) error {
return err
}
if len(receivedMessage.OriginalMessageId) != 0 {
if receivedMessage.ContentType != protobuf.ChatMessage_EDIT {
return errors.New("replace can only be used with an edit content type")
}
shouldContinue, err := m.handleEditedMessage(state, receivedMessage)
if err != nil {
return err
}
if !shouldContinue {
return nil
}
}
// If the chat is not active, create a notification in the center
if chat.OneToOne() && !chat.Active {
m.createMessageNotification(chat, state)
@ -1124,50 +1114,43 @@ func (m *MessageHandler) HandleChatIdentity(state *ReceivedMessageState, ci prot
return nil
}
func (m *MessageHandler) handleEditedMessage(state *ReceivedMessageState, message *common.Message) (bool, error) {
originalMessageID := message.OriginalMessageId
// Check if it's already in the response
originalMessage := state.Response.GetMessage(originalMessageID)
// and pull all the edits + original message
messageHistory, err := m.persistence.MessagesByOriginalMessageID(originalMessageID)
if err != nil {
return false, err
}
func (m *MessageHandler) handleEditedMessage(state *ReceivedMessageState, message *protobuf.EditMessage) (bool, error) {
/*
originalMessageID := message.OriginalMessageId
// Check if it's already in the response
originalMessage := state.Response.GetMessage(originalMessageID)
// otherwise pull from database
if originalMessage == nil {
originalMessage, err := m.persistence.MessageByID(originalMessageID)
// Check if we have the original message
if originalMessage == nil {
for _, m := range messageHistory {
if m.ID == originalMessageID {
originalMessage = m
if err != nil {
return false, err
}
}
}
// We don't have the original message, save the edited message hidden and continue
if originalMessage == nil {
// This could be a single query
err := m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
// We don't have the original message, save the edited message
if originalMessage == nil {
// Save edit and return
//m.persistence.SaveMessageEdit()
return false, nil
}
err = m.persistence.HideMessage(message.ID)
if err != nil {
return false, nil
}
// We tell them to ignore this message
return false, nil
}
// We have an original message and potentially some edits
// Check edit is valid
// check that the edit is valid
// Check that edit should be applied
// find the most up to date edit
// Update message and return it */
return true, nil
}
func (m *MessageHandler) checkForEdits(message *common.Message) error {
// Check for any pending edit
// If any pending edits are available and valid, apply them
return nil
}
func (m *MessageHandler) isMessageAllowedFrom(allContacts *contactMap, publicKey string, chat *Chat) (bool, error) {
onlyFromContacts, err := m.settings.GetMessagesFromContactsOnly()
if err != nil {

View File

@ -47,7 +47,7 @@ func (db sqlitePersistence) tableUserMessagesAllFields() string {
command_state,
command_signature,
replace_message,
original_message_id,
edited_at,
rtl,
line_count,
response_to,
@ -88,7 +88,7 @@ func (db sqlitePersistence) tableUserMessagesAllFieldsJoin() string {
m1.command_state,
m1.command_signature,
m1.replace_message,
m1.original_message_id,
m1.edited_at,
m1.rtl,
m1.line_count,
m1.response_to,
@ -129,7 +129,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
var communityID sql.NullString
var gapFrom sql.NullInt64
var gapTo sql.NullInt64
var originalMessageID sql.NullString
var editedAt sql.NullInt64
sticker := &protobuf.StickerMessage{}
command := &common.CommandParameters{}
@ -167,7 +167,7 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
&command.CommandState,
&command.Signature,
&message.Replace,
&originalMessageID,
&editedAt,
&message.RTL,
&message.LineCount,
&message.ResponseTo,
@ -189,8 +189,8 @@ func (db sqlitePersistence) tableUserMessagesScanAllFields(row scanner, message
return err
}
if originalMessageID.Valid {
message.OriginalMessageId = originalMessageID.String
if editedAt.Valid {
message.EditedAt = uint64(editedAt.Int64)
}
if quotedText.Valid {
@ -326,7 +326,7 @@ func (db sqlitePersistence) tableUserMessagesAllValues(message *common.Message)
command.CommandState,
command.Signature,
message.Replace,
message.OriginalMessageId,
message.EditedAt,
message.RTL,
message.LineCount,
message.ResponseTo,
@ -1454,40 +1454,3 @@ func (db sqlitePersistence) clearHistory(chat *Chat, currentClockValue uint64, t
err = db.saveChat(tx, *chat)
return err
}
func (db sqlitePersistence) MessagesByOriginalMessageID(id string) ([]*common.Message, error) {
allFields := db.tableUserMessagesAllFieldsJoin()
// nolint: gosec
rows, err := db.db.Query(fmt.Sprintf(`
SELECT
%s
FROM
user_messages m1
LEFT JOIN
user_messages m2
ON
m1.response_to = m2.id
LEFT JOIN
contacts c
ON
m1.source = c.id
WHERE m1.id = ? OR m1.original_message_id = ?`, allFields), id, id)
if err != nil {
return nil, err
}
defer rows.Close()
var result []*common.Message
for rows.Next() {
var message common.Message
if err := db.tableUserMessagesScanAllFields(rows, &message); err != nil {
return nil, err
}
result = append(result, &message)
}
return result, nil
}

View File

@ -2070,30 +2070,6 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
if err != nil {
return nil, err
}
} else if message.ContentType == protobuf.ChatMessage_EDIT {
if len(message.OriginalMessageId) == 0 {
return nil, errors.New("the id of the message to replace is required")
}
msgToReplace, err := m.persistence.MessageByID(message.OriginalMessageId)
if err != nil {
return nil, err
}
sender, err := msgToReplace.GetSenderPubKey()
if err != nil {
return nil, err
}
if !sender.Equal(&m.identity.PublicKey) {
return nil, errors.New("sender is not the author of the message")
}
if msgToReplace.ContentType != protobuf.ChatMessage_TEXT_PLAIN {
return nil, errors.New("only text messages can be replaced")
}
message.ChatId = msgToReplace.ChatId
}
var response MessengerResponse

View File

@ -11,7 +11,7 @@ import (
gethbridge "github.com/status-im/status-go/eth-node/bridge/geth"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
)
@ -87,14 +87,21 @@ func (s *MessengerEditMessageSuite) TestEditMessage() {
ogMessage := sendResponse.Messages()[0]
editedMessage := buildTestMessage(*theirChat)
editedMessage.OriginalMessageId = ogMessage.ID
editedMessage.ContentType = protobuf.ChatMessage_EDIT
messageID, err := types.DecodeHex(ogMessage.ID)
s.Require().NoError(err)
sendResponse, err = theirMessenger.SendChatMessage(context.Background(), editedMessage)
editedText := "edited text"
editedMessage := &requests.EditMessage{
ID: messageID,
Text: editedText,
}
sendResponse, err = theirMessenger.EditMessage(context.Background(), editedMessage)
s.Require().NoError(err)
s.Require().Len(sendResponse.Messages(), 1)
s.Require().NotEmpty(sendResponse.Messages()[0].EditedAt)
s.Require().Equal(sendResponse.Messages()[0].Text, editedText)
response, err = WaitOnMessengerResponse(
s.m,
@ -105,13 +112,14 @@ func (s *MessengerEditMessageSuite) TestEditMessage() {
s.Require().Len(response.Chats(), 1)
s.Require().Len(response.Messages(), 1)
s.Require().Equal(ogMessage.ID, response.Messages()[0].OriginalMessageId)
s.Require().NotEmpty(response.Messages()[0].EditedAt)
// Main instance user attempts to edit the message it received from theirMessenger
editedMessage = buildTestMessage(*ourChat)
editedMessage.OriginalMessageId = ogMessage.ID
editedMessage.ContentType = protobuf.ChatMessage_EDIT
_, err = s.m.SendChatMessage(context.Background(), editedMessage)
editedMessage = &requests.EditMessage{
ID: messageID,
Text: "edited-again text",
}
_, err = s.m.EditMessage(context.Background(), editedMessage)
s.Require().Equal("sender is not the author of the message", err.Error())
s.Require().Equal(ErrInvalidEditAuthor, err.Error())
}

View File

@ -0,0 +1,88 @@
package protocol
import (
"context"
"errors"
"fmt"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/requests"
)
var ErrInvalidEditAuthor = errors.New("sender is not the author of the message")
var ErrInvalidEditContentType = errors.New("only text messages can be replaced")
func (m *Messenger) EditMessage(ctx context.Context, request *requests.EditMessage) (*MessengerResponse, error) {
err := request.Validate()
if err != nil {
return nil, err
}
fmt.Println("IDDD", request.ID.String())
message, err := m.persistence.MessageByID(request.ID.String())
if err != nil {
return nil, err
}
sender, err := message.GetSenderPubKey()
if err != nil {
return nil, err
}
if !sender.Equal(&m.identity.PublicKey) {
return nil, ErrInvalidEditAuthor
}
if message.ContentType != protobuf.ChatMessage_TEXT_PLAIN {
return nil, ErrInvalidEditContentType
}
// A valid added chat is required.
chat, ok := m.allChats.Load(message.ChatId)
if !ok {
return nil, errors.New("Chat not found")
}
clock, _ := chat.NextClockAndTimestamp(m.getTimesource())
message.Text = request.Text
message.EditedAt = clock
err = message.PrepareContent(common.PubkeyToHex(&m.identity.PublicKey))
if err != nil {
return nil, err
}
err = m.persistence.SaveMessages([]*common.Message{message})
if err != nil {
return nil, err
}
editMessage := &EditMessage{}
editMessage.Text = request.Text
editMessage.ChatId = message.ChatId
editMessage.MessageId = request.ID.String()
editMessage.Clock = clock
encodedMessage, err := m.encodeChatEntity(chat, editMessage)
if err != nil {
return nil, err
}
rawMessage := common.RawMessage{
LocalChatID: chat.ID,
Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_EDIT_MESSAGE,
ResendAutomatically: true,
}
_, err = m.dispatchMessage(ctx, rawMessage)
if err != nil {
return nil, err
}
response := &MessengerResponse{}
response.AddMessage(message)
return response, nil
}

View File

@ -36,7 +36,7 @@
// 1622464518_set_synced_to_from.up.sql (105B)
// 1622464519_add_chat_description.up.sql (93B)
// 1622622253_add_pinned_by_to_pin_messages.up.sql (52B)
// 1622722745_add_original_message_id.up.sql (66B)
// 1622722745_add_original_message_id.up.sql (254B)
// 1623938329_add_author_activity_center_notification_field.up.sql (66B)
// README.md (554B)
// doc.go (850B)
@ -828,7 +828,7 @@ func _1622622253_add_pinned_by_to_pin_messagesUpSql() (*asset, error) {
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")
var __1622722745_add_original_message_idUpSql = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x74\xcc\x41\x0a\xc2\x30\x10\x85\xe1\x7d\x4e\xf1\x96\x0a\xde\xa0\xab\xb1\x1d\x54\x88\x29\x84\xd4\x6d\x28\xcd\xa0\x45\xa5\xd0\x49\xc1\xe3\x4b\x41\x17\x42\x5c\x7f\xef\xfd\x64\x03\x7b\x04\xda\x5b\xc6\xa2\x32\xc7\xa7\xa8\xf6\x57\x51\x50\xd3\xa0\x6e\x6d\x77\x76\x90\x34\x66\x49\xb1\xcf\x38\xb9\xc0\x07\xf6\x95\x31\xb5\x67\x0a\x5c\x7a\xc6\x75\xae\xd8\x18\x60\x78\x4c\xc3\xfd\x7b\x82\x6b\x03\x5c\x67\xed\x6e\x95\x5b\x9f\xe3\x98\x70\x21\x5f\x1f\xe9\xd7\x3e\xa1\x7f\xac\xd3\x32\x0f\x52\xa4\x2c\xaf\x5c\x84\x42\xca\x6c\x2b\xf3\x0e\x00\x00\xff\xff\x78\xbe\xc2\xbb\xfe\x00\x00\x00")
func _1622722745_add_original_message_idUpSqlBytes() ([]byte, error) {
return bindataRead(
@ -843,8 +843,8 @@ func _1622722745_add_original_message_idUpSql() (*asset, error) {
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}}
info := bindataFileInfo{name: "1622722745_add_original_message_id.up.sql", size: 254, mode: os.FileMode(0644), modTime: time.Unix(1624368035, 0)}
a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x12, 0x7e, 0x5e, 0x10, 0xbe, 0xe6, 0xdf, 0xb7, 0xbe, 0xce, 0x67, 0xcf, 0x63, 0xae, 0x4, 0x80, 0xab, 0xc3, 0x74, 0x9, 0x3b, 0x6b, 0x48, 0xa9, 0xd0, 0x79, 0xbe, 0x2d, 0xb7, 0x0, 0x5, 0xfc}}
return a, nil
}

View File

@ -1 +1,10 @@
ALTER TABLE user_messages ADD COLUMN original_message_id VARCHAR;
ALTER TABLE user_messages ADD COLUMN edited_at INTEGER;
CREATE TABLE user_messages_edits (
clock INTEGER NOT NULL,
chat_id VARCHAR NOT NULL,
message_id VARCHAR NOT NULL,
source VARCHAR NOT NULL,
text VARCHAR NOT NULL,
id VARCHAR NOT NULL
);

View File

@ -52,6 +52,7 @@ const (
ApplicationMetadataMessage_COMMUNITY_INVITATION ApplicationMetadataMessage_Type = 26
ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN ApplicationMetadataMessage_Type = 27
ApplicationMetadataMessage_PIN_MESSAGE ApplicationMetadataMessage_Type = 28
ApplicationMetadataMessage_EDIT_MESSAGE ApplicationMetadataMessage_Type = 29
)
var ApplicationMetadataMessage_Type_name = map[int32]string{
@ -84,6 +85,7 @@ var ApplicationMetadataMessage_Type_name = map[int32]string{
26: "COMMUNITY_INVITATION",
27: "COMMUNITY_REQUEST_TO_JOIN",
28: "PIN_MESSAGE",
29: "EDIT_MESSAGE",
}
var ApplicationMetadataMessage_Type_value = map[string]int32{
@ -116,6 +118,7 @@ var ApplicationMetadataMessage_Type_value = map[string]int32{
"COMMUNITY_INVITATION": 26,
"COMMUNITY_REQUEST_TO_JOIN": 27,
"PIN_MESSAGE": 28,
"EDIT_MESSAGE": 29,
}
func (x ApplicationMetadataMessage_Type) String() string {
@ -194,40 +197,40 @@ func init() {
}
var fileDescriptor_ad09a6406fcf24c7 = []byte{
// 546 bytes of a gzipped FileDescriptorProto
// 553 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x4d, 0x53, 0xdb, 0x3e,
0x10, 0xc6, 0xff, 0x01, 0xfe, 0x04, 0x96, 0x37, 0xb1, 0x40, 0x31, 0xef, 0x34, 0xed, 0xb4, 0xb4,
0x10, 0xc6, 0xff, 0x01, 0xfe, 0x04, 0x96, 0x37, 0xb1, 0x40, 0x09, 0xef, 0x34, 0xed, 0xb4, 0xb4,
0x9d, 0xc9, 0xa1, 0x3d, 0xf7, 0x20, 0xe4, 0x05, 0x44, 0x63, 0xc9, 0x48, 0x32, 0x9d, 0x9c, 0x34,
0xa6, 0xb8, 0x0c, 0x33, 0x40, 0x3c, 0x60, 0x0e, 0x7c, 0xca, 0x7e, 0x8a, 0x7e, 0x8f, 0x8e, 0x9d,
0x84, 0x40, 0x09, 0xe5, 0x94, 0xd1, 0xf3, 0xfc, 0x76, 0x95, 0x7d, 0x56, 0x86, 0x46, 0x9a, 0xe7,
0x17, 0xe7, 0x3f, 0xd2, 0xe2, 0xbc, 0x73, 0xe5, 0x2f, 0xb3, 0x22, 0x3d, 0x4d, 0x8b, 0xd4, 0x5f,
0x66, 0x37, 0x37, 0xe9, 0x59, 0xd6, 0xcc, 0xaf, 0x3b, 0x45, 0x07, 0x27, 0xaa, 0x9f, 0x93, 0xdb,
0x9f, 0x8d, 0xdf, 0x75, 0x58, 0xe5, 0x83, 0x82, 0xa8, 0xc7, 0x47, 0x5d, 0x1c, 0xd7, 0x61, 0xf2,
0xe6, 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x41, 0x30, 0x04, 0x00, 0x00,
}

View File

@ -41,5 +41,6 @@ message ApplicationMetadataMessage {
COMMUNITY_INVITATION = 26;
COMMUNITY_REQUEST_TO_JOIN = 27;
PIN_MESSAGE = 28;
EDIT_MESSAGE = 29;
}
}

View File

@ -64,7 +64,6 @@ const (
ChatMessage_COMMUNITY ChatMessage_ContentType = 9
// Only local
ChatMessage_SYSTEM_MESSAGE_GAP ChatMessage_ContentType = 10
ChatMessage_EDIT ChatMessage_ContentType = 11
)
var ChatMessage_ContentType_name = map[int32]string{
@ -79,7 +78,6 @@ var ChatMessage_ContentType_name = map[int32]string{
8: "AUDIO",
9: "COMMUNITY",
10: "SYSTEM_MESSAGE_GAP",
11: "EDIT",
}
var ChatMessage_ContentType_value = map[string]int32{
@ -94,7 +92,6 @@ var ChatMessage_ContentType_value = map[string]int32{
"AUDIO": 8,
"COMMUNITY": 9,
"SYSTEM_MESSAGE_GAP": 10,
"EDIT": 11,
}
func (x ChatMessage_ContentType) String() string {
@ -102,7 +99,7 @@ func (x ChatMessage_ContentType) String() string {
}
func (ChatMessage_ContentType) EnumDescriptor() ([]byte, []int) {
return fileDescriptor_263952f55fd35689, []int{3, 0}
return fileDescriptor_263952f55fd35689, []int{4, 0}
}
type StickerMessage struct {
@ -254,6 +251,88 @@ func (m *AudioMessage) GetDurationMs() uint64 {
return 0
}
type EditMessage struct {
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
// Text of the message
Text string `protobuf:"bytes,2,opt,name=text,proto3" json:"text,omitempty"`
ChatId string `protobuf:"bytes,3,opt,name=chat_id,json=chatId,proto3" json:"chat_id,omitempty"`
MessageId string `protobuf:"bytes,4,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"`
// Grant for community edit messages
Grant []byte `protobuf:"bytes,5,opt,name=grant,proto3" json:"grant,omitempty"`
// The type of message (public/one-to-one/private-group-chat)
MessageType MessageType `protobuf:"varint,6,opt,name=message_type,json=messageType,proto3,enum=protobuf.MessageType" json:"message_type,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *EditMessage) Reset() { *m = EditMessage{} }
func (m *EditMessage) String() string { return proto.CompactTextString(m) }
func (*EditMessage) ProtoMessage() {}
func (*EditMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_263952f55fd35689, []int{3}
}
func (m *EditMessage) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_EditMessage.Unmarshal(m, b)
}
func (m *EditMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_EditMessage.Marshal(b, m, deterministic)
}
func (m *EditMessage) XXX_Merge(src proto.Message) {
xxx_messageInfo_EditMessage.Merge(m, src)
}
func (m *EditMessage) XXX_Size() int {
return xxx_messageInfo_EditMessage.Size(m)
}
func (m *EditMessage) XXX_DiscardUnknown() {
xxx_messageInfo_EditMessage.DiscardUnknown(m)
}
var xxx_messageInfo_EditMessage proto.InternalMessageInfo
func (m *EditMessage) GetClock() uint64 {
if m != nil {
return m.Clock
}
return 0
}
func (m *EditMessage) GetText() string {
if m != nil {
return m.Text
}
return ""
}
func (m *EditMessage) GetChatId() string {
if m != nil {
return m.ChatId
}
return ""
}
func (m *EditMessage) GetMessageId() string {
if m != nil {
return m.MessageId
}
return ""
}
func (m *EditMessage) GetGrant() []byte {
if m != nil {
return m.Grant
}
return nil
}
func (m *EditMessage) GetMessageType() MessageType {
if m != nil {
return m.MessageType
}
return MessageType_UNKNOWN_MESSAGE_TYPE
}
type ChatMessage struct {
// Lamport timestamp of the chat message
Clock uint64 `protobuf:"varint,1,opt,name=clock,proto3" json:"clock,omitempty"`
@ -282,10 +361,7 @@ type ChatMessage struct {
// *ChatMessage_Community
Payload isChatMessage_Payload `protobuf_oneof:"payload"`
// Grant for community chat messages
Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"`
// original_message_id indicates that this is a edit of a message
// that has been updated
OriginalMessageId string `protobuf:"bytes,14,opt,name=original_message_id,json=originalMessageId,proto3" json:"original_message_id,omitempty"`
Grant []byte `protobuf:"bytes,13,opt,name=grant,proto3" json:"grant,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -295,7 +371,7 @@ 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_263952f55fd35689, []int{3}
return fileDescriptor_263952f55fd35689, []int{4}
}
func (m *ChatMessage) XXX_Unmarshal(b []byte) error {
@ -442,13 +518,6 @@ func (m *ChatMessage) GetGrant() []byte {
return nil
}
func (m *ChatMessage) GetOriginalMessageId() string {
if m != nil {
return m.OriginalMessageId
}
return ""
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*ChatMessage) XXX_OneofWrappers() []interface{} {
return []interface{}{
@ -465,6 +534,7 @@ func init() {
proto.RegisterType((*StickerMessage)(nil), "protobuf.StickerMessage")
proto.RegisterType((*ImageMessage)(nil), "protobuf.ImageMessage")
proto.RegisterType((*AudioMessage)(nil), "protobuf.AudioMessage")
proto.RegisterType((*EditMessage)(nil), "protobuf.EditMessage")
proto.RegisterType((*ChatMessage)(nil), "protobuf.ChatMessage")
}
@ -473,47 +543,48 @@ func init() {
}
var fileDescriptor_263952f55fd35689 = []byte{
// 661 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xd1, 0x6e, 0xd3, 0x30,
0x14, 0x5d, 0xb6, 0xb4, 0x69, 0x6e, 0xba, 0x2a, 0x78, 0x63, 0x33, 0x08, 0x41, 0xa9, 0x90, 0xe8,
0x53, 0x1f, 0xc6, 0x90, 0xf6, 0x1a, 0xda, 0xa8, 0x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bc, 0x6f,
0x0e, 0x75, 0xa3, 0x31, 0x99, 0xcc, 0xa6, 0x76, 0x53, 0xaa, 0x79, 0xbe, 0x33, 0x76, 0x6d, 0x43,
0x96, 0x2a, 0xf6, 0x76, 0x0b, 0x1d, 0x82, 0x29, 0xc5, 0x66, 0x81, 0x47, 0xaf, 0x6d, 0x53, 0x3e,
0x8c, 0x27, 0x72, 0x63, 0x67, 0x6a, 0x03, 0x6a, 0x81, 0xee, 0x8e, 0x3c, 0x6a, 0x5b, 0x9f, 0xcc,
0x87, 0x87, 0x7b, 0xd3, 0x54, 0xc6, 0x7f, 0xf8, 0x17, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x0e, 0x5a,
0x91, 0x95, 0x04, 0x00, 0x00,
// 678 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0x9b, 0x4c,
0x10, 0x0e, 0xf1, 0x07, 0x66, 0x70, 0x22, 0xb4, 0xc9, 0x9b, 0xf0, 0xbe, 0x7a, 0xdb, 0xb8, 0x56,
0xa5, 0xfa, 0xe4, 0x43, 0x9a, 0x4a, 0xb9, 0x52, 0x07, 0x39, 0x34, 0x05, 0xbb, 0xcb, 0xba, 0x6d,
0x4e, 0x68, 0x83, 0xb7, 0x31, 0x4a, 0xf8, 0x90, 0x59, 0x4b, 0xf5, 0x1f, 0xeb, 0xb5, 0x3f, 0xa4,
0x87, 0xfe, 0x95, 0x6a, 0x17, 0x63, 0x88, 0x2f, 0xe9, 0xc9, 0x33, 0xc3, 0x3c, 0x0f, 0xf3, 0x3c,
0xcc, 0x18, 0x50, 0xb8, 0xa0, 0x3c, 0x88, 0x59, 0x9e, 0xd3, 0x7b, 0x36, 0xcc, 0x96, 0x29, 0x4f,
0x51, 0x47, 0xfe, 0xdc, 0xad, 0xbe, 0xfd, 0xa7, 0xb3, 0x64, 0x15, 0xe7, 0x45, 0xb9, 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ae, 0x2d, 0xed, 0x7b, 0xfb, 0x27, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x56,
0xc0, 0x4f, 0x1d, 0x05, 0x00, 0x00,
}

View File

@ -25,6 +25,22 @@ message AudioMessage {
}
}
message EditMessage {
uint64 clock = 1;
// Text of the message
string text = 2;
string chat_id = 3;
string message_id = 4;
// Grant for community edit messages
bytes grant = 5;
// The type of message (public/one-to-one/private-group-chat)
MessageType message_type = 6;
}
message ChatMessage {
// Lamport timestamp of the chat message
uint64 clock = 1;
@ -58,10 +74,6 @@ message ChatMessage {
// Grant for community chat messages
bytes grant = 13;
// original_message_id indicates that this is a edit of a message
// that has been updated
string original_message_id = 14;
enum ContentType {
UNKNOWN_CONTENT_TYPE = 0;
TEXT_PLAIN = 1;
@ -76,6 +88,5 @@ message ChatMessage {
COMMUNITY = 9;
// Only local
SYSTEM_MESSAGE_GAP = 10;
EDIT = 11;
}
}

View File

@ -0,0 +1,27 @@
package requests
import (
"errors"
"github.com/status-im/status-go/eth-node/types"
)
var ErrEditMessageInvalidID = errors.New("edit-message: invalid id")
var ErrEditMessageInvalidText = errors.New("edit-message: invalid text")
type EditMessage struct {
ID types.HexBytes `json:"id"`
Text string `json:"text"`
}
func (e *EditMessage) Validate() error {
if len(e.ID) == 0 {
return ErrEditMessageInvalidID
}
if len(e.Text) == 0 {
return ErrEditMessageInvalidText
}
return nil
}

View File

@ -230,6 +230,8 @@ func (m *StatusMessage) HandleApplication() error {
return m.unmarshalProtobufData(new(protobuf.CommunityInvitation))
case protobuf.ApplicationMetadataMessage_COMMUNITY_REQUEST_TO_JOIN:
return m.unmarshalProtobufData(new(protobuf.CommunityRequestToJoin))
case protobuf.ApplicationMetadataMessage_EDIT_MESSAGE:
return m.unmarshalProtobufData(new(protobuf.EditMessage))
case protobuf.ApplicationMetadataMessage_PUSH_NOTIFICATION_REGISTRATION:
// This message is a bit different as it's encrypted, so we pass it straight through
v := reflect.ValueOf(m.UnwrappedPayload)