mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 02:29:31 +08:00
FIX: Added two user badge triggers
Created two triggers that trigger events when a badge is granted or removed. Trigger 1: user_badge_granted Variable - badge_id Variable - user_id Trigger 2: user_badge_removed Variable - badge_id Variable - user_id
This commit is contained in:
parent
cf81b3f86d
commit
15e54c715f
|
@ -12,10 +12,12 @@ class UserBadge < ActiveRecord::Base
|
||||||
|
|
||||||
after_create do
|
after_create do
|
||||||
Badge.increment_counter 'grant_count', self.badge_id
|
Badge.increment_counter 'grant_count', self.badge_id
|
||||||
|
DiscourseEvent.trigger(:user_badge_granted, badge_id, user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
after_destroy do
|
after_destroy do
|
||||||
Badge.decrement_counter 'grant_count', self.badge_id
|
Badge.decrement_counter 'grant_count', self.badge_id
|
||||||
|
DiscourseEvent.trigger(:user_badge_removed, badge_id, user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user