FIX: when granting old badges that are bronze, do not notify

This commit is contained in:
Sam
2016-04-12 22:08:38 +10:00
parent 144bf07886
commit 72849e65de
2 changed files with 23 additions and 9 deletions
+12 -9
View File
@@ -41,15 +41,18 @@ class BadgeGranter
end
if SiteSetting.enable_badges?
I18n.with_locale(@user.effective_locale) do
notification = @user.notifications.create(
notification_type: Notification.types[:granted_badge],
data: { badge_id: @badge.id,
badge_name: @badge.display_name,
badge_slug: @badge.slug,
username: @user.username}.to_json
)
user_badge.update_attributes notification_id: notification.id
unless @badge.badge_type_id == BadgeType::Bronze && user_badge.granted_at < 2.days.ago
I18n.with_locale(@user.effective_locale) do
notification = @user.notifications.create(
notification_type: Notification.types[:granted_badge],
data: { badge_id: @badge.id,
badge_name: @badge.display_name,
badge_slug: @badge.slug,
username: @user.username}.to_json
)
user_badge.update_attributes notification_id: notification.id
end
end
end
end