summaryrefslogtreecommitdiff
path: root/app/graphql/resolvers/todo_resolver.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /app/graphql/resolvers/todo_resolver.rb
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/graphql/resolvers/todo_resolver.rb')
-rw-r--r--app/graphql/resolvers/todo_resolver.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/graphql/resolvers/todo_resolver.rb b/app/graphql/resolvers/todo_resolver.rb
index cff65321dc0..bd5f8f274cd 100644
--- a/app/graphql/resolvers/todo_resolver.rb
+++ b/app/graphql/resolvers/todo_resolver.rb
@@ -4,7 +4,7 @@ module Resolvers
class TodoResolver < BaseResolver
type Types::TodoType, null: true
- alias_method :user, :object
+ alias_method :target, :object
argument :action, [Types::TodoActionEnum],
required: false,
@@ -31,9 +31,10 @@ module Resolvers
description: 'The type of the todo'
def resolve(**args)
- return Todo.none if user != context[:current_user]
+ return Todo.none unless current_user.present? && target.present?
+ return Todo.none if target.is_a?(User) && target != current_user
- TodosFinder.new(user, todo_finder_params(args)).execute
+ TodosFinder.new(current_user, todo_finder_params(args)).execute
end
private
@@ -46,6 +47,15 @@ module Resolvers
author_id: args[:author_id],
action_id: args[:action],
project_id: args[:project_id]
+ }.merge(target_params)
+ end
+
+ def target_params
+ return {} unless TodosFinder::TODO_TYPES.include?(target.class.name)
+
+ {
+ type: target.class.name,
+ target_id: target.id
}
end
end