@@ -2,7 +2,7 @@ import revertTenantMiddleware from '../../helpers/tenantIdMiddleware';
2
2
import { ChannelsService } from '../../generated/typescript/api/resources/chat/resources/channels/service/ChannelsService' ;
3
3
import { logError , logInfo } from '../../helpers/logger' ;
4
4
import { isStandardError } from '../../helpers/error' ;
5
- import { InternalServerError } from '../../generated/typescript/api/resources/common' ;
5
+ import { InternalServerError , NotFoundError } from '../../generated/typescript/api/resources/common' ;
6
6
import { TP_ID } from '@prisma/client' ;
7
7
import axios from 'axios' ;
8
8
import { UnifiedChannel } from '../../models/unified/channel' ;
@@ -25,6 +25,8 @@ const channelsService = new ChannelsService(
25
25
const tenantId = connection . t_id ;
26
26
const customerId = connection . tp_customer_id ;
27
27
const botToken = connection . app_bot_token ;
28
+ const fields = req . query . fields ;
29
+
28
30
logInfo (
29
31
'Revert::GET ALL CHANNELS' ,
30
32
connection . app ?. env ?. accountId ,
@@ -86,9 +88,31 @@ const channelsService = new ChannelsService(
86
88
)
87
89
) ;
88
90
91
+
89
92
res . send ( { status : 'ok' , next : undefined , results : channels } ) ;
90
93
break ;
91
94
}
95
+ case TP_ID . gdrive : {
96
+ const url = `https://discord.com/api/guilds/${ customerId } /channels` ;
97
+ let channels : any = await axios . get ( url , {
98
+ headers : { Authorization : `Bot ${ botToken } ` } ,
99
+ } ) ;
100
+ channels = await Promise . all (
101
+ channels . data ?. map (
102
+ async ( l : any ) =>
103
+ await unifyObject < any , UnifiedChannel > ( {
104
+ obj : l ,
105
+ tpId : thirdPartyId ,
106
+ objType,
107
+ tenantSchemaMappingId : connection . schema_mapping_id ,
108
+ accountFieldMappingConfig : account . accountFieldMappingConfig ,
109
+ } )
110
+ )
111
+ ) ;
112
+
113
+
114
+ res . send ( { status : 'ok' , next : undefined , results : channels } ) ;
115
+ break ;
92
116
}
93
117
} catch ( error : any) {
94
118
logError ( error ) ;
0 commit comments