agrs-sequelize-sdk 1.1.25 → 1.1.26
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/models/CodefuelCampaign.js +0 -26
- package/package.json +1 -1
|
@@ -147,32 +147,6 @@ module.exports = (sequelize, DataTypes) => {
|
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
-
CodefuelCampaign.beforeUpdate(async (campaign, options) => {
|
|
151
|
-
const { updateAdData, publishAdFacebook } = require("../Facebook/Ad");
|
|
152
|
-
console.log("CodefuelCampaign changed", campaign.changed("FinalLink"));
|
|
153
|
-
const { getAdsByAgrscid } = require("../Facebook/db/ad");
|
|
154
|
-
if (campaign.changed("FinalLink")) {
|
|
155
|
-
try {
|
|
156
|
-
const ads = await getAdsByAgrscid(campaign.AGRSCID);
|
|
157
|
-
|
|
158
|
-
await Promise.all(
|
|
159
|
-
ads.map(async (ad) => {
|
|
160
|
-
if (ad.Draft === "true" || ad.Draft === true) {
|
|
161
|
-
// Update ad data and publish ad
|
|
162
|
-
await updateAdData({
|
|
163
|
-
adId: ad.AdID,
|
|
164
|
-
websiteUrl: campaign.FinalLink, // Assuming `campaign.FinalLink` is correct
|
|
165
|
-
});
|
|
166
|
-
await publishAdFacebook(ad.AdID, null, null, campaign.FinalLink);
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.error("Error processing ads:", error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
|
|
176
150
|
CodefuelCampaign.afterUpdate(async (campaign, options) => {
|
|
177
151
|
console.log("afterUpdate", campaign);
|
|
178
152
|
});
|