@@ -549,13 +549,9 @@ func (ap *ApiProvider) GetSlackConnect(ctx context.Context) ([]slack.User, error
549549 return res , nil
550550}
551551
552- func (ap * ApiProvider ) GetChannels (ctx context.Context , channelTypes []string ) []Channel {
553- if len (channelTypes ) == 0 {
554- channelTypes = AllChanTypes
555- }
556-
552+ func (ap * ApiProvider ) GetChannelsType (ctx context.Context , channelType string ) []Channel {
557553 params := & slack.GetConversationsParameters {
558- Types : AllChanTypes ,
554+ Types : [] string { channelType } ,
559555 Limit : 999 ,
560556 ExcludeArchived : true ,
561557 }
@@ -575,6 +571,10 @@ func (ap *ApiProvider) GetChannels(ctx context.Context, channelTypes []string) [
575571 }
576572
577573 channels , nextcur , err = ap .client .GetConversationsContext (ctx , params )
574+ ap .logger .Debug ("Fetched channels for " ,
575+ zap .String ("channelType" , channelType ),
576+ zap .Int ("count" , len (channels )),
577+ )
578578 if err != nil {
579579 ap .logger .Error ("Failed to fetch channels" , zap .Error (err ))
580580 break
@@ -599,17 +599,30 @@ func (ap *ApiProvider) GetChannels(ctx context.Context, channelTypes []string) [
599599 chans = append (chans , ch )
600600 }
601601
602- for _ , ch := range chans {
603- ap .channels [ch .ID ] = ch
604- ap .channelsInv [ch .Name ] = ch .ID
605- }
606-
607602 if nextcur == "" {
608603 break
609604 }
610605
611606 params .Cursor = nextcur
612607 }
608+ return chans
609+ }
610+
611+ func (ap * ApiProvider ) GetChannels (ctx context.Context , channelTypes []string ) []Channel {
612+ if len (channelTypes ) == 0 {
613+ channelTypes = AllChanTypes
614+ }
615+
616+ var chans []Channel
617+ for _ , t := range AllChanTypes {
618+ var typeChannels = ap .GetChannelsType (ctx , t )
619+ chans = append (chans , typeChannels ... )
620+ }
621+
622+ for _ , ch := range chans {
623+ ap .channels [ch .ID ] = ch
624+ ap .channelsInv [ch .Name ] = ch .ID
625+ }
613626
614627 var res []Channel
615628 for _ , t := range channelTypes {
0 commit comments