File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import { CacheItemStateType } from "./cache-item-state.model";
29
29
import { CalendarFilterOptions } from "./calendar-filter-options.model" ;
30
30
import { IntegrationErrorType } from "./integration-error.model" ;
31
31
import { PubSubClient } from "./pubsub-client.model" ;
32
+ import { PubSubContactsMessage } from "./pubsub-contacts-message.model" ;
32
33
33
34
const CONTACT_FETCH_TIMEOUT = 3000 ;
34
35
@@ -55,7 +56,7 @@ export class Controller {
55
56
56
57
const { PUBSUB_TOPIC_NAME : topicName } = process . env ;
57
58
58
- if ( isProduction ( ) ) {
59
+ if ( isProduction ( ) && typeof this . adapter . streamContacts === "function" ) {
59
60
if ( ! topicName ) {
60
61
throw new Error ( "No pubsub topic name provided." ) ;
61
62
}
@@ -202,7 +203,7 @@ export class Controller {
202
203
throw new Error ( "Invalid contacts received" ) ;
203
204
}
204
205
205
- const message = {
206
+ const message : PubSubContactsMessage = {
206
207
userId : providerConfig . userId ,
207
208
timestamp,
208
209
contacts : contacts . map ( ( contact ) =>
Original file line number Diff line number Diff line change 1
1
import { PubSub } from "@google-cloud/pubsub" ;
2
2
import { errorLogger , infoLogger } from "../util" ;
3
+ import { PubSubContactsMessage } from "./pubsub-contacts-message.model" ;
3
4
4
5
export class PubSubClient {
5
6
private client : PubSub ;
@@ -10,7 +11,7 @@ export class PubSubClient {
10
11
this . topicName = topicName ;
11
12
}
12
13
13
- async publishMessage ( message : unknown ) {
14
+ async publishMessage ( message : PubSubContactsMessage ) {
14
15
try {
15
16
if ( ! this . topicName ) {
16
17
throw new Error ( "No pubsub topic name provided." ) ;
@@ -23,7 +24,7 @@ export class PubSubClient {
23
24
24
25
infoLogger (
25
26
PubSubClient . name ,
26
- `Published message ${ json } to topic ${ this . topicName } `
27
+ `Published ${ message . contacts . length } contacts for user ${ message . userId } to topic ${ this . topicName } `
27
28
) ;
28
29
} catch ( error ) {
29
30
console . error ( error ) ;
Original file line number Diff line number Diff line change
1
+ import { Contact } from "./contact.model" ;
2
+
3
+ export type PubSubContactsMessage = {
4
+ userId : string ;
5
+ timestamp : number ;
6
+ contacts : Contact [ ] ;
7
+ } ;
You can’t perform that action at this time.
0 commit comments