Skip to content

Commit

Permalink
Merge pull request #812 from brave/fix-invalid-notification-id
Browse files Browse the repository at this point in the history
Handle invalid grant notification ID
  • Loading branch information
NejcZdovc committed Nov 6, 2018
1 parent 319d6b7 commit 379afa2
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ namespace brave_rewards {

RewardsNotificationServiceImpl::RewardsNotificationServiceImpl(Profile* profile)
: profile_(profile) {
ReadRewardsNotifications();
}

RewardsNotificationServiceImpl::~RewardsNotificationServiceImpl() {
StoreRewardsNotifications();
}

void RewardsNotificationServiceImpl::AddNotification(
Expand Down Expand Up @@ -102,16 +100,18 @@ void RewardsNotificationServiceImpl::ReadRewardsNotifications() {
int notification_timestamp;
RewardsNotificationArgs notification_args;
dict_value->GetString("id", &notification_id);
dict_value->GetInteger("type", &notification_type);
dict_value->GetInteger("timestamp", &notification_timestamp);

if (notification_id.empty()) {
int old_id;
dict_value->GetInteger("id", &old_id);
notification_id = std::to_string(old_id);
if (old_id == 0 && notification_type == 2)
notification_id = "rewards_notification_grant";
else
notification_id = std::to_string(old_id);
}

dict_value->GetInteger("type", &notification_type);
dict_value->GetInteger("timestamp", &notification_timestamp);

base::ListValue* args;
dict_value->GetList("args", &args);
for (auto& arg : *args) {
Expand Down

0 comments on commit 379afa2

Please sign in to comment.