@bprotsyk/aso-core 2.1.85 → 2.1.86
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.
|
@@ -315,8 +315,41 @@ async function cloneDirectCampaign(app, platform, addDefaultStreams) {
|
|
|
315
315
|
return hasId && hasArrow && noPlatformAtEnd;
|
|
316
316
|
});
|
|
317
317
|
}
|
|
318
|
-
if (matchingCampaign.length > 0)
|
|
319
|
-
|
|
318
|
+
if (matchingCampaign.length > 0) {
|
|
319
|
+
const existingCampaign = matchingCampaign[0];
|
|
320
|
+
// Якщо addDefaultStreams === true, додаємо потоки до існуючої кампанії
|
|
321
|
+
if (addDefaultStreams) {
|
|
322
|
+
const originalStreams = await getStreamsByCampaignId(3175);
|
|
323
|
+
const existingStreams = await getStreamsByCampaignId(existingCampaign.id);
|
|
324
|
+
for (const stream of originalStreams) {
|
|
325
|
+
// Перевіряємо чи потік вже існує
|
|
326
|
+
const existingStream = existingStreams.find(s => s.name === stream.name);
|
|
327
|
+
if (!existingStream) {
|
|
328
|
+
await http_1.default.post('streams', {
|
|
329
|
+
name: stream.name,
|
|
330
|
+
campaign_id: existingCampaign.id,
|
|
331
|
+
schema: stream.schema,
|
|
332
|
+
type: stream.type,
|
|
333
|
+
action_type: stream.action_type,
|
|
334
|
+
weight: stream.weight,
|
|
335
|
+
offers: stream.offers.map((offer) => ({
|
|
336
|
+
offer_id: offer.offer_id,
|
|
337
|
+
share: offer.share,
|
|
338
|
+
state: offer.state
|
|
339
|
+
})),
|
|
340
|
+
filters: stream.filters.map((filter) => ({
|
|
341
|
+
name: filter.name,
|
|
342
|
+
mode: filter.mode,
|
|
343
|
+
payload: filter.payload
|
|
344
|
+
})),
|
|
345
|
+
position: stream.position,
|
|
346
|
+
state: stream.state
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return existingCampaign;
|
|
352
|
+
}
|
|
320
353
|
const originalCampaign = await getCampaignById(3175);
|
|
321
354
|
const maxPosition = Math.max(...allCampaigns.map(c => c.position || 0));
|
|
322
355
|
const originalStreams = await getStreamsByCampaignId(3175);
|
package/package.json
CHANGED
|
@@ -385,7 +385,44 @@ async function cloneDirectCampaign(app: IApp, platform?: EPlatform, addDefaultSt
|
|
|
385
385
|
});
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
-
if (matchingCampaign.length > 0)
|
|
388
|
+
if (matchingCampaign.length > 0) {
|
|
389
|
+
const existingCampaign = matchingCampaign[0];
|
|
390
|
+
|
|
391
|
+
// Якщо addDefaultStreams === true, додаємо потоки до існуючої кампанії
|
|
392
|
+
if (addDefaultStreams) {
|
|
393
|
+
const originalStreams = await getStreamsByCampaignId(3175);
|
|
394
|
+
const existingStreams = await getStreamsByCampaignId(existingCampaign.id);
|
|
395
|
+
|
|
396
|
+
for (const stream of originalStreams) {
|
|
397
|
+
// Перевіряємо чи потік вже існує
|
|
398
|
+
const existingStream = existingStreams.find(s => s.name === stream.name);
|
|
399
|
+
if (!existingStream) {
|
|
400
|
+
await keitaroApi.post('streams', {
|
|
401
|
+
name: stream.name,
|
|
402
|
+
campaign_id: existingCampaign.id,
|
|
403
|
+
schema: stream.schema,
|
|
404
|
+
type: stream.type,
|
|
405
|
+
action_type: stream.action_type,
|
|
406
|
+
weight: stream.weight,
|
|
407
|
+
offers: stream.offers.map((offer) => ({
|
|
408
|
+
offer_id: offer.offer_id,
|
|
409
|
+
share: offer.share,
|
|
410
|
+
state: offer.state
|
|
411
|
+
})),
|
|
412
|
+
filters: stream.filters.map((filter) => ({
|
|
413
|
+
name: filter.name,
|
|
414
|
+
mode: filter.mode,
|
|
415
|
+
payload: filter.payload
|
|
416
|
+
})),
|
|
417
|
+
position: stream.position,
|
|
418
|
+
state: stream.state
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return existingCampaign;
|
|
425
|
+
}
|
|
389
426
|
|
|
390
427
|
const originalCampaign: IKeitaroCampaign = await getCampaignById(3175);
|
|
391
428
|
const maxPosition = Math.max(...allCampaigns.map(c => c.position || 0));
|