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