Return hashes from user ban use cases
This commit is contained in:
parent
a8e99723cc
commit
050d7d5b56
|
@ -1,13 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'use_case/base'
|
||||
require "use_case/base"
|
||||
|
||||
module UseCase
|
||||
module User
|
||||
class Ban < UseCase::Base
|
||||
REASON_SPAM = 'Spam'
|
||||
REASON_HARASSMENT = 'Harassment'
|
||||
REASON_BAN_EVASION = 'Ban evasion'
|
||||
REASON_SPAM = "Spam"
|
||||
REASON_HARASSMENT = "Harassment"
|
||||
REASON_BAN_EVASION = "Ban evasion"
|
||||
|
||||
option :target_user_id, type: Types::Coercible::Integer
|
||||
option :expiry, types: Types::Nominal::DateTime.optional
|
||||
|
@ -24,14 +24,18 @@ module UseCase
|
|||
)
|
||||
target_user.profile.update!(
|
||||
display_name: nil,
|
||||
description: '',
|
||||
location: '',
|
||||
website: '',
|
||||
description: "",
|
||||
location: "",
|
||||
website: ""
|
||||
)
|
||||
end
|
||||
|
||||
{
|
||||
ban: ban
|
||||
status: 201,
|
||||
resource: ban,
|
||||
extra: {
|
||||
target_user:
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -40,11 +44,7 @@ module UseCase
|
|||
end
|
||||
|
||||
def source_user
|
||||
if source_user_id
|
||||
@source_user ||= ::User.find(source_user_id)
|
||||
else
|
||||
nil
|
||||
end
|
||||
@source_user ||= ::User.find(source_user_id) if source_user_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,6 +9,14 @@ module UseCase
|
|||
|
||||
def call
|
||||
target_user.unban
|
||||
|
||||
{
|
||||
status: 204,
|
||||
resource: nil,
|
||||
extra: {
|
||||
target_user: target_user
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def target_user
|
||||
|
|
Loading…
Reference in New Issue