Move ban invalidation to `User#unban` method
This commit is contained in:
parent
0c6d79ce0b
commit
3247d1c746
|
@ -234,7 +234,10 @@ class User < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def unban
|
def unban
|
||||||
UseCase::User::Unban.call(id)
|
UserBan.current.where(user_id: self.id).update_all(
|
||||||
|
# -1s to account for flakyness with timings in tests
|
||||||
|
expires_at: DateTime.now - 1.second
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Bans a user.
|
# Bans a user.
|
||||||
|
|
|
@ -8,10 +8,11 @@ module UseCase
|
||||||
param :target_user_id, type: Types::Coercible::Integer
|
param :target_user_id, type: Types::Coercible::Integer
|
||||||
|
|
||||||
def call
|
def call
|
||||||
UserBan.current.where(user_id: target_user_id).update_all(
|
target_user.unban
|
||||||
# -1s to account for flakyness with timings in tests
|
end
|
||||||
expires_at: DateTime.now - 1.second
|
|
||||||
)
|
def target_user
|
||||||
|
@target_user ||= ::User.find(target_user_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue