@capillarytech/creatives-library 7.13.5 → 7.13.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/routes.js +1 -0
- package/services/api.js +6 -1
- package/utils/cdnTransformation.js +369 -0
- package/utils/tests/__snapshots__/cdnTransformation.test.js.snap +298 -0
- package/utils/tests/cdnTransformation.mockdata.js +301 -0
- package/utils/tests/cdnTransformation.test.js +245 -0
- package/v2Containers/Cap/actions.js +0 -1
- package/v2Containers/CreativesContainer/actions.js +1 -1
- package/v2Containers/CreativesContainer/index.js +6 -1
- package/v2Containers/CreativesContainer/tests/index.test.js +4 -0
- package/v2Containers/Email/index.js +4 -1
- package/v2Containers/Facebook/Advertisement/index.js +4 -4
- package/v2Containers/Line/Container/Image/index.js +5 -4
- package/v2Containers/Line/Container/ImageCarousel/index.js +6 -5
- package/v2Containers/Line/Container/ImageMap/index.js +2 -1
- package/v2Containers/MobilePush/Create/index.js +5 -7
- package/v2Containers/MobilePush/Edit/index.js +4 -3
- package/v2Containers/Rcs/index.js +2 -1
- package/v2Containers/Templates/actions.js +6 -0
- package/v2Containers/Templates/constants.js +4 -0
- package/v2Containers/Templates/sagas.js +23 -0
- package/v2Containers/TemplatesV2/index.js +5 -0
- package/v2Containers/Viber/index.js +11 -2
- package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +3 -1
- package/v2Containers/Whatsapp/index.js +4 -2
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import * as cdnUtils from "../cdnTransformation";
|
|
2
|
+
import * as mockdata from "./cdnTransformation.mockdata";
|
|
3
|
+
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
var localStorageMock = (function () {
|
|
6
|
+
var store = {
|
|
7
|
+
CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
|
|
8
|
+
CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
|
|
9
|
+
CREATIVES_CDN_QUALITY_CONFIG:
|
|
10
|
+
'{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
getItem: function (key) {
|
|
14
|
+
return store[key];
|
|
15
|
+
},
|
|
16
|
+
setItem: function (key, value) {
|
|
17
|
+
store[key] = value.toString();
|
|
18
|
+
},
|
|
19
|
+
clear: function () {
|
|
20
|
+
store = {};
|
|
21
|
+
},
|
|
22
|
+
removeItem: function (key) {
|
|
23
|
+
delete store[key];
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
Object.defineProperty(window, "localStorage", { value: localStorageMock });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
localStorage.setItem(
|
|
32
|
+
"CREATIVES_CDN_QUALITY_CONFIG",
|
|
33
|
+
'{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}'
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe("cdnTransformationTests", () => {
|
|
38
|
+
describe("getCdnUrl()", () => {
|
|
39
|
+
it("should return s3 url if bucket subfolder doesn't contain intouch_creative_assets", () => {
|
|
40
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/test/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
41
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
42
|
+
url: TEST_S3_URL,
|
|
43
|
+
channelName: "EMAIL",
|
|
44
|
+
});
|
|
45
|
+
expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should return s3 if channelName is not defined", () => {
|
|
49
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
50
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({ url: TEST_S3_URL });
|
|
51
|
+
expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("should return s3 if specified channelSubType doesn't exist", () => {
|
|
55
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
56
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
57
|
+
url: TEST_S3_URL,
|
|
58
|
+
channelName: "LINE",
|
|
59
|
+
channelSubType: "ABC",
|
|
60
|
+
});
|
|
61
|
+
expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("Should replace s3 url with cdn url for email when h/w are not provided", () => {
|
|
65
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
66
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
67
|
+
url: TEST_S3_URL,
|
|
68
|
+
channelName: "EMAIL",
|
|
69
|
+
});
|
|
70
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
71
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("Should replace s3 url with cdn url for email when h/w are provided", () => {
|
|
75
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
76
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
77
|
+
url: TEST_S3_URL,
|
|
78
|
+
channelName: "EMAIL",
|
|
79
|
+
height: 100,
|
|
80
|
+
width: 200,
|
|
81
|
+
});
|
|
82
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
83
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("should replace cdn url with new cdn url for email incase h/w etc changed", () => {
|
|
87
|
+
const TEST_S3_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
88
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
89
|
+
url: TEST_S3_URL,
|
|
90
|
+
channelName: "EMAIL",
|
|
91
|
+
height: 400,
|
|
92
|
+
width: 500,
|
|
93
|
+
});
|
|
94
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=500,height=400,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
95
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("should replace cdn url with new cdn url incase channelName is LINE and channelSubType is RICH_MESSAGE ", () => {
|
|
99
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8`;
|
|
100
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
101
|
+
url: TEST_S3_URL,
|
|
102
|
+
channelName: "LINE",
|
|
103
|
+
channelSubType: "RICH_MESSAGE",
|
|
104
|
+
});
|
|
105
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=1040,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8`;
|
|
106
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should replace cdn url with new cdn url for channels which has predefined h/w for channel", () => {
|
|
110
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
111
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
112
|
+
url: TEST_S3_URL,
|
|
113
|
+
channelName: "RCS",
|
|
114
|
+
});
|
|
115
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=1440,height=720,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
116
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("should return url directly if typeof CREATIVES_CDN_QUALITY_CONFIG is not object", () => {
|
|
120
|
+
localStorage.setItem("CREATIVES_CDN_QUALITY_CONFIG", "a");
|
|
121
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
122
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
123
|
+
url: TEST_S3_URL,
|
|
124
|
+
channelName: "EMAIL",
|
|
125
|
+
});
|
|
126
|
+
expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("should return cdn url with full quality if quality is not number", () => {
|
|
130
|
+
localStorage.setItem(
|
|
131
|
+
"CREATIVES_CDN_QUALITY_CONFIG",
|
|
132
|
+
'{"EMAIL":"a","RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}'
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
136
|
+
const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
|
|
137
|
+
url: TEST_S3_URL,
|
|
138
|
+
channelName: "EMAIL",
|
|
139
|
+
height: 100,
|
|
140
|
+
width: 200,
|
|
141
|
+
});
|
|
142
|
+
const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=100,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
|
|
143
|
+
|
|
144
|
+
expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe("updateImagesInHtml()", () => {
|
|
149
|
+
it("should update images in html", () => {
|
|
150
|
+
const htmlContentsInput = mockdata.emailRawInput;
|
|
151
|
+
const htmlContentsOutput = cdnUtils.updateImagesInHtml(htmlContentsInput);
|
|
152
|
+
const expected = mockdata.emailRawTransformed;
|
|
153
|
+
expect(htmlContentsOutput).toEqual(expected);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe("transformEmailTemplate()", () => {
|
|
158
|
+
it("should transform email template", () => {
|
|
159
|
+
const emailTemplateInput = mockdata.emailTemplateRaw;
|
|
160
|
+
const emailTemplateOutput =
|
|
161
|
+
cdnUtils.transformEmailTemplates(emailTemplateInput);
|
|
162
|
+
expect(emailTemplateOutput).toMatchSnapshot();
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe("saveCdnConfigs()", () => {
|
|
167
|
+
it("should set received input values in localStorage", () => {
|
|
168
|
+
const cdnConfigs = {
|
|
169
|
+
transformationUrlSuffix: "cdn-cgi/image",
|
|
170
|
+
hostname: "https://storage.crm.n.content-cdn.io",
|
|
171
|
+
qualityCfg: {
|
|
172
|
+
EMAIL: 75,
|
|
173
|
+
RCS: 75,
|
|
174
|
+
VIBER: 75,
|
|
175
|
+
WHATSAPP: 75,
|
|
176
|
+
MOBILE_PUSH: 75,
|
|
177
|
+
FACEBOOK: 75,
|
|
178
|
+
LINE: 75,
|
|
179
|
+
DEFAULT: 75,
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const expected = {
|
|
184
|
+
CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
|
|
185
|
+
CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
|
|
186
|
+
CREATIVES_CDN_QUALITY_CONFIG:
|
|
187
|
+
'{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
|
|
188
|
+
};
|
|
189
|
+
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
190
|
+
|
|
191
|
+
expect(
|
|
192
|
+
localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
|
|
193
|
+
).toBe(expected.CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX);
|
|
194
|
+
expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(
|
|
195
|
+
expected.CREATIVES_CDN_BASE_URL
|
|
196
|
+
);
|
|
197
|
+
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
|
|
198
|
+
expected.CREATIVES_CDN_QUALITY_CONFIG
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should clear items from localStorage if input does not contain hostname or transformationUrlSuffix", () => {
|
|
203
|
+
const cdnConfigs = {
|
|
204
|
+
qualityCfg: {
|
|
205
|
+
EMAIL: 75,
|
|
206
|
+
RCS: 75,
|
|
207
|
+
VIBER: 75,
|
|
208
|
+
WHATSAPP: 75,
|
|
209
|
+
MOBILE_PUSH: 75,
|
|
210
|
+
FACEBOOK: 75,
|
|
211
|
+
LINE: 75,
|
|
212
|
+
DEFAULT: 75,
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const expected = {
|
|
217
|
+
CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
|
|
218
|
+
CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
|
|
219
|
+
CREATIVES_CDN_QUALITY_CONFIG:
|
|
220
|
+
'{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
|
|
221
|
+
};
|
|
222
|
+
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
223
|
+
|
|
224
|
+
expect(
|
|
225
|
+
localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
|
|
226
|
+
).toBe(undefined);
|
|
227
|
+
expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(undefined);
|
|
228
|
+
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
|
|
229
|
+
expected.CREATIVES_CDN_QUALITY_CONFIG
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("should clear items from localStorage if input is null or empty object", () => {
|
|
234
|
+
const cdnConfigs = {};
|
|
235
|
+
|
|
236
|
+
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
237
|
+
|
|
238
|
+
expect(
|
|
239
|
+
localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
|
|
240
|
+
).toBe(undefined);
|
|
241
|
+
expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(undefined);
|
|
242
|
+
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(undefined);
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
});
|
|
@@ -33,6 +33,7 @@ import { CREATIVE } from '../Facebook/constants';
|
|
|
33
33
|
import { LOYALTY } from '../App/constants';
|
|
34
34
|
import { WHATSAPP_STATUSES } from '../Whatsapp/constants';
|
|
35
35
|
|
|
36
|
+
import { updateImagesInHtml } from '../../utils/cdnTransformation';
|
|
36
37
|
|
|
37
38
|
const classPrefix = 'add-creatives-section';
|
|
38
39
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -76,6 +77,9 @@ export class Creatives extends React.Component {
|
|
|
76
77
|
|
|
77
78
|
componentDidMount() {
|
|
78
79
|
GA.timeTracker.startTimer(CREATIVES_CONTAINER);
|
|
80
|
+
if(!this.props?.isFullMode){
|
|
81
|
+
this.props?.templateActions.getCdnTransformationConfig();
|
|
82
|
+
}
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
onEnterTemplateName = () => {
|
|
@@ -495,7 +499,8 @@ export class Creatives extends React.Component {
|
|
|
495
499
|
if (!html_content) {
|
|
496
500
|
emailBase = templateRecords.base;
|
|
497
501
|
}
|
|
498
|
-
|
|
502
|
+
const newHtmlContent = updateImagesInHtml(html_content);
|
|
503
|
+
templateData = {...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
|
|
499
504
|
delete templateData.html_content;
|
|
500
505
|
delete templateData.subject;
|
|
501
506
|
}
|
|
@@ -26,6 +26,7 @@ jest.mock('../../../v2Components/FormBuilder', () => ({
|
|
|
26
26
|
describe('Test SlideBoxContent container', () => {
|
|
27
27
|
const handleCloseCreatives = jest.fn();
|
|
28
28
|
const getCreativesData = jest.fn();
|
|
29
|
+
const getCdnTransformationConfig = jest.fn();
|
|
29
30
|
let renderedComponent;
|
|
30
31
|
|
|
31
32
|
beforeEach(() => {
|
|
@@ -41,6 +42,9 @@ describe('Test SlideBoxContent container', () => {
|
|
|
41
42
|
templateData={templateData}
|
|
42
43
|
handleCloseCreatives={handleCloseCreatives}
|
|
43
44
|
getCreativesData={getCreativesData}
|
|
45
|
+
templateActions={{
|
|
46
|
+
getCdnTransformationConfig
|
|
47
|
+
}}
|
|
44
48
|
/>,
|
|
45
49
|
);
|
|
46
50
|
};
|
|
@@ -35,6 +35,8 @@ import { TRACK_CREATE_EMAIL, TRACK_EDIT_EMAIL, BEE_PLUGIN, CREATE, EDIT } from '
|
|
|
35
35
|
import { FONT_COLOR_05 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
36
36
|
import { gtmPush } from '../../utils/gtmTrackers';
|
|
37
37
|
const {CapCustomCardList} = CapCustomCard;
|
|
38
|
+
import {transformEmailTemplates} from '../../utils/cdnTransformation';
|
|
39
|
+
|
|
38
40
|
export class Email extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
39
41
|
constructor(props) {
|
|
40
42
|
super(props);
|
|
@@ -2438,7 +2440,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2438
2440
|
|
|
2439
2441
|
// if (saveCount === 0) {
|
|
2440
2442
|
|
|
2441
|
-
|
|
2443
|
+
const newEmail = transformEmailTemplates(obj);
|
|
2444
|
+
this.props.actions.createTemplate(newEmail, this.onUpdateTemplateComplete);
|
|
2442
2445
|
// } else {
|
|
2443
2446
|
// this.setState({saveObj: obj, targetSaveCount: saveCount, mode: "save", saveEdmDataMode: 'save'}, () => {
|
|
2444
2447
|
// _.forEach(data.selectedLanguages, (language, langIndex) => {
|
|
@@ -7,7 +7,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
7
7
|
import { connect } from "react-redux";
|
|
8
8
|
import { createStructuredSelector } from "reselect";
|
|
9
9
|
import { selectCurrentOrgDetails } from "../../Cap/selectors";
|
|
10
|
-
|
|
10
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation';
|
|
11
11
|
import {
|
|
12
12
|
CapInput,
|
|
13
13
|
CapRadioCard,
|
|
@@ -197,7 +197,7 @@ export const Advertisement = (props) => {
|
|
|
197
197
|
};
|
|
198
198
|
if (obj.subType === IMAGE) {
|
|
199
199
|
data.imageData = {
|
|
200
|
-
imageSrc: obj.imgSrc,
|
|
200
|
+
imageSrc: getCdnUrl({url: obj.imgSrc, channelName: 'FACEBOOK', channelSubType: 'IMAGE'}),
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
if (obj.subType === VIDEO) {
|
|
@@ -336,7 +336,7 @@ export const Advertisement = (props) => {
|
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
if (obj.subType === IMAGE) {
|
|
339
|
-
data.imgSrc = obj.imageData.imageSrc;
|
|
339
|
+
data.imgSrc = getCdnUrl({url: obj.imageData.imageSrc, channelName: 'FACEBOOK', channelSubType: 'IMAGE'});
|
|
340
340
|
} else {
|
|
341
341
|
const {
|
|
342
342
|
videoSrc,
|
|
@@ -1033,4 +1033,4 @@ const mapStateToProps = (state, props) =>
|
|
|
1033
1033
|
: selectCurrentOrgDetails(),
|
|
1034
1034
|
});
|
|
1035
1035
|
|
|
1036
|
-
export default connect(mapStateToProps, null)(injectIntl(Advertisement));
|
|
1036
|
+
export default connect(mapStateToProps, null)(injectIntl(Advertisement));
|
|
@@ -15,6 +15,7 @@ import Gallery from '../../../Assets/Gallery';
|
|
|
15
15
|
import style from './style';
|
|
16
16
|
import { CAP_G06, CAP_G09 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
17
|
import withStyles from '../../../../hoc/withStyles';
|
|
18
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
18
19
|
|
|
19
20
|
import messages from './messages';
|
|
20
21
|
import {
|
|
@@ -73,7 +74,7 @@ export const LineImage = ({
|
|
|
73
74
|
if (imageSrc && (isFullMode ? messageTitle: true) && imagePreview) {
|
|
74
75
|
updateMessageState({
|
|
75
76
|
isError: !imageSrc || !(isFullMode ? messageTitle : true) || isImageError || errorMessageTitle,
|
|
76
|
-
originalContentUrl: imageSrc,
|
|
77
|
+
originalContentUrl: getCdnUrl({url: imageSrc, channelName: 'LINE', channelSubType: 'IMAGE'}),
|
|
77
78
|
previewImageUrl: imagePreview,
|
|
78
79
|
messageTitle,
|
|
79
80
|
index,
|
|
@@ -112,7 +113,7 @@ export const LineImage = ({
|
|
|
112
113
|
|
|
113
114
|
updateMessageState({
|
|
114
115
|
isError: !imgSrc || !(isFullMode ? messageTitle : true) || errorMessageTitle,
|
|
115
|
-
originalContentUrl: imgSrc,
|
|
116
|
+
originalContentUrl: getCdnUrl({url: imgSrc, channelName: 'LINE', channelSubType: 'IMAGE'}),
|
|
116
117
|
previewImageUrl: imgPreview,
|
|
117
118
|
messageTitle,
|
|
118
119
|
index,
|
|
@@ -155,7 +156,7 @@ export const LineImage = ({
|
|
|
155
156
|
}
|
|
156
157
|
updateMessageState({
|
|
157
158
|
isError: !imageSrc || !(isFullMode ? value : true) || isImageError || !value,
|
|
158
|
-
originalContentUrl: imageSrc,
|
|
159
|
+
originalContentUrl: getCdnUrl({url: imageSrc, channelName: 'LINE', channelSubType: 'IMAGE'}),
|
|
159
160
|
previewImageUrl: imagePreview,
|
|
160
161
|
messageTitle: value,
|
|
161
162
|
index,
|
|
@@ -412,7 +413,7 @@ export const LineImage = ({
|
|
|
412
413
|
updateImagePreview(imagePreview);
|
|
413
414
|
updateMessageState({
|
|
414
415
|
isError: !image || !(isFullMode ? messageTitle : true) || isImageError || errorMessageTitle,
|
|
415
|
-
originalContentUrl: image,
|
|
416
|
+
originalContentUrl: getCdnUrl({url: image, channelName: 'LINE', channelSubType: 'IMAGE'}),
|
|
416
417
|
previewImageUrl: imagePreview,
|
|
417
418
|
messageTitle,
|
|
418
419
|
index,
|
|
@@ -15,6 +15,7 @@ import LineDrawer from '../Drawer';
|
|
|
15
15
|
import style from './style';
|
|
16
16
|
import { CAP_G06, FONT_COLOR_01, FONT_COLOR_02, CAP_SPACE_08, CAP_WHITE, CAP_SPACE_24, CAP_SPACE_04 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
17
17
|
import withStyles from '../../../../hoc/withStyles';
|
|
18
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
18
19
|
|
|
19
20
|
import LineImageCarouselContent from './Content';
|
|
20
21
|
|
|
@@ -103,7 +104,7 @@ export const LineImageCarousel = (props) => {
|
|
|
103
104
|
} = content || {};
|
|
104
105
|
validCarouselImages.push({
|
|
105
106
|
activeIndex: index,
|
|
106
|
-
originalContentUrl: url,
|
|
107
|
+
originalContentUrl: getCdnUrl({url: url, channelName: 'LINE', channelSubType: 'CARD'}),
|
|
107
108
|
aspectRatio,
|
|
108
109
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
109
110
|
actionContent: text || uri,
|
|
@@ -127,7 +128,7 @@ export const LineImageCarousel = (props) => {
|
|
|
127
128
|
|
|
128
129
|
validCarouselImages.push({
|
|
129
130
|
activeIndex: index,
|
|
130
|
-
originalContentUrl: imageUrl,
|
|
131
|
+
originalContentUrl: getCdnUrl({url: imageUrl, channelName: 'LINE', channelSubType: 'CARD'}),
|
|
131
132
|
selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
132
133
|
actionContent: text || uri,
|
|
133
134
|
actionLabel: label,
|
|
@@ -160,7 +161,7 @@ export const LineImageCarousel = (props) => {
|
|
|
160
161
|
? isErrorIndex
|
|
161
162
|
: ((!originalContentUrl || !selectedActionType || actionContentErrorMessage || actionLabelErrorMessage || !actionContent) && activeIndex);
|
|
162
163
|
columns.push({
|
|
163
|
-
imageUrl: originalContentUrl,
|
|
164
|
+
imageUrl: getCdnUrl({url: originalContentUrl, channelName: 'LINE', channelSubType: 'CARD'}),
|
|
164
165
|
aspectRatio,
|
|
165
166
|
action: {
|
|
166
167
|
type: selectedActionType ? (selectedActionType === TEXT_ACTION_TYPE ? MESSAGE_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
@@ -455,7 +456,7 @@ export const LineImageCarousel = (props) => {
|
|
|
455
456
|
} = content || {};
|
|
456
457
|
validCarouselImages.push({
|
|
457
458
|
activeIndex: index,
|
|
458
|
-
originalContentUrl: url,
|
|
459
|
+
originalContentUrl: getCdnUrl({url: url, channelName: 'LINE', channelSubType: 'CARD'}),
|
|
459
460
|
aspectRatio,
|
|
460
461
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
461
462
|
actionContent: text || uri,
|
|
@@ -480,7 +481,7 @@ export const LineImageCarousel = (props) => {
|
|
|
480
481
|
|
|
481
482
|
validCarouselImages.push({
|
|
482
483
|
activeIndex: index,
|
|
483
|
-
originalContentUrl: imageUrl,
|
|
484
|
+
originalContentUrl: getCdnUrl({url: imageUrl, channelName: 'LINE', channelSubType: 'CARD'}),
|
|
484
485
|
selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
485
486
|
actionContent: text || uri,
|
|
486
487
|
actionLabel: label,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from '../constants';
|
|
40
40
|
|
|
41
41
|
const { CapIconAvatar } = CapIcon;
|
|
42
|
+
import { getCdnUrl } from '../../../../utils/cdnTransformation';
|
|
42
43
|
|
|
43
44
|
export const LineImageMap = ({
|
|
44
45
|
className,
|
|
@@ -114,7 +115,7 @@ export const LineImageMap = ({
|
|
|
114
115
|
if (imageSrc && (isFullMode ? messageTitle: true) && imageMapTemplate && actionLinks) {
|
|
115
116
|
updateMessageState({
|
|
116
117
|
isError: !imageSrc || !(isFullMode ? messageTitle : true) || !imageMapTemplate || (isImageError && errorMessageTitle) || errorTitle || !altText,
|
|
117
|
-
baseUrl: imageSrc,
|
|
118
|
+
baseUrl: getCdnUrl({url: imageSrc, channelName: 'LINE', channelSubType: 'RICH_MESSAGE'}),
|
|
118
119
|
messageTitle,
|
|
119
120
|
index,
|
|
120
121
|
type: IMAGE_MAP,
|
|
@@ -31,6 +31,7 @@ import { GA } from '@capillarytech/cap-ui-utils';
|
|
|
31
31
|
import { CREATE, TRACK_CREATE_MPUSH } from '../../App/constants';
|
|
32
32
|
import { MOBILE_PUSH } from '../../CreativesContainer/constants';
|
|
33
33
|
import { getContent } from '../commonMethods';
|
|
34
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation'
|
|
34
35
|
|
|
35
36
|
const PrefixWrapper = styled.div`
|
|
36
37
|
margin-right: 16px;
|
|
@@ -464,7 +465,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
464
465
|
const secondaryCta2 = !!android['cta-deeplink-secondary-cta-1-select'] || !!android['secondary-cta-1-label'];
|
|
465
466
|
const imageLink = android.image;
|
|
466
467
|
if (imageLink) {
|
|
467
|
-
obj.versions.base.ANDROID.expandableDetails.image = imageLink;
|
|
468
|
+
obj.versions.base.ANDROID.expandableDetails.image = getCdnUrl({url: imageLink, channelName: 'MOBILE_PUSH'});
|
|
468
469
|
obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
|
|
469
470
|
}
|
|
470
471
|
if (secondaryCta1 || secondaryCta2 ) {
|
|
@@ -538,7 +539,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
538
539
|
const imageLinkIos = ios.image;
|
|
539
540
|
const secondaryCtaIos = !!ios['cta-deeplink-secondary-cta-1-select'] || !!ios['secondary-cta-1-label'];
|
|
540
541
|
if (imageLinkIos) {
|
|
541
|
-
obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
|
|
542
|
+
obj.versions.base.IOS.expandableDetails.image = getCdnUrl({url: imageLinkIos, channelName: 'MOBILE_PUSH'});
|
|
542
543
|
obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
|
|
543
544
|
}
|
|
544
545
|
if (secondaryCtaIos) {
|
|
@@ -1320,10 +1321,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1320
1321
|
duration: 2,
|
|
1321
1322
|
});
|
|
1322
1323
|
} else {
|
|
1323
|
-
|
|
1324
|
-
const blob = data.file.slice(0, -1, 'image');
|
|
1325
|
-
const newFile = new File([blob], `${name[0]}${Date.now()}.${name[1]}`, {type: 'image'});
|
|
1326
|
-
this.props.actions.uploadAsset(newFile, data.type, data.fileParams);
|
|
1324
|
+
this.props.actions.uploadAsset(data.file, data.type, data.fileParams);
|
|
1327
1325
|
}
|
|
1328
1326
|
};
|
|
1329
1327
|
selectCtaIos = (selectedConfig) => {
|
|
@@ -1853,4 +1851,4 @@ export default withCreatives({
|
|
|
1853
1851
|
mapStateToProps,
|
|
1854
1852
|
mapDispatchToProps,
|
|
1855
1853
|
userAuth: false,
|
|
1856
|
-
});
|
|
1854
|
+
});
|
|
@@ -33,6 +33,7 @@ import {getPrimaryCtaFields, getSecondaryCtaFields, getLinkTypeFields, getConten
|
|
|
33
33
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
34
34
|
import { EDIT, TRACK_EDIT_MPUSH } from '../../App/constants';
|
|
35
35
|
import { MOBILE_PUSH } from '../../CreativesContainer/constants';
|
|
36
|
+
import { getCdnUrl } from '../../../utils/cdnTransformation';
|
|
36
37
|
|
|
37
38
|
const PrefixWrapper = styled.div`
|
|
38
39
|
margin-right: 16px;
|
|
@@ -421,7 +422,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
421
422
|
}
|
|
422
423
|
const imageLink = android.image;
|
|
423
424
|
if (imageLink) {
|
|
424
|
-
obj.versions.base.ANDROID.expandableDetails.image = imageLink;
|
|
425
|
+
obj.versions.base.ANDROID.expandableDetails.image = getCdnUrl({url: imageLink, channelName: 'MOBILE_PUSH'});
|
|
425
426
|
obj.versions.base.ANDROID.expandableDetails.style = "BIG_PICTURE";
|
|
426
427
|
}
|
|
427
428
|
if (obj.versions.base.ANDROID && obj.versions.base.ANDROID.cta) {
|
|
@@ -492,7 +493,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
492
493
|
}
|
|
493
494
|
const imageLinkIos = ios.image;
|
|
494
495
|
if (imageLinkIos) {
|
|
495
|
-
obj.versions.base.IOS.expandableDetails.image = imageLinkIos;
|
|
496
|
+
obj.versions.base.IOS.expandableDetails.image = getCdnUrl({url: imageLinkIos, channelName: 'MOBILE_PUSH'});
|
|
496
497
|
obj.versions.base.IOS.expandableDetails.style = "BIG_PICTURE";
|
|
497
498
|
}
|
|
498
499
|
if (obj.versions.base.IOS && obj.versions.base.IOS.cta) {
|
|
@@ -1941,4 +1942,4 @@ export default withCreatives({
|
|
|
1941
1942
|
mapStateToProps,
|
|
1942
1943
|
mapDispatchToProps,
|
|
1943
1944
|
userAuth: false,
|
|
1944
|
-
});
|
|
1945
|
+
});
|
|
@@ -81,6 +81,7 @@ import Templates from '../Templates';
|
|
|
81
81
|
import SmsTraiEdit from '../SmsTrai/Edit';
|
|
82
82
|
import TagList from '../TagList';
|
|
83
83
|
import { validateTags } from '../../utils/tagValidations';
|
|
84
|
+
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
84
85
|
const { Group: CapCheckboxGroup } = CapCheckbox;
|
|
85
86
|
export const Rcs = (props) => {
|
|
86
87
|
const {
|
|
@@ -900,7 +901,7 @@ export const Rcs = (props) => {
|
|
|
900
901
|
...(suggestions.length > 0 && { suggestions }),
|
|
901
902
|
...(!isMediaTypeNone && {
|
|
902
903
|
media: {
|
|
903
|
-
mediaUrl: rcsImageSrc,
|
|
904
|
+
mediaUrl: getCdnUrl({url: rcsImageSrc, channelName: 'RCS'}),
|
|
904
905
|
height: MEDIUM,
|
|
905
906
|
},
|
|
906
907
|
}),
|
|
@@ -68,3 +68,7 @@ export const GET_SENDER_DETAILS_SUCCESS =
|
|
|
68
68
|
'app/v2Containers/Templates/GET_SENDER_DETAILS_SUCCESS';
|
|
69
69
|
export const GET_SENDER_DETAILS_FAILURE =
|
|
70
70
|
'app/v2Containers/Templates/GET_SENDER_DETAILS_FAILURE';
|
|
71
|
+
|
|
72
|
+
export const GET_CDN_TRANSFORMATION_CONFIG_REQUEST = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_REQUEST';
|
|
73
|
+
export const GET_CDN_TRANSFORMATION_CONFIG_SUCCESS = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_SUCCESS';
|
|
74
|
+
export const GET_CDN_TRANSFORMATION_CONFIG_FAILURE = 'app/v2Containers/Templates/GET_CDN_TRANSFORMATION_CONFIG_FAILURE';
|
|
@@ -3,6 +3,7 @@ import { LOCATION_CHANGE } from 'react-router-redux';
|
|
|
3
3
|
// import { schema, normalize } from 'normalizr';
|
|
4
4
|
import * as Api from '../../services/api';
|
|
5
5
|
import * as types from './constants';
|
|
6
|
+
import { saveCdnConfigs, removeAllCdnLocalStorageItems } from '../../utils/cdnTransformation';
|
|
6
7
|
|
|
7
8
|
// Individual exports for testing
|
|
8
9
|
export function* getAllTemplates(channel, queryParams) {
|
|
@@ -85,6 +86,20 @@ export function* getOrgLevelCampaignSettings() {
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
function* getCdnTransformationConfig() {
|
|
90
|
+
try {
|
|
91
|
+
const res = yield call(Api.getCdnTransformationConfig);
|
|
92
|
+
|
|
93
|
+
if (res?.success && res?.status?.code === 200) {
|
|
94
|
+
const cdnConfigs = res?.response;
|
|
95
|
+
saveCdnConfigs(cdnConfigs);
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.log("some error occured during getCdnTransformationConfig call");
|
|
99
|
+
removeAllCdnLocalStorageItems();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
88
103
|
export function* watchGetOrgLevelCampaignSettings() {
|
|
89
104
|
const watcher = yield takeLatest(
|
|
90
105
|
types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST,
|
|
@@ -222,6 +237,13 @@ function* watchGetSenderDetails() {
|
|
|
222
237
|
yield cancel(watcher);
|
|
223
238
|
}
|
|
224
239
|
|
|
240
|
+
function* watchGetCdnTransformationConfig() {
|
|
241
|
+
yield takeLatest(
|
|
242
|
+
types.GET_CDN_TRANSFORMATION_CONFIG_REQUEST,
|
|
243
|
+
getCdnTransformationConfig
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
225
247
|
// All sagas to be loaded
|
|
226
248
|
export default [
|
|
227
249
|
watchGetAllTemplates,
|
|
@@ -233,4 +255,5 @@ export default [
|
|
|
233
255
|
watchGetTemplateDetails,
|
|
234
256
|
watchGetOrgLevelCampaignSettings,
|
|
235
257
|
watchGetSenderDetails,
|
|
258
|
+
watchGetCdnTransformationConfig
|
|
236
259
|
];
|
|
@@ -19,6 +19,7 @@ import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
|
19
19
|
import { makeSelectTemplates, makeSelectTemplatesResponse } from '../Templates/selectors';
|
|
20
20
|
import messages from './messages';
|
|
21
21
|
import * as actions from './actions';
|
|
22
|
+
import * as templateActions from '../Templates/actions';
|
|
22
23
|
import Templates from '../Templates';
|
|
23
24
|
import CallTask from '../CallTask';
|
|
24
25
|
import Facebook from '../Facebook';
|
|
@@ -139,6 +140,9 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
139
140
|
if (queryItems.channel === WHATSAPP) {
|
|
140
141
|
this.channelChange(WHATSAPP);
|
|
141
142
|
}
|
|
143
|
+
if(this.props?.isFullMode){
|
|
144
|
+
this.props.templateActions.getCdnTransformationConfig();
|
|
145
|
+
}
|
|
142
146
|
}
|
|
143
147
|
|
|
144
148
|
componentWillReceiveProps(nextProps) {
|
|
@@ -351,6 +355,7 @@ const mapStateToProps = createStructuredSelector({
|
|
|
351
355
|
function mapDispatchToProps(dispatch) {
|
|
352
356
|
return {
|
|
353
357
|
actions: bindActionCreators(actions, dispatch),
|
|
358
|
+
templateActions: bindActionCreators(templateActions, dispatch),
|
|
354
359
|
};
|
|
355
360
|
}
|
|
356
361
|
|