Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Brave Ads dislike icon should be shown based upon the advertiser ID #11855

Merged
merged 1 commit into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,31 @@ AdsHistoryInfo Get(const AdsHistoryFilterType filter_type,

void AddAdNotification(const AdNotificationInfo& ad,
const ConfirmationType& confirmation_type) {
const AdHistoryInfo ad_history =
const AdHistoryInfo& ad_history =
BuildAdHistory(ad, confirmation_type, ad.title, ad.body);

Client::Get()->AppendAdHistory(ad_history);
}

void AddNewTabPageAd(const NewTabPageAdInfo& ad,
const ConfirmationType& confirmation_type) {
const AdHistoryInfo ad_history =
const AdHistoryInfo& ad_history =
BuildAdHistory(ad, confirmation_type, ad.company_name, ad.alt);

Client::Get()->AppendAdHistory(ad_history);
}

void AddPromotedContentAd(const PromotedContentAdInfo& ad,
const ConfirmationType& confirmation_type) {
const AdHistoryInfo ad_history =
const AdHistoryInfo& ad_history =
BuildAdHistory(ad, confirmation_type, ad.title, ad.description);

Client::Get()->AppendAdHistory(ad_history);
}

void AddInlineContentAd(const InlineContentAdInfo& ad,
const ConfirmationType& confirmation_type) {
const AdHistoryInfo ad_history =
const AdHistoryInfo& ad_history =
BuildAdHistory(ad, confirmation_type, ad.title, ad.description);

Client::Get()->AppendAdHistory(ad_history);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AdHistoryInfo BuildAdHistory(const AdInfo& ad,
ad_history.ad_content.brand_display_url = GetHostFromUrl(ad.target_url);
ad_history.ad_content.brand_url = ad.target_url;
ad_history.ad_content.like_action_type =
Client::Get()->GetAdContentLikeActionTypeForSegment(ad.segment);
Client::Get()->GetAdContentLikeActionTypeForAdvertiser(ad.advertiser_id);
ad_history.ad_content.confirmation_type = confirmation_type;
ad_history.category_content.opt_action_type =
Client::Get()->GetCategoryContentOptActionTypeForSegment(ad.segment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ TEST_F(BatAdsAdsHistoryUtilTest, BuildAd) {
ad.target_url = "https://brave.com";

// Act
const AdHistoryInfo ad_history =
const AdHistoryInfo& ad_history =
BuildAdHistory(ad, ConfirmationType::kViewed, "title", "description");

// Assert
Expand Down
6 changes: 3 additions & 3 deletions vendor/bat-native-ads/src/bat/ads/internal/client/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ AdContentLikeActionType Client::ToggleAdThumbDown(
return like_action_type;
}

AdContentLikeActionType Client::GetAdContentLikeActionTypeForSegment(
const std::string& segment) {
AdContentLikeActionType Client::GetAdContentLikeActionTypeForAdvertiser(
const std::string& advertiser_id) {
for (const auto& element : client_->ads_shown_history) {
if (element.category_content.category == segment) {
if (element.ad_content.advertiser_id == advertiser_id) {
return element.ad_content.like_action_type;
}
}
Expand Down
4 changes: 2 additions & 2 deletions vendor/bat-native-ads/src/bat/ads/internal/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class Client final {

AdContentLikeActionType ToggleAdThumbUp(const AdContentInfo& ad_content);
AdContentLikeActionType ToggleAdThumbDown(const AdContentInfo& ad_content);
AdContentLikeActionType GetAdContentLikeActionTypeForSegment(
const std::string& segment);
AdContentLikeActionType GetAdContentLikeActionTypeForAdvertiser(
const std::string& advertiser_id);

CategoryContentOptActionType ToggleAdOptIn(
const std::string& category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ std::string DislikeFrequencyCap::GetLastMessage() const {
}

bool DislikeFrequencyCap::DoesRespectCap(const CreativeAdInfo& creative_ad) {
const FilteredAdvertiserList filtered_advertisers =
const FilteredAdvertiserList& filtered_advertisers =
Client::Get()->GetFilteredAdvertisers();
if (filtered_advertisers.empty()) {
return true;
Expand Down