1
0
mirror of synced 2026-08-05 22:56:55 +00:00

no accounts created

This commit is contained in:
Rimian Perkins
2017-05-10 10:05:53 +10:00
parent e875b17be2
commit f008f91a79
2 changed files with 56 additions and 48 deletions
@@ -30,26 +30,12 @@ module DiscourseDonations
if charge['paid'] == true
output['messages'] << I18n.t('donations.payment.success')
end
if reward?(payment)
if current_user.present?
reward = DiscourseDonations::Rewards.new(current_user)
if reward.add_to_group(group_name)
output['rewards'] << { type: :group, name: group_name }
end
if reward.grant_badge(badge_name)
output['rewards'] << { type: :badge, name: badge_name }
end
elsif email.present?
if group_name.present?
store = PluginStore.get('discourse-donations', 'group:add') || []
PluginStore.set('discourse-donations', 'group:add', store << email)
end
if badge_name.present?
store = PluginStore.get('discourse-donations', 'badge:grant') || []
PluginStore.set('discourse-donations', 'badge:grant', store << email)
end
output['rewards'] << { type: :group, name: group_name } if group_name
output['rewards'] << { type: :badge, name: badge_name } if badge_name
if create_account && email.present?
# ::Jobs.enqueue(:donation_user, params.merge(rewards: output['rewards']))
end
end
@@ -59,7 +45,7 @@ module DiscourseDonations
private
def create_account
params[:create_account] == 'true'
params[:create_account] == 'true' && SiteSetting.discourse_donations_enable_create_accounts
end
def reward?(payment)