Skip to content

Commit 77566c0

Browse files
committed
Revert ":recycle: Change contactsChangd to integrationEntitiesChanged"
This reverts commit fa2e432.
1 parent fa2e432 commit 77566c0

7 files changed

+23
-28
lines changed

src/models/adapter.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
LoggedIntegrationEntity,
1515
} from '.';
1616
import { IntegrationEntityType } from './integration-entity.model';
17-
import { IntegrationEntitiesChangedData } from './integration-entities-changed.model';
17+
import { ContactsChangedData } from './contacts-changed.model';
1818

1919
export interface Adapter {
2020
getToken?: (config: Config) => Promise<{ apiKey: string }>;
@@ -83,5 +83,5 @@ export interface Adapter {
8383
req: Request,
8484
res?: Response,
8585
) => Promise<{ apiKey: string; apiUrl: string }>;
86-
handleWebhook?: (body: unknown) => Promise<IntegrationEntitiesChangedData>;
86+
handleWebhook?: (body: unknown) => Promise<ContactsChangedData>;
8787
}

src/models/integration-entities-changed.model.ts renamed to src/models/contacts-changed.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { IntegrationEntityType } from './integration-entity.model';
22

3-
export type IntegrationEntitiesChangedData = {
3+
export type ContactsChangedData = {
44
integrationName: string;
55
data: {
66
integrationAccountId: string;

src/models/controller.model.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
ContactDelta,
1313
ContactTemplate,
1414
ContactUpdate,
15-
IntegrationEntitiesChangedData,
15+
ContactsChangedData,
1616
ServerError,
1717
} from '.';
1818
import { calendarEventsSchema, contactsSchema } from '../schemas';
@@ -35,7 +35,7 @@ import {
3535
PubSubContactsMessage,
3636
PubSubContactsState,
3737
} from './pubsub-contacts-message.model';
38-
import { PubSubIntegrationEntitiesChangedClient } from './pubsub-integration-entities-changed-client.model';
38+
import { PubSubContactsChangedClient } from './pubsub-contacts-changed-client.model';
3939

4040
const CONTACT_FETCH_TIMEOUT = 5000;
4141

@@ -54,7 +54,7 @@ export class Controller {
5454
private contactCache: ContactCache | null;
5555
private ajv: Ajv;
5656
private pubSubClient: PubSubClient | null = null;
57-
private pubSubIntegrationEntitiesChangedClient: PubSubIntegrationEntitiesChangedClient | null =
57+
private pubSubContactsChangedClient: PubSubContactsChangedClient | null =
5858
null;
5959
private integrationName: string = 'UNKNOWN';
6060
private streamingPromises = new Map<string, Promise<void>>();
@@ -67,19 +67,16 @@ export class Controller {
6767
if (this.adapter.streamContacts) {
6868
const {
6969
PUBSUB_TOPIC_NAME: topicName,
70-
PUBSUB_INTEGRATION_ENTITIES_CHANGED_TOPIC_NAME:
71-
integrationEntitiesChangedTopicName,
70+
PUBSUB_CONTACTS_CHANGED_TOPIC_NAME: contactsChangedTopicName,
7271
INTEGRATION_NAME: integrationName,
7372
} = process.env;
7473

7574
if (!topicName) {
7675
throw new Error('No PUBSUB_TOPIC_NAME provided.');
7776
}
7877

79-
if (!integrationEntitiesChangedTopicName) {
80-
throw new Error(
81-
'No PUBSUB_INTEGRATION_ENTITIES_CHANGED_TOPIC_NAME provided.',
82-
);
78+
if (!contactsChangedTopicName) {
79+
throw new Error('No PUBSUB_CONTACTS_CHANGED_TOPIC_NAME provided.');
8380
}
8481

8582
if (!integrationName) {
@@ -93,13 +90,12 @@ export class Controller {
9390
`Initialized PubSub client with topic ${topicName}`,
9491
);
9592

96-
this.pubSubIntegrationEntitiesChangedClient =
97-
new PubSubIntegrationEntitiesChangedClient(
98-
integrationEntitiesChangedTopicName,
99-
);
93+
this.pubSubContactsChangedClient = new PubSubContactsChangedClient(
94+
contactsChangedTopicName,
95+
);
10096
infoLogger(
10197
'Controller',
102-
`Initialized PubSub client with topic ${integrationEntitiesChangedTopicName}`,
98+
`Initialized PubSub client with topic ${contactsChangedTopicName}`,
10399
);
104100
}
105101
}
@@ -1313,11 +1309,11 @@ export class Controller {
13131309
throw new ServerError(501, 'Webhook handling not implemented');
13141310
}
13151311

1316-
const changedData: IntegrationEntitiesChangedData =
1312+
const contactsChangedData: ContactsChangedData =
13171313
await this.adapter.handleWebhook(req.body);
13181314

1319-
console.log('sending webhook to pubsub', changedData);
1320-
this.pubSubIntegrationEntitiesChangedClient?.publishMessage(changedData);
1315+
console.log('sending webhook to pubsub', contactsChangedData);
1316+
this.pubSubContactsChangedClient?.publishMessage(contactsChangedData);
13211317

13221318
res.sendStatus(200);
13231319
} catch (error) {

src/models/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export * from './call-event.model';
77
export * from './config.model';
88
export * from './contact-cache.model';
99
export * from './contact.model';
10-
export * from './integration-entities-changed.model';
10+
export * from './contacts-changed.model';
1111
export * from './controller.model';
1212
export * from './custom-router.model';
1313
export * from './server-error.model';

src/models/pubsub-integration-entities-changed-client.model.ts renamed to src/models/pubsub-contacts-changed-client.model.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { PubSub } from '@google-cloud/pubsub';
22
import { timeout } from '../util/timeout';
3-
import { PubSubIntegrationEntitiesChangedMessage } from './pubsub-integration-entities-changed-message.model';
3+
import { PubSubContactsChangedMessage } from './pubsub-contacts-changed-message.model';
44

55
const PUBLISH_TIMEOUT = 10_000;
66

7-
export class PubSubIntegrationEntitiesChangedClient {
7+
export class PubSubContactsChangedClient {
88
private client: PubSub;
99
private topicName: string;
1010

@@ -13,7 +13,7 @@ export class PubSubIntegrationEntitiesChangedClient {
1313
this.topicName = topicName;
1414
}
1515

16-
async publishMessage(message: PubSubIntegrationEntitiesChangedMessage) {
16+
async publishMessage(message: PubSubContactsChangedMessage) {
1717
if (!this.topicName) {
1818
throw new Error('No pubsub topic name provided.');
1919
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ContactsChangedData } from './contacts-changed.model';
2+
3+
export type PubSubContactsChangedMessage = ContactsChangedData;

src/models/pubsub-integration-entities-changed-message.model.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)