Class: Users::Internal
- Inherits:
-
Object
- Object
- Users::Internal
- Extended by:
- Forwardable, Gitlab::Utils::StrongMemoize
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- lib/users/internal.rb
Class Method Summary collapse
- .in_organization(organization) ⇒ Object
-
.support_bot_id ⇒ Object
Checks against this bot are now included in every issue and work item detail and list page rendering and in GraphQL queries (especially for determining the web_url of an issue/work item).
Instance Method Summary collapse
- #admin_bot ⇒ Object
- #alert_bot ⇒ Object
- #automation_bot ⇒ Object
- #bot_avatar(image:) ⇒ Object
- #duo_code_review_bot ⇒ Object
-
#ghost ⇒ Object
Return (create if necessary) the ghost user.
-
#initialize(organization: nil) ⇒ Internal
constructor
A new instance of Internal.
- #security_bot ⇒ Object
- #support_bot ⇒ Object
- #support_bot_id ⇒ Object
Constructor Details
#initialize(organization: nil) ⇒ Internal
Returns a new instance of Internal.
33 34 35 36 37 38 39 40 41 |
# File 'lib/users/internal.rb', line 33 def initialize(organization: nil) case organization when ::Organizations::Organization @organization = organization @organization_id = organization.id else @organization_id = organization end end |
Class Method Details
.in_organization(organization) ⇒ Object
14 15 16 |
# File 'lib/users/internal.rb', line 14 def in_organization(organization) new(organization: organization) end |
.support_bot_id ⇒ Object
Checks against this bot are now included in every issue and work item detail and list page rendering and in GraphQL queries (especially for determining the web_url of an issue/work item). Because the bot never changes once created, we can memoize it for the lifetime of the application process. It also doesn’t matter that different nodes may have different object instances of the bot. We only memoize the id because this is the information we check against.
25 26 27 |
# File 'lib/users/internal.rb', line 25 def support_bot_id new.support_bot.id end |
Instance Method Details
#admin_bot ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/users/internal.rb', line 119 def admin_bot email_pattern = "admin-bot%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:admin_bot), 'GitLab-Admin-Bot', email_pattern) do |u| u.bio = 'Admin bot used for tasks that require admin privileges' u.name = 'GitLab Admin Bot' u.avatar = bot_avatar(image: 'admin-bot.png') u.admin = true u.confirmed_at = Time.zone.now u.private_profile = true end end |
#alert_bot ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/users/internal.rb', line 54 def alert_bot email_pattern = "alert%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:alert_bot), 'alert-bot', email_pattern) do |u| u.bio = 'The GitLab alert bot' u.name = 'GitLab Alert Bot' u.avatar = bot_avatar(image: 'alert-bot.png') u.confirmed_at = Time.zone.now u.private_profile = true end end |
#automation_bot ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/users/internal.rb', line 95 def automation_bot email_pattern = "automation%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:automation_bot), 'automation-bot', email_pattern) do |u| u.bio = 'The GitLab automation bot used for automated workflows and tasks' u.name = 'GitLab Automation Bot' u.avatar = bot_avatar(image: 'support-bot.png') # todo: add an avatar for automation-bot u.confirmed_at = Time.zone.now u.private_profile = true end end |
#bot_avatar(image:) ⇒ Object
132 133 134 |
# File 'lib/users/internal.rb', line 132 def bot_avatar(image:) Rails.root.join('lib', 'assets', 'images', 'bot_avatars', image).open end |
#duo_code_review_bot ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/users/internal.rb', line 107 def duo_code_review_bot email_pattern = "gitlab-duo%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:duo_code_review_bot), 'GitLabDuo', email_pattern) do |u| u.bio = 'GitLab Duo bot for handling AI tasks' u.name = 'GitLab Duo' u.avatar = bot_avatar(image: 'duo-bot.png') u.confirmed_at = Time.zone.now u.private_profile = true end end |
#ghost ⇒ Object
Return (create if necessary) the ghost user. The ghost user owns records previously belonging to deleted users.
45 46 47 48 49 50 51 52 |
# File 'lib/users/internal.rb', line 45 def ghost email = 'ghost%[email protected]' unique_internal(User.with_user_types(:ghost), 'ghost', email) do |u| u.bio = _('This is a "Ghost User", created to hold all issues authored by users that have ' \ 'since been deleted. This user cannot be removed.') u.name = 'Ghost' end end |
#security_bot ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/users/internal.rb', line 66 def security_bot email_pattern = "security-bot%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:security_bot), 'GitLab-Security-Bot', email_pattern) do |u| u.bio = 'System bot that monitors detected vulnerabilities for solutions ' \ 'and creates merge requests with the fixes.' u.name = 'GitLab Security Bot' u.avatar = bot_avatar(image: 'security-bot.png') u.confirmed_at = Time.zone.now u.private_profile = true end end |
#support_bot ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/users/internal.rb', line 79 def support_bot email_pattern = "support%s@#{Settings.gitlab.host}" unique_internal(User.with_user_types(:support_bot), 'support-bot', email_pattern) do |u| u.bio = 'The GitLab support bot used for Service Desk' u.name = 'GitLab Support Bot' u.avatar = bot_avatar(image: 'support-bot.png') u.confirmed_at = Time.zone.now u.private_profile = true end end |
#support_bot_id ⇒ Object
91 92 93 |
# File 'lib/users/internal.rb', line 91 def support_bot_id support_bot.id end |