Skip to content

Commit

Permalink
FIX: Add exclude groups for each ad platforms
Browse files Browse the repository at this point in the history
With the new group system for displaying ads we no longer can check if a
user belongs to a trust level group lower than specified. The other
problem is that ALL users including staff and higher trust levels all
belong to trust level 0. So without this fix if we say that an ad should
be visible to trust level 0 users then it will be shown to all users.

This fix adds a new default setting for each ad platform for excluding
trust level 3, 4, and staff users from being shown ads.
  • Loading branch information
oblakeerickson committed Feb 8, 2024
1 parent 6b54128 commit fff25eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
30 changes: 30 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ adsense_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
adsense_exclude_groups:
default: "3|13|14"
type: group_list
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
adsense_topic_list_top_code:
client: true
default: ""
Expand Down Expand Up @@ -177,6 +183,12 @@ dfp_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
dfp_exclude_groups:
default: "3|13|14"
type: group_list
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
dfp_topic_list_top_code:
client: true
default: ""
Expand Down Expand Up @@ -334,6 +346,12 @@ amazon_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
amazon_exclude_groups:
default: "3|13|14"
type: group_list
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
amazon_topic_list_top_src_code:
client: true
default: ""
Expand Down Expand Up @@ -430,6 +448,12 @@ carbonads_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
carbonads_exclude_groups:
default: "3|13|14"
type: group_list
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
carbonads_topic_list_top_enabled:
client: true
default: false
Expand All @@ -453,6 +477,12 @@ adbutler_plugin:
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
adbutler_exclude_groups:
default: "3|13|14"
type: group_list
allow_any: false
refresh: true
validator: "AtLeastOneGroupValidator"
adbutler_topic_list_top_zone_id:
client: true
default: ""
Expand Down
15 changes: 10 additions & 5 deletions lib/adplugin/guardian_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
module ::AdPlugin
module GuardianExtensions
def show_dfp_ads?
self.user.in_any_groups?(SiteSetting.dfp_display_groups_map)
self.user.in_any_groups?(SiteSetting.dfp_display_groups_map) &&
!self.user.in_any_groups?(SiteSetting.dfp_exclude_groups_map)
end

def show_adsense_ads?
self.user.in_any_groups?(SiteSetting.adsense_display_groups_map)
self.user.in_any_groups?(SiteSetting.adsense_display_groups_map) &&
!self.user.in_any_groups?(SiteSetting.adsense_exclude_groups_map)
end

def show_carbon_ads?
self.user.in_any_groups?(SiteSetting.carbonads_display_groups_map)
self.user.in_any_groups?(SiteSetting.carbonads_display_groups_map) &&
!self.user.in_any_groups?(SiteSetting.carbonads_exclude_groups_map)
end

def show_amazon_ads?
self.user.in_any_groups?(SiteSetting.amazon_display_groups_map)
self.user.in_any_groups?(SiteSetting.amazon_display_groups_map) &&
!self.user.in_any_groups?(SiteSetting.amazon_exclude_groups_map)
end

def show_adbutler_ads?
self.user.in_any_groups?(SiteSetting.adbutler_display_groups_map)
self.user.in_any_groups?(SiteSetting.adbutler_display_groups_map) &&
!self.user.in_any_groups?(SiteSetting.adbutler_exclude_groups_map)
end
end
end

0 comments on commit fff25eb

Please sign in to comment.