From 9414e8ddf4ce7e951a6dc9130d99fa12c5696b94 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 17 Oct 2017 11:05:53 +0200 Subject: fix: destroy invites used to create test accounts Production instances are getting cluttered with invites from test accounts. Instead of marking them as used we will now completely remove them. refers to #8804 refers to #8807\ --- app/models/account.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/models/account.rb') diff --git a/app/models/account.rb b/app/models/account.rb index 3283bcc..4442a68 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -43,8 +43,12 @@ class Account end if user.invite_required? user_invite_code = InviteCode.find_by_invite_code user.invite_code - user_invite_code.invite_count += 1 - user_invite_code.save + if user.is_test? && user_invite_code.max_uses == 1 + user_invite_code.destroy + else + user_invite_code.invite_count += 1 + user_invite_code.save + end end end rescue VALIDATION_FAILED => ex -- cgit v1.2.3