Turn direct setting into an option for the use case

This commit is contained in:
Andreas Nedbal 2022-07-24 22:24:48 +02:00
parent bea98fa917
commit 2692783518
1 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,7 @@ module UseCase
option :content, type: Types::Coercible::String option :content, type: Types::Coercible::String
option :anonymous, type: Types::Params::Bool, default: proc { false } option :anonymous, type: Types::Params::Bool, default: proc { false }
option :author_identifier, type: Types::Coercible::String | Types::Nil option :author_identifier, type: Types::Coercible::String | Types::Nil
option :direct, type: Types::Params::Bool, default: proc { true }
def call def call
check_anonymous_rules check_anonymous_rules
@ -21,7 +22,7 @@ module UseCase
author_is_anonymous: anonymous, author_is_anonymous: anonymous,
author_identifier: author_identifier, author_identifier: author_identifier,
user: source_user_id.nil? ? nil : source_user, user: source_user_id.nil? ? nil : source_user,
direct: true direct: direct
) )
return if filtered?(question) return if filtered?(question)
@ -56,7 +57,7 @@ module UseCase
end end
def increment_asked_count def increment_asked_count
unless source_user_id && !anonymous unless source_user_id && !anonymous && !direct
# Only increment the asked count of the source user if the question # Only increment the asked count of the source user if the question
# is not anonymous, and we actually have a source user # is not anonymous, and we actually have a source user
return return