Skip to content

Commit

Permalink
fix(intercom): return conversations root content node (#6102)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Fontanier <[email protected]>
  • Loading branch information
fontanierh and Henry Fontanier authored Jul 8, 2024
1 parent b3147ef commit 152c5a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
29 changes: 22 additions & 7 deletions connectors/src/connectors/intercom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
getTeamInternalId,
getTeamsInternalId,
isInternalIdForAllConversations,
isInternalIdForAllTeams,
} from "@connectors/connectors/intercom/lib/utils";
import {
launchIntercomSyncWorkflow,
Expand Down Expand Up @@ -566,9 +565,22 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
const helpCenterIds: string[] = [];
const collectionIds: string[] = [];
const articleIds: string[] = [];
let isAllTeams = false;
let isAllConversations = false;
const teamIds: string[] = [];

const intercomWorkspace = await IntercomWorkspace.findOne({
where: {
connectorId: this.connectorId,
},
});
if (!intercomWorkspace) {
return new Err(
new Error(
`Intercom workspace not found for connector ${this.connectorId}`
)
);
}

internalIds.forEach((internalId) => {
let objectId = getHelpCenterIdFromInternalId(
this.connectorId,
Expand All @@ -595,10 +607,10 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
return;
}
if (
!isAllTeams &&
isInternalIdForAllTeams(this.connectorId, internalId)
!isAllConversations &&
isInternalIdForAllConversations(this.connectorId, internalId)
) {
isAllTeams = true;
isAllConversations = true;
}
objectId = getTeamIdFromInternalId(this.connectorId, internalId);
if (objectId) {
Expand Down Expand Up @@ -695,7 +707,7 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
lastUpdatedAt: article.lastUpsertedTs?.getTime() || null,
});
}
if (isAllTeams) {
if (isAllConversations) {
nodes.push({
provider: "intercom",
internalId: getTeamsInternalId(this.connectorId),
Expand All @@ -704,7 +716,10 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
title: "Conversations",
sourceUrl: null,
expandable: true,
permission: "none",
permission:
intercomWorkspace.syncAllConversations === "activated"
? "read"
: "none",
dustDocumentId: null,
lastUpdatedAt: null,
});
Expand Down
6 changes: 0 additions & 6 deletions connectors/src/connectors/intercom/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ export function isInternalIdForAllConversations(
): boolean {
return internalId === `intercom-conversations-all-${connectorId}`;
}
export function isInternalIdForAllTeams(
connectorId: ModelId,
internalId: string
): boolean {
return internalId === `intercom-teams-${connectorId}`;
}
export function getTeamIdFromInternalId(
connectorId: ModelId,
internalId: string
Expand Down

0 comments on commit 152c5a6

Please sign in to comment.