Skip to content

Commit

Permalink
🐛 Fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
naelob committed Jan 8, 2024
1 parent 6347c6f commit 56c9ae4
Show file tree
Hide file tree
Showing 25 changed files with 1,218 additions and 271 deletions.
4 changes: 2 additions & 2 deletions apps/frontend-snippet/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ export const providersConfig: ProvidersConfig = {
logoPath: 'assets/ticketing/front.png',
},
'zendesk_tcg': {
clientId: 'panora_ticketing',
clientId: 'panora_bbb',
scopes: 'read write',
authBaseUrl: 'https://panora3702.zendesk.com/oauth/authorizations/new',
authBaseUrl: 'https://panora7548.zendesk.com/oauth/authorizations/new',
logoPath: 'assets/crm/zendesk_logo.png',
},
},
Expand Down
7 changes: 1 addition & 6 deletions packages/api/src/@core/connections/connections.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,6 @@ export class ConnectionsController {
@ApiResponse({ status: 200 })
@Get()
async getConnections() {
return await this.prisma.connections.findMany({
select: {
access_token: false,
refresh_token: false,
},
});
return await this.prisma.connections.findMany();
}
}
8 changes: 6 additions & 2 deletions packages/api/src/crm/contact/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,12 @@ export class SyncContactsService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');

if (!connection) {
this.logger.warn(
`Skipping contacts syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}
// get potential fieldMappings and extract the original properties name
const customFieldMappings =
await this.fieldMappingService.getCustomFieldMappings(
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/ticketing/account/account.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export class AccountController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down
11 changes: 8 additions & 3 deletions packages/api/src/ticketing/account/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export class SyncService implements OnModuleInit {

async onModuleInit() {
try {
//await this.syncAccounts();
await this.syncAccounts();
} catch (error) {
handleServiceError(error, this.logger);
}
}

//@Cron('*/20 * * * *')
@Cron('*/20 * * * *')
//function used by sync worker which populate our tcg_accounts table
//its role is to fetch all accounts from providers 3rd parties and save the info inside our db
async syncAccounts() {
Expand Down Expand Up @@ -99,7 +99,12 @@ export class SyncService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');
if (!connection) {
this.logger.warn(
`Skipping accounts syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}

// get potential fieldMappings and extract the original properties name
const customFieldMappings =
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/ticketing/account/types/mappingsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const githubAccountMapper = new GithubAccountMapper();

export const accountUnificationMapping = {
zendesk_tcg: {
unify: zendeskAccountMapper.unify,
unify: zendeskAccountMapper.unify.bind(zendeskAccountMapper),
desunify: zendeskAccountMapper.desunify,
},
front: {
unify: frontAccountMapper.unify,
unify: frontAccountMapper.unify.bind(frontAccountMapper),
desunify: frontAccountMapper.desunify,
},
github: {
unify: githubAccountMapper.unify,
unify: githubAccountMapper.unify.bind(githubAccountMapper),
desunify: githubAccountMapper.desunify,
},
};
12 changes: 9 additions & 3 deletions packages/api/src/ticketing/attachment/attachment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export class AttachmentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down Expand Up @@ -169,7 +171,9 @@ export class AttachmentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down Expand Up @@ -209,6 +213,8 @@ export class AttachmentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const zendeskAttachmentMapper = new ZendeskAttachmentMapper();
const githubAttachmentMapper = new GithubAttachmentMapper();
const frontAttachmentMapper = new FrontAttachmentMapper();

export const commentUnificationMapping = {
export const attachmentUnificationMapping = {
zendesk_tcg: {
unify: zendeskAttachmentMapper.unify.bind(zendeskAttachmentMapper),
desunify: zendeskAttachmentMapper.desunify,
Expand Down
12 changes: 9 additions & 3 deletions packages/api/src/ticketing/comment/comment.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ export class CommentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down Expand Up @@ -141,7 +143,9 @@ export class CommentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down Expand Up @@ -181,6 +185,8 @@ export class CommentController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}
}
10 changes: 7 additions & 3 deletions packages/api/src/ticketing/comment/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SyncService implements OnModuleInit {

async onModuleInit() {
try {
//await this.syncComments();
await this.syncComments();
} catch (error) {
handleServiceError(error, this.logger);
}
Expand Down Expand Up @@ -110,8 +110,12 @@ export class SyncService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');

if (!connection) {
this.logger.warn(
`Skipping comments syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}
// get potential fieldMappings and extract the original properties name
const customFieldMappings =
await this.fieldMappingService.getCustomFieldMappings(
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/ticketing/contact/contact.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export class ContactController {
linkedUserId,
remote_data,
);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down
12 changes: 8 additions & 4 deletions packages/api/src/ticketing/contact/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export class SyncService implements OnModuleInit {

async onModuleInit() {
try {
//await this.syncContacts();
await this.syncContacts();
} catch (error) {
handleServiceError(error, this.logger);
}
}

//@Cron('*/20 * * * *')
@Cron('*/20 * * * *')
//function used by sync worker which populate our tcg_contacts table
//its role is to fetch all contacts from providers 3rd parties and save the info inside our db
async syncContacts() {
Expand Down Expand Up @@ -99,8 +99,12 @@ export class SyncService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');

if (!connection) {
this.logger.warn(
`Skipping contacts syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}
// get potential fieldMappings and extract the original properties name
const customFieldMappings =
await this.fieldMappingService.getCustomFieldMappings(
Expand Down
8 changes: 4 additions & 4 deletions packages/api/src/ticketing/contact/types/mappingsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const zendeskContactMapper = new ZendeskContactMapper();
const frontContactMapper = new FrontContactMapper();
const githubContactMapper = new GithubContactMapper();

export const accountUnificationMapping = {
export const contactUnificationMapping = {
zendesk_tcg: {
unify: zendeskContactMapper.unify,
unify: zendeskContactMapper.unify.bind(zendeskContactMapper),
desunify: zendeskContactMapper.desunify,
},
front: {
unify: frontContactMapper.unify,
unify: frontContactMapper.unify.bind(frontContactMapper),
desunify: frontContactMapper.desunify,
},
github: {
unify: githubContactMapper.unify,
unify: githubContactMapper.unify.bind(githubContactMapper),
desunify: githubContactMapper.desunify,
},
};
12 changes: 8 additions & 4 deletions packages/api/src/ticketing/tag/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export class SyncService implements OnModuleInit {

async onModuleInit() {
try {
//await this.syncTags();
await this.syncTags();
} catch (error) {
handleServiceError(error, this.logger);
}
}

//@Cron('*/20 * * * *')
@Cron('*/20 * * * *')
//function used by sync worker which populate our tcg_tags table
//its role is to fetch all tags from providers 3rd parties and save the info inside our db
async syncTags() {
Expand Down Expand Up @@ -110,8 +110,12 @@ export class SyncService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');

if (!connection) {
this.logger.warn(
`Skipping tags syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}
// get potential fieldMappings and extract the original properties name
const customFieldMappings =
await this.fieldMappingService.getCustomFieldMappings(
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/ticketing/tag/tag.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export class TagController {
connection_token,
);
return this.tagService.getTags(remoteSource, linkedUserId, remote_data);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/ticketing/tag/types/mappingsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const githubTagMapper = new GithubTagMapper();

export const tagUnificationMapping = {
zendesk_tcg: {
unify: zendeskTagMapper.unify,
unify: zendeskTagMapper.unify.bind(zendeskTagMapper),
desunify: zendeskTagMapper.desunify,
},
front: {
unify: frontTagMapper.unify,
unify: frontTagMapper.unify.bind(frontTagMapper),
desunify: frontTagMapper.desunify,
},
github: {
unify: githubTagMapper.unify,
unify: githubTagMapper.unify.bind(githubTagMapper),
desunify: githubTagMapper.desunify,
},
};
12 changes: 8 additions & 4 deletions packages/api/src/ticketing/team/sync/sync.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export class SyncService implements OnModuleInit {

async onModuleInit() {
try {
//await this.syncTeams();
await this.syncTeams();
} catch (error) {
handleServiceError(error, this.logger);
}
}

//@Cron('*/20 * * * *')
@Cron('*/20 * * * *')
//function used by sync worker which populate our tcg_teams table
//its role is to fetch all teams from providers 3rd parties and save the info inside our db
async syncTeams() {
Expand Down Expand Up @@ -99,8 +99,12 @@ export class SyncService implements OnModuleInit {
provider_slug: integrationId,
},
});
if (!connection) throw new Error('connection not found');

if (!connection) {
this.logger.warn(
`Skipping teams syncing... No ${integrationId} connection was found for linked user ${linkedUserId} `,
);
return;
}
// get potential fieldMappings and extract the original properties name
const customFieldMappings =
await this.fieldMappingService.getCustomFieldMappings(
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/ticketing/team/team.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export class TeamController {
connection_token,
);
return this.teamService.getTeams(remoteSource, linkedUserId, remote_data);
} catch (error) {}
} catch (error) {
throw new Error(error);
}
}

@ApiOperation({
Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/ticketing/team/types/mappingsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const githubTeamMapper = new GithubTeamMapper();

export const teamUnificationMapping = {
zendesk_tcg: {
unify: zendeskTeamMapper.unify,
unify: zendeskTeamMapper.unify.bind(zendeskTeamMapper),
desunify: zendeskTeamMapper.desunify,
},
front: {
unify: frontTeamMapper.unify,
unify: frontTeamMapper.unify.bind(frontTeamMapper),
desunify: frontTeamMapper.desunify,
},
github: {
unify: githubTeamMapper.unify,
unify: githubTeamMapper.unify.bind(githubTeamMapper),
desunify: githubTeamMapper.desunify,
},
};
Loading

0 comments on commit 56c9ae4

Please sign in to comment.