Private
Public Access
1
0
Files
Kordophone/model/conversation.go

37 lines
883 B
Go
Raw Normal View History

package model
2023-06-23 00:32:17 -07:00
import (
"strings"
"time"
"github.com/rs/zerolog"
)
type Conversation struct {
Date time.Time `json:"date"`
Participants []string `json:"participantDisplayNames"`
2023-06-18 13:12:06 -07:00
DisplayName *string `json:"displayName"` // Optional
UnreadCount int `json:"unreadCount"`
LastMessagePreview string `json:"lastMessagePreview"`
Guid string `json:"guid"`
}
2023-06-23 00:32:17 -07:00
func (c *Conversation) GetDisplayName() string {
if c.DisplayName == nil {
return strings.Join(c.Participants, ",")
}
return *c.DisplayName
}
func (c Conversation) MarshalZerologObject(e *zerolog.Event) {
e.Str("guid", c.Guid)
e.Time("date", c.Date)
e.Int("unreadCount", c.UnreadCount)
e.Str("lastMessagePreview", c.LastMessagePreview)
e.Strs("participants", c.Participants)
if c.DisplayName != nil {
e.Str("displayName", *c.DisplayName)
}
}