Skip to content

Commit

Permalink
Merge pull request #196 from tada-team/12954-message-threads
Browse files Browse the repository at this point in the history
feat: add thread chat type
  • Loading branch information
fadinflame authored Jun 20, 2023
2 parents 3aaf44c + ce925c0 commit e8d8245
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chat_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const (

//Meeting
MeetingChatType ChatType = "meeting"

// Thread chat
ThreadChatType ChatType = "thread"
)

func (ct ChatType) JidPrefix() string {
Expand All @@ -31,6 +34,8 @@ func (ct ChatType) JidPrefix() string {
return TaskPrefix
case MeetingChatType:
return MeetingPrefix
case ThreadChatType:
return ThreadPrefix
default:
log.Panicf("JidPrefix(): incorrect chat type: %s", ct)
return ""
Expand All @@ -43,3 +48,4 @@ func (ct ChatType) IsDirect() bool { return ct == DirectChatType }
func (ct ChatType) IsGroup() bool { return ct == GroupChatType }
func (ct ChatType) IsTask() bool { return ct == TaskChatType }
func (ct ChatType) IsMeeting() bool { return ct == MeetingChatType }
func (ct ChatType) IsThread() bool { return ct == ThreadChatType }
4 changes: 4 additions & 0 deletions jid.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const (
GroupSectionPrefix = "sg-"
TaskSectionPrefix = "st-"
MeetingPrefix = "m-"
ThreadPrefix = "th-"
)

type HasJid interface {
Expand All @@ -35,6 +36,8 @@ func (jid JID) ChatType() ChatType {
return TaskChatType
case jid.IsMeeting():
return MeetingChatType
case jid.IsThread():
return ThreadChatType
default:
log.Fatalf("invalid chat type: %s", jid)
return ""
Expand All @@ -46,6 +49,7 @@ func (jid JID) IsGroup() bool { return strings.HasPrefix(jid.String(), GroupPr
func (jid JID) IsTask() bool { return strings.HasPrefix(jid.String(), TaskPrefix) }
func (jid JID) IsSection() bool { return strings.HasPrefix(jid.String(), ContactSectionPrefix) }
func (jid JID) IsMeeting() bool { return strings.HasPrefix(jid.String(), MeetingPrefix) }
func (jid JID) IsThread() bool { return strings.HasPrefix(jid.String(), ThreadPrefix) }

func (jid JID) Empty() bool { return jid.String() == "" }
func (jid JID) JID() JID { return jid }
Expand Down
6 changes: 6 additions & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ type Message struct {

// Debug information, if any
Debug string `json:"_debug,omitempty" tdproto:"readonly"`

// ThreadJID
ThreadJID JID `json:"thread_jid,omitempty"`

// Thread Messages Count
ThreadMessagesCount int `json:"thread_messages_count,omitempty"`
}

// Website title and description
Expand Down

0 comments on commit e8d8245

Please sign in to comment.