Skip to content

Commit e8420f5

Browse files
STRATCONN-6128 - fix unsubscribe list bug (#3177)
* use globalUnsubscribe * fix for bug --------- Co-authored-by: Joe Ayoub <[email protected]>
1 parent 2e932d6 commit e8420f5

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

packages/destination-actions/src/destinations/iterable-lists/syncAudience/iterable-client.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RequestClient, PayloadValidationError } from '@segment/actions-core'
22

33
import { Settings, AudienceSettings } from '../generated-types'
4-
import { Unsubscriber, Subscriber } from '../types'
4+
import { Unsubscriber, Subscriber, IterableSubscribePayload, IterableUnsubscribePayload } from '../types'
55
import { Payload } from './generated-types'
66

77
import { CONSTANTS } from '../constants'
@@ -65,30 +65,32 @@ export class IterableListsClient {
6565
const unSubcribeRequests = []
6666

6767
subscribersGroup.forEach((subscribers, listId) => {
68+
const json: IterableSubscribePayload = {
69+
listId: Number(listId),
70+
subscribers,
71+
updateExistingUsersOnly: this.updateExistingUsersOnly
72+
}
6873
subcribeRequests.push(
6974
this.request(`${CONSTANTS.API_BASE_URL}/lists/subscribe`, {
7075
method: 'post',
7176
skipResponseCloning: true,
72-
json: {
73-
listId: Number(listId),
74-
subscribers,
75-
updateExistingUsersOnly: this.updateExistingUsersOnly
76-
}
77+
json
7778
})
7879
)
7980
})
8081

8182
unsubscribersGroup.forEach((subscribers, listId) => {
83+
const json: IterableUnsubscribePayload = {
84+
listId: Number(listId),
85+
subscribers,
86+
campaignId: typeof this.campaignId === 'number' ? this.campaignId : undefined,
87+
channelUnsubscribe: this.globalUnsubscribe
88+
}
8289
unSubcribeRequests.push(
8390
this.request(`${CONSTANTS.API_BASE_URL}/lists/unsubscribe`, {
8491
method: 'post',
8592
skipResponseCloning: true,
86-
json: {
87-
listId: Number(listId),
88-
subscribers,
89-
campaignId: typeof this.campaignId === 'number' ? this.campaignId : undefined,
90-
channelUnsubscribe: this.updateExistingUsersOnly
91-
}
93+
json
9294
})
9395
)
9496
})

packages/destination-actions/src/destinations/iterable-lists/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export interface Subscriber {
1414
export interface IterableUnsubscribePayload {
1515
listId: number
1616
subscribers: Array<Unsubscriber>
17-
campaignId?: string
17+
campaignId?: number
1818
channelUnsubscribe?: boolean
1919
}
2020

0 commit comments

Comments
 (0)