diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 03:07:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 03:07:23 +0300 |
commit | 196f676f0e538e12501bc0ade8dd064c509230ba (patch) | |
tree | 024b06a803422eccad6a756ecf5d2357ed7ef0ba /app | |
parent | 97db9c4644d04ca42b65240f218f803529ad5cf2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/graphql/types/member_interface.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/merge_requests/interacts_with_merge_request.rb | 2 | ||||
-rw-r--r-- | app/graphql/types/user_interface.rb | 13 | ||||
-rw-r--r-- | app/graphql/types/users/email_type.rb | 36 | ||||
-rw-r--r-- | app/graphql/types/users/namespace_commit_email_type.rb | 36 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | app/policies/email_policy.rb | 5 | ||||
-rw-r--r-- | app/policies/user_policy.rb | 1 | ||||
-rw-r--r-- | app/policies/users/namespace_commit_email_policy.rb | 7 |
9 files changed, 100 insertions, 4 deletions
diff --git a/app/graphql/types/member_interface.rb b/app/graphql/types/member_interface.rb index edadbcddfb3..4c9ee6246a3 100644 --- a/app/graphql/types/member_interface.rb +++ b/app/graphql/types/member_interface.rb @@ -46,7 +46,7 @@ module Types def merge_request_interaction(id: nil) Gitlab::Graphql::Lazy.with_value(GitlabSchema.object_from_id(id, expected_class: ::MergeRequest)) do |merge_request| - Users::MergeRequestInteraction.new(user: object.user, merge_request: merge_request) if merge_request + ::Users::MergeRequestInteraction.new(user: object.user, merge_request: merge_request) if merge_request end end end diff --git a/app/graphql/types/merge_requests/interacts_with_merge_request.rb b/app/graphql/types/merge_requests/interacts_with_merge_request.rb index bef2d39dc5c..672a2a315d4 100644 --- a/app/graphql/types/merge_requests/interacts_with_merge_request.rb +++ b/app/graphql/types/merge_requests/interacts_with_merge_request.rb @@ -16,7 +16,7 @@ module Types def merge_request_interaction(parent:, id: nil) # need the connection parent if called from a connection node: parent = parent.parent if parent.try(:field)&.connection? - Users::MergeRequestInteraction.new(user: object, merge_request: parent) + ::Users::MergeRequestInteraction.new(user: object, merge_request: parent) end end end diff --git a/app/graphql/types/user_interface.rb b/app/graphql/types/user_interface.rb index 51046d09f90..a5bed3b9e19 100644 --- a/app/graphql/types/user_interface.rb +++ b/app/graphql/types/user_interface.rb @@ -42,10 +42,23 @@ module Types null: true, description: 'User email.', method: :public_email, deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' } + field :emails, + type: Types::Users::EmailType.connection_type, + null: true, + description: "User's email addresses." field :public_email, type: GraphQL::Types::String, null: true, description: "User's public email." + field :commit_email, + type: GraphQL::Types::String, + null: true, + description: "User's default commit email.", + authorize: :read_user_email_address + field :namespace_commit_emails, + type: Types::Users::NamespaceCommitEmailType.connection_type, + null: true, + description: "User's custom namespace commit emails." field :avatar_url, type: GraphQL::Types::String, null: true, diff --git a/app/graphql/types/users/email_type.rb b/app/graphql/types/users/email_type.rb new file mode 100644 index 00000000000..5e0b9563f57 --- /dev/null +++ b/app/graphql/types/users/email_type.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Types + module Users + class EmailType < BaseObject + graphql_name 'Email' + + authorize :read_user_email_address + + field :id, + GraphQL::Types::ID, + null: false, + description: 'Internal ID of the email.' + + field :email, + GraphQL::Types::String, + null: false, + description: 'Email address.' + + field :confirmed_at, + Types::TimeType, + null: true, + description: 'Timestamp the email was confirmed.' + + field :created_at, + Types::TimeType, + null: false, + description: 'Timestamp the email was created.' + + field :updated_at, + Types::TimeType, + null: false, + description: 'Timestamp the email was last updated.' + end + end +end diff --git a/app/graphql/types/users/namespace_commit_email_type.rb b/app/graphql/types/users/namespace_commit_email_type.rb new file mode 100644 index 00000000000..a64423c7169 --- /dev/null +++ b/app/graphql/types/users/namespace_commit_email_type.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module Types + module Users + class NamespaceCommitEmailType < BaseObject + graphql_name 'NamespaceCommitEmail' + + authorize :read_user_email_address + + field :id, + GraphQL::Types::ID, + null: false, + description: 'Internal ID of the namespace commit email.' + + field :email, + Types::Users::EmailType, + null: false, + description: 'Email.' + + field :namespace, + Types::NamespaceType, + null: false, + description: 'Namespace.' + + field :created_at, + Types::TimeType, + null: false, + description: 'Timestamp the namespace commit email was created.' + + field :updated_at, + Types::TimeType, + null: false, + description: 'Timestamp the namespace commit email was last updated.' + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 3483d70c228..da6e1abad07 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -265,9 +265,7 @@ class User < ApplicationRecord has_many :resource_label_events, dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent has_many :resource_state_events, dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent has_many :authored_events, class_name: 'Event', dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent - has_many :namespace_commit_emails, class_name: 'Users::NamespaceCommitEmail' - has_many :user_achievements, class_name: 'Achievements::UserAchievement', inverse_of: :user has_many :awarded_user_achievements, class_name: 'Achievements::UserAchievement', foreign_key: 'awarded_by_user_id', inverse_of: :awarded_by_user has_many :revoked_user_achievements, class_name: 'Achievements::UserAchievement', foreign_key: 'revoked_by_user_id', inverse_of: :revoked_by_user diff --git a/app/policies/email_policy.rb b/app/policies/email_policy.rb new file mode 100644 index 00000000000..cf10fa893b4 --- /dev/null +++ b/app/policies/email_policy.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +class EmailPolicy < BasePolicy # rubocop:disable Gitlab/NamespacedClass + delegate { @subject.user } +end diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb index 4f3dafbf5c8..ed5b01e52b4 100644 --- a/app/policies/user_policy.rb +++ b/app/policies/user_policy.rb @@ -30,6 +30,7 @@ class UserPolicy < BasePolicy enable :read_group_count enable :read_user_groups enable :read_saved_replies + enable :read_user_email_address end rule { default }.enable :read_user_profile diff --git a/app/policies/users/namespace_commit_email_policy.rb b/app/policies/users/namespace_commit_email_policy.rb new file mode 100644 index 00000000000..849ebd04688 --- /dev/null +++ b/app/policies/users/namespace_commit_email_policy.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module Users + class NamespaceCommitEmailPolicy < BasePolicy + delegate { @subject.user } + end +end |