Allowing campaigns to be marked as non-global.
This commit is contained in:
@@ -82,18 +82,27 @@ export async function getRandomCampaign(options = {}, context = {}, pass = 0) {
|
||||
|
||||
const validCampaigns = campaigns.filter((campaign) => {
|
||||
if (options.minRatio && (!campaign.banner || campaign.banner.ratio < options.minRatio)) {
|
||||
// too small
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.maxRatio && (!campaign.banner || campaign.banner.ratio > options.maxRatio)) {
|
||||
// too big
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.entityIds && !options.entityIds.some((entityId) => campaign.entity.id === entityId || campaign.entity.parent?.id === entityId)) {
|
||||
// this is an entity page, this campaign does not belong to this entity
|
||||
return false;
|
||||
}
|
||||
|
||||
if (campaign.affiliate?.parameters?.global === false && !options.entityIds) {
|
||||
// this campaign should only show on entity page
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.tagFilter && campaign.banner && campaign.banner.tags.some((tag) => context.tagFilter.includes(tag) && !options.tagSlugs?.includes(tag))) {
|
||||
// wrong tag
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
2
static
2
static
Submodule static updated: 4e5c91df28...13a0a44985
Reference in New Issue
Block a user