@@ -609,10 +609,10 @@ func (ch *Channel) demoteModerators(ctx context.Context, userIDs []string, msg *
609
609
610
610
type markReadOption struct {
611
611
MessageID string `json:"message_id"`
612
+ ThreadID string `json:"thread_id"`
612
613
613
614
UserID string `json:"user_id"`
614
615
}
615
-
616
616
type MarkReadOption func (* markReadOption )
617
617
618
618
func MarkReadUntilMessage (id string ) func (* markReadOption ) {
@@ -621,6 +621,12 @@ func MarkReadUntilMessage(id string) func(*markReadOption) {
621
621
}
622
622
}
623
623
624
+ func MarkReadThread (id string ) func (* markReadOption ) {
625
+ return func (opt * markReadOption ) {
626
+ opt .ThreadID = id
627
+ }
628
+ }
629
+
624
630
// MarkRead sends the mark read event for user with given ID,
625
631
// only works if the `read_events` setting is enabled.
626
632
func (ch * Channel ) MarkRead (ctx context.Context , userID string , options ... MarkReadOption ) (* Response , error ) {
@@ -643,6 +649,49 @@ func (ch *Channel) MarkRead(ctx context.Context, userID string, options ...MarkR
643
649
return & resp , err
644
650
}
645
651
652
+ type markUnreadOption struct {
653
+ MessageID string `json:"message_id"`
654
+ ThreadID string `json:"thread_id"`
655
+
656
+ UserID string `json:"user_id"`
657
+ }
658
+
659
+ type MarkUnreadOption func (option * markUnreadOption )
660
+
661
+ // Specify ID of the message from where the channel is marked unread
662
+ func MarkUnreadFromMessage (id string ) func (* markUnreadOption ) {
663
+ return func (opt * markUnreadOption ) {
664
+ opt .MessageID = id
665
+ }
666
+ }
667
+
668
+ func MarkUnreadThread (id string ) func (* markUnreadOption ) {
669
+ return func (opt * markUnreadOption ) {
670
+ opt .ThreadID = id
671
+ }
672
+ }
673
+
674
+ // MarkUnread message or thread (not both) for specified user.
675
+ func (ch * Channel ) MarkUnread (ctx context.Context , userID string , options ... MarkUnreadOption ) (* Response , error ) {
676
+ if userID == "" {
677
+ return nil , errors .New ("user ID must be not empty" )
678
+ }
679
+
680
+ p := path .Join ("channels" , url .PathEscape (ch .Type ), url .PathEscape (ch .ID ), "unread" )
681
+
682
+ opts := & markUnreadOption {
683
+ UserID : userID ,
684
+ }
685
+
686
+ for _ , fn := range options {
687
+ fn (opts )
688
+ }
689
+
690
+ var resp Response
691
+ err := ch .client .makeRequest (ctx , http .MethodPost , p , nil , opts , & resp )
692
+ return & resp , err
693
+ }
694
+
646
695
// RefreshState makes request to channel api and updates channel internal state.
647
696
func (ch * Channel ) RefreshState (ctx context.Context ) (* QueryResponse , error ) {
648
697
q := & QueryRequest {State : true }
0 commit comments