Private
Public Access
1
0

conversation: adds Equal()

This commit is contained in:
2023-07-19 10:56:49 -06:00
parent ac27ac2d14
commit 7611bedef7
2 changed files with 40 additions and 21 deletions

View File

@@ -24,7 +24,7 @@ func (c *Conversation) GetDisplayName() string {
return *c.DisplayName
}
func (c Conversation) MarshalZerologObject(e *zerolog.Event) {
func (c *Conversation) MarshalZerologObject(e *zerolog.Event) {
e.Str("guid", c.Guid)
e.Time("date", c.Date)
e.Int("unreadCount", c.UnreadCount)
@@ -34,3 +34,39 @@ func (c Conversation) MarshalZerologObject(e *zerolog.Event) {
e.Str("displayName", *c.DisplayName)
}
}
func (c *Conversation) Equal(o *Conversation) bool {
if c.Guid != o.Guid {
return false
}
if !c.Date.Equal(o.Date) {
return false
}
if c.UnreadCount != o.UnreadCount {
return false
}
if c.LastMessagePreview != o.LastMessagePreview {
return false
}
if len(c.Participants) != len(o.Participants) {
return false
}
for i, p := range c.Participants {
if p != o.Participants[i] {
return false
}
}
if c.DisplayName != nil && o.DisplayName != nil {
if *c.DisplayName != *o.DisplayName {
return false
}
}
return true
}