Skip to content

Commit e750a12

Browse files
committed
new changes
1 parent fbf8391 commit e750a12

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

packages/backend/constants/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { TP_ID } from '@prisma/client';
22

33
export type CRM_TP_ID = 'zohocrm' | 'sfdc' | 'pipedrive' | 'hubspot' | 'closecrm';
4-
export type CHAT_TP_ID = 'slack' | 'discord' |'gdrive';
4+
export type CHAT_TP_ID = 'slack' | 'discord' | 'gdrive';
55
export type TICKET_TP_ID = 'linear' | 'clickup' | 'asana' | 'jira' | 'trello' ;
66

77
export const DEFAULT_SCOPE = {

packages/backend/prisma/fields.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -787,15 +787,15 @@ export const chatFields = {
787787
source_field_name: {
788788
[TP_ID.slack]: 'id',
789789
[TP_ID.discord]: 'id',
790-
[TP_ID.gdrive]: 'id',
790+
[TP_ID.gdrive]: undefined,
791791
},
792792
target_field_name: 'id',
793793
},
794794
{
795795
source_field_name: {
796796
[TP_ID.slack]: 'name',
797797
[TP_ID.discord]: 'name',
798-
[TP_ID.gdrive]: 'name',
798+
[TP_ID.gdrive]: undefined,
799799
},
800800
target_field_name: 'name',
801801
},
@@ -813,15 +813,15 @@ export const chatFields = {
813813
source_field_name: {
814814
[TP_ID.slack]: 'id',
815815
[TP_ID.discord]: 'user.id',
816-
[TP_ID.gdrive]: 'id',
816+
[TP_ID.gdrive]: undefined,
817817
},
818818
target_field_name: 'id',
819819
},
820820
{
821821
source_field_name: {
822822
[TP_ID.slack]: 'profile.real_name',
823823
[TP_ID.discord]: 'user.global_name',
824-
[TP_ID.gdrive]: 'realName',
824+
[TP_ID.gdrive]: undefined,
825825
},
826826
target_field_name: 'name',
827827
},

packages/backend/prisma/seed.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async function main() {
133133

134134
Object.values(ChatStandardObjects).forEach((obj) => {
135135
Object.values(TP_ID).forEach(async (tpId) => {
136-
if (!(tpId === 'slack' || tpId === 'discord' || tpId==='gdrive')) return;
136+
if (!(tpId === 'slack' || tpId === 'discord' || tpId ==='gdrive')) return;
137137
const objSchema = chatSchemas.find((s: any) => s.object === obj);
138138
const fieldMappings = objSchema?.fields.map((field: any) => {
139139
const sourceFields: any = (chatFields[obj] as { target_field_name: string }[]).find(

packages/backend/routes/v1/chat/auth.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import prisma, { xprisma } from '../../../prisma/client';
44
import { logError, logInfo, logDebug } from '../../../helpers/logger';
55
import { Prisma, TP_ID } from '@prisma/client';
66
import AuthService from '../../../services/auth';
7-
import axios, { isAxiosError } from 'axios';
7+
import axios from 'axios';
88
import qs from 'qs';
99
import { randomUUID } from 'crypto';
1010
import redis from '../../../redis/client';

packages/backend/services/chat/channels.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import revertTenantMiddleware from '../../helpers/tenantIdMiddleware';
22
import { ChannelsService } from '../../generated/typescript/api/resources/chat/resources/channels/service/ChannelsService';
33
import { logError, logInfo } from '../../helpers/logger';
44
import { isStandardError } from '../../helpers/error';
5-
import { InternalServerError } from '../../generated/typescript/api/resources/common';
5+
import { InternalServerError, NotFoundError } from '../../generated/typescript/api/resources/common';
66
import { TP_ID } from '@prisma/client';
77
import axios from 'axios';
88
import { UnifiedChannel } from '../../models/unified/channel';
@@ -25,6 +25,8 @@ const channelsService = new ChannelsService(
2525
const tenantId = connection.t_id;
2626
const customerId = connection.tp_customer_id;
2727
const botToken = connection.app_bot_token;
28+
const fields=req.query.fields;
29+
2830
logInfo(
2931
'Revert::GET ALL CHANNELS',
3032
connection.app?.env?.accountId,
@@ -86,9 +88,31 @@ const channelsService = new ChannelsService(
8688
)
8789
);
8890

91+
8992
res.send({ status: 'ok', next: undefined, results: channels });
9093
break;
9194
}
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;
92116
}
93117
} catch (error: any) {
94118
logError(error);

packages/js/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ const createIntegrationBlock = function (self, integration) {
12491249
}
12501250
};
12511251
}
1252-
revert = new Revert();
1252+
revert = new revert();
12531253
})();
12541254
module.exports = revert;
12551255
(window as any).Revert = revert;

0 commit comments

Comments
 (0)