Fix protobuf type of incoming message/conversation events

This commit is contained in:
Tulir Asokan 2023-08-25 18:29:27 +03:00
parent 8fcb4283a9
commit 821849a25b
4 changed files with 19 additions and 15 deletions

View file

@ -190,19 +190,23 @@ func (c *Client) handleUpdatesEvent(msg *IncomingRPCMessage) {
c.triggerEvent(evt.SettingsEvent) c.triggerEvent(evt.SettingsEvent)
case *gmproto.UpdateEvents_ConversationEvent: case *gmproto.UpdateEvents_ConversationEvent:
if c.deduplicateUpdate(evt.ConversationEvent.GetData().GetConversationID(), msg) { for _, part := range evt.ConversationEvent.GetData() {
return if c.deduplicateUpdate(part.GetConversationID(), msg) {
return
}
c.triggerEvent(part)
} }
c.triggerEvent(evt.ConversationEvent.GetData())
case *gmproto.UpdateEvents_MessageEvent: case *gmproto.UpdateEvents_MessageEvent:
if c.deduplicateUpdate(evt.MessageEvent.GetData().GetMessageID(), msg) { for _, part := range evt.MessageEvent.GetData() {
return if c.deduplicateUpdate(part.GetMessageID(), msg) {
return
}
c.triggerEvent(&WrappedMessage{
Message: part,
Data: msg.DecryptedData,
})
} }
c.triggerEvent(&WrappedMessage{
Message: evt.MessageEvent.GetData(),
Data: msg.DecryptedData,
})
case *gmproto.UpdateEvents_TypingEvent: case *gmproto.UpdateEvents_TypingEvent:
c.logContent(msg, "", nil) c.logContent(msg, "", nil)

View file

@ -290,7 +290,7 @@ type ConversationEvent struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Data *Conversation `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Data []*Conversation `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"`
} }
func (x *ConversationEvent) Reset() { func (x *ConversationEvent) Reset() {
@ -325,7 +325,7 @@ func (*ConversationEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{1} return file_events_proto_rawDescGZIP(), []int{1}
} }
func (x *ConversationEvent) GetData() *Conversation { func (x *ConversationEvent) GetData() []*Conversation {
if x != nil { if x != nil {
return x.Data return x.Data
} }
@ -384,7 +384,7 @@ type MessageEvent struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Data *Message `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` Data []*Message `protobuf:"bytes,2,rep,name=data,proto3" json:"data,omitempty"`
} }
func (x *MessageEvent) Reset() { func (x *MessageEvent) Reset() {
@ -419,7 +419,7 @@ func (*MessageEvent) Descriptor() ([]byte, []int) {
return file_events_proto_rawDescGZIP(), []int{3} return file_events_proto_rawDescGZIP(), []int{3}
} }
func (x *MessageEvent) GetData() *Message { func (x *MessageEvent) GetData() []*Message {
if x != nil { if x != nil {
return x.Data return x.Data
} }

Binary file not shown.

View file

@ -35,7 +35,7 @@ message UpdateEvents {
} }
message ConversationEvent { message ConversationEvent {
conversations.Conversation data = 2; repeated conversations.Conversation data = 2;
} }
message TypingEvent { message TypingEvent {
@ -43,7 +43,7 @@ message TypingEvent {
} }
message MessageEvent { message MessageEvent {
conversations.Message data = 2; repeated conversations.Message data = 2;
} }
message UserAlertEvent { message UserAlertEvent {