diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/email | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/email')
13 files changed, 30 insertions, 665 deletions
diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb index e6c64e2b1d6..7daa1bb96a1 100644 --- a/lib/gitlab/email/handler/create_note_handler.rb +++ b/lib/gitlab/email/handler/create_note_handler.rb @@ -50,7 +50,7 @@ module Gitlab end def create_note - external_author = from_address if author == User.support_bot + external_author = from_address if author == Users::Internal.support_bot sent_notification.create_reply(note_message, external_author) end @@ -67,7 +67,7 @@ module Gitlab def validate_from_address! # Recipieint is always set to Support bot for ServiceDesk issues so we should exclude those. - return if author == User.support_bot + return if author == Users::Internal.support_bot raise UserNotFoundError unless from_address && author.verified_email?(from_address) end diff --git a/lib/gitlab/email/handler/service_desk_handler.rb b/lib/gitlab/email/handler/service_desk_handler.rb index 5d0e6ea61e1..949fa554aeb 100644 --- a/lib/gitlab/email/handler/service_desk_handler.rb +++ b/lib/gitlab/email/handler/service_desk_handler.rb @@ -117,7 +117,7 @@ module Gitlab def create_issue! result = ::Issues::CreateService.new( container: project, - current_user: User.support_bot, + current_user: Users::Internal.support_bot, params: { title: mail.subject, description: message_including_template, @@ -199,7 +199,7 @@ module Gitlab def create_note(note) ::Notes::CreateService.new( project, - User.support_bot, + Users::Internal.support_bot, noteable: @issue, note: note ).execute @@ -214,7 +214,7 @@ module Gitlab end def author - User.support_bot + Users::Internal.support_bot end def add_email_participant diff --git a/lib/gitlab/email/message/in_product_marketing.rb b/lib/gitlab/email/message/in_product_marketing.rb deleted file mode 100644 index bd2c91755c8..00000000000 --- a/lib/gitlab/email/message/in_product_marketing.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - UnknownTrackError = Class.new(StandardError) - - def self.for(track) - valid_tracks = Namespaces::InProductMarketingEmailsService::TRACKS.keys - raise UnknownTrackError unless valid_tracks.include?(track) - - "Gitlab::Email::Message::InProductMarketing::#{track.to_s.classify}".constantize - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/admin_verify.rb b/lib/gitlab/email/message/in_product_marketing/admin_verify.rb deleted file mode 100644 index 888f84cde23..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/admin_verify.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class AdminVerify < Base - def subject_line - s_('InProductMarketing|Create a custom CI runner with just a few clicks') - end - - def tagline - nil - end - - def title - s_('InProductMarketing|Spin up an autoscaling runner in GitLab') - end - - def subtitle - s_('InProductMarketing|Use our AWS cloudformation template to spin up your runners in just a few clicks!') - end - - def body_line1 - '' - end - - def body_line2 - '' - end - - def cta_text - s_('InProductMarketing|Create a custom runner') - end - - def progress - super(track_name: 'Admin') - end - - def invite_members? - user.can?(:admin_group_member, group) - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/base.rb b/lib/gitlab/email/message/in_product_marketing/base.rb deleted file mode 100644 index bd20b7e5fc7..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/base.rb +++ /dev/null @@ -1,127 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class Base - include Gitlab::Email::Message::InProductMarketing::Helper - include Gitlab::Routing - include Gitlab::Experiment::Dsl - - attr_accessor :format - - def initialize(group:, user:, series:, format: :html) - @series = series - @group = group - @user = user - @format = format - - validate_series! - end - - def subject_line - raise NotImplementedError - end - - def tagline - raise NotImplementedError - end - - def title - raise NotImplementedError - end - - def subtitle - raise NotImplementedError - end - - def body_line1 - raise NotImplementedError - end - - def body_line2 - raise NotImplementedError - end - - def cta_text - raise NotImplementedError - end - - def cta_link - case format - when :html - ActionController::Base.helpers.link_to cta_text, group_email_campaigns_url(group, track: track, series: series), target: '_blank', rel: 'noopener noreferrer' - else - [cta_text, group_email_campaigns_url(group, track: track, series: series)].join(' >> ') - end - end - - def invite_members? - false - end - - def invite_text - s_('InProductMarketing|Do you have a teammate who would be perfect for this task?') - end - - def invite_link - action_link(s_('InProductMarketing|Invite them to help out.'), group_url(group, open_modal: 'invite_members_for_task')) - end - - def unsubscribe - self_managed_preferences_link = marketing_preference_link(track, series) - unsubscribe_message(self_managed_preferences_link) - end - - def progress(current: series + 1, total: total_series, track_name: track.to_s.humanize) - if Gitlab.com? - s_('InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series.') % { current_series: current, total_series: total, track: track_name } - else - s_('InProductMarketing|This is email %{current_series} of %{total_series} in the %{track} series. To disable notification emails sent by your local GitLab instance, either contact your administrator or %{unsubscribe_link}.') % { current_series: current, total_series: total, track: track_name, unsubscribe_link: unsubscribe_link } - end - end - - def logo_path - ["mailers/in_product_marketing", "#{track}-#{series}.png"].join('/') - end - - def series? - total_series > 0 - end - - protected - - attr_reader :group, :user, :series - - private - - def track - self.class.name.demodulize.underscore.to_sym - end - - def total_series - Namespaces::InProductMarketingEmailsService::TRACKS[track][:interval_days].size - end - - def marketing_preference_link(track, series) - params = { - utm_source: 'SM', - utm_medium: 'email', - utm_campaign: 'onboarding', - utm_term: "#{track}_#{series}" - } - - preference_link = "https://about.gitlab.com/company/preference-center/?#{params.to_query}" - - link(s_('InProductMarketing|update your preferences'), preference_link) - end - - def validate_series! - raise ArgumentError, "Only #{total_series} series available for this track." unless @series.between?(0, total_series - 1) - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/create.rb b/lib/gitlab/email/message/in_product_marketing/create.rb deleted file mode 100644 index 68f9a9a21c9..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/create.rb +++ /dev/null @@ -1,105 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class Create < Base - def subject_line - [ - s_('InProductMarketing|Create a project in GitLab in 5 minutes'), - s_('InProductMarketing|Import your project and code from GitHub, Bitbucket and others'), - s_('InProductMarketing|Understand repository mirroring') - ][series] - end - - def tagline - [ - s_('InProductMarketing|Get started today'), - s_('InProductMarketing|Get our import guides'), - s_('InProductMarketing|Need an alternative to importing?') - ][series] - end - - def title - [ - s_('InProductMarketing|Take your first steps with GitLab'), - s_('InProductMarketing|Start by importing your projects'), - s_('InProductMarketing|How (and why) mirroring makes sense') - ][series] - end - - def subtitle - [ - s_('InProductMarketing|Dig in and create a project and a repo'), - s_("InProductMarketing|Here's what you need to know"), - s_('InProductMarketing|Try it out') - ][series] - end - - def body_line1 - [ - s_("InProductMarketing|To understand and get the most out of GitLab, start at the beginning and %{project_link}. In GitLab, repositories are part of a project, so after you've created your project you can go ahead and %{repo_link}.") % { project_link: project_link, repo_link: repo_link }, - s_("InProductMarketing|Making the switch? It's easier than you think to import your projects into GitLab. Move %{github_link}, or import something %{bitbucket_link}.") % { github_link: github_link, bitbucket_link: bitbucket_link }, - s_("InProductMarketing|Sometimes you're not ready to make a full transition to a new tool. If you're not ready to fully commit, %{mirroring_link} gives you a safe way to try out GitLab in parallel with your current tool.") % { mirroring_link: mirroring_link } - ][series] - end - - def body_line2 - [ - s_("InProductMarketing|That's all it takes to get going with GitLab, but if you're new to working with Git, check out our %{basics_link} for helpful tips and tricks for getting started.") % { basics_link: basics_link }, - s_("InProductMarketing|Have a different instance you'd like to import? Here's our %{import_link}.") % { import_link: import_link }, - s_("InProductMarketing|It's also possible to simply %{external_repo_link} in order to take advantage of GitLab's CI/CD.") % { external_repo_link: external_repo_link } - ][series] - end - - def cta_text - [ - s_('InProductMarketing|Create your first project!'), - s_('InProductMarketing|Master the art of importing!'), - s_('InProductMarketing|Understand your project options') - ][series] - end - - def invite_members? - user.can?(:admin_group_member, group) - end - - private - - def project_link - link(s_('InProductMarketing|create a project'), help_page_url('user/project/index')) - end - - def repo_link - link(s_('InProductMarketing|set up a repo'), help_page_url('user/project/repository/index', anchor: 'create-a-repository')) - end - - def github_link - link(s_('InProductMarketing|GitHub Enterprise projects to GitLab'), help_page_url('user/project/import/github')) - end - - def bitbucket_link - link(s_('InProductMarketing|from Bitbucket'), help_page_url('user/project/import/bitbucket_server')) - end - - def mirroring_link - link(s_('InProductMarketing|repository mirroring'), help_page_url('user/project/repository/mirror/index')) - end - - def basics_link - link(s_('InProductMarketing|Git basics'), help_page_url('topics/git/index')) - end - - def import_link - link(s_('InProductMarketing|comprehensive guide'), help_page_url('user/project/import/index')) - end - - def external_repo_link - link(s_('InProductMarketing|connect an external repository'), new_project_url(anchor: 'cicd_for_external_repo')) - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/helper.rb b/lib/gitlab/email/message/in_product_marketing/helper.rb index 73d1e0743cc..0770e5f4d76 100644 --- a/lib/gitlab/email/message/in_product_marketing/helper.rb +++ b/lib/gitlab/email/message/in_product_marketing/helper.rb @@ -64,15 +64,6 @@ module Gitlab ] end - def list(array) - case format - when :html - tag.ul { array.map { |item| tag.li item } } - else - '- ' + array.join("\n- ") - end - end - def strong_options case format when :html diff --git a/lib/gitlab/email/message/in_product_marketing/team.rb b/lib/gitlab/email/message/in_product_marketing/team.rb deleted file mode 100644 index ca99dd12c8e..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/team.rb +++ /dev/null @@ -1,84 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class Team < Base - def subject_line - [ - s_('InProductMarketing|Working in GitLab = more efficient'), - s_("InProductMarketing|Multiple owners, confusing workstreams? We've got you covered"), - s_('InProductMarketing|Your teams can be more efficient') - ][series] - end - - def tagline - [ - s_('InProductMarketing|Invite your colleagues to join in less than one minute'), - s_('InProductMarketing|Get your team set up on GitLab'), - nil - ][series] - end - - def title - [ - s_('InProductMarketing|Team work makes the dream work'), - s_('InProductMarketing|*GitLab*, noun: a synonym for efficient teams'), - s_('InProductMarketing|Find out how your teams are really doing') - ][series] - end - - def subtitle - [ - s_('InProductMarketing|Actually, GitLab makes the team work (better)'), - s_('InProductMarketing|Our tool brings all the things together'), - s_("InProductMarketing|It's all in the stats") - ][series] - end - - def body_line1 - [ - [ - s_('InProductMarketing|Did you know teams that use GitLab are far more efficient?'), - list([ - s_('InProductMarketing|Goldman Sachs went from 1 build every two weeks to thousands of builds a day'), - s_('InProductMarketing|Ticketmaster decreased their CI build time by 15X') - ]) - ].join("\n"), - s_("InProductMarketing|We know a thing or two about efficiency and we don't want to keep that to ourselves. Sign up for a free trial of GitLab Ultimate and your teams will be on it from day one."), - [ - s_('InProductMarketing|Stop wondering and use GitLab to answer questions like:'), - list([ - s_('InProductMarketing|How long does it take us to close issues/MRs by types like feature requests, bugs, tech debt, security?'), - s_('InProductMarketing|How many days does it take our team to complete various tasks?'), - s_('InProductMarketing|What does our value stream timeline look like from product to development to review and production?') - ]) - ].join("\n") - ][series] - end - - def body_line2 - [ - s_('InProductMarketing|Invite your colleagues and start shipping code faster.'), - s_("InProductMarketing|Streamline code review, know at a glance who's unavailable, communicate in comments or in email and integrate with Slack so everyone's on the same page."), - s_('InProductMarketing|When your team is on GitLab these answers are a click away.') - ][series] - end - - def cta_text - [ - s_('InProductMarketing|Invite your colleagues today'), - s_('InProductMarketing|Invite your team in less than 60 seconds'), - s_('InProductMarketing|Invite your team now') - ][series] - end - - def progress - super(current: series + 2, total: 4) - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/team_short.rb b/lib/gitlab/email/message/in_product_marketing/team_short.rb deleted file mode 100644 index 1d60a5fe4e5..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/team_short.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class TeamShort < Base - def subject_line - s_('InProductMarketing|Team up in GitLab for greater efficiency') - end - - def tagline - nil - end - - def title - s_('InProductMarketing|Turn coworkers into collaborators') - end - - def subtitle - s_('InProductMarketing|Invite your team today to build better code (and processes) together') - end - - def body_line1 - '' - end - - def body_line2 - '' - end - - def cta_text - s_('InProductMarketing|Invite your colleagues today') - end - - def progress - super(total: 4, track_name: 'Team') - end - - def logo_path - 'mailers/in_product_marketing/team-0.png' - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/trial.rb b/lib/gitlab/email/message/in_product_marketing/trial.rb deleted file mode 100644 index 720262816b4..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/trial.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class Trial < Base - def subject_line - [ - s_('InProductMarketing|Go farther with GitLab'), - s_('InProductMarketing|Automated security scans directly within GitLab'), - s_('InProductMarketing|Take your source code management to the next level') - ][series] - end - - def tagline - [ - s_('InProductMarketing|Start a free trial of GitLab Ultimate – no credit card required'), - s_('InProductMarketing|Improve app security with a 30-day trial'), - s_('InProductMarketing|Start with a GitLab Ultimate free trial') - ][series] - end - - def title - [ - s_('InProductMarketing|Give us one minute...'), - s_("InProductMarketing|Security that's integrated into your development lifecycle"), - s_('InProductMarketing|Improve code quality and streamline reviews') - ][series] - end - - def subtitle - [ - s_('InProductMarketing|...and you can get a free trial of GitLab Ultimate'), - s_('InProductMarketing|Try GitLab Ultimate for free'), - s_('InProductMarketing|Better code in less time') - ][series] - end - - def body_line1 - [ - [ - s_("InProductMarketing|GitLab's premium tiers are designed to make you, your team and your application more efficient and more secure with features including but not limited to:"), - list([ - s_('InProductMarketing|%{strong_start}Company wide portfolio management%{strong_end} — including multi-level epics, scoped labels').html_safe % strong_options, - s_('InProductMarketing|%{strong_start}Multiple approval roles%{strong_end} — including code owners and required merge approvals').html_safe % strong_options, - s_('InProductMarketing|%{strong_start}Advanced application security%{strong_end} — including SAST, DAST scanning, FUZZ testing, dependency scanning, license compliance, secrete detection').html_safe % strong_options, - s_('InProductMarketing|%{strong_start}Executive level insights%{strong_end} — including reporting on productivity, tasks by type, days to completion, value stream').html_safe % strong_options - ]) - ].join("\n"), - s_('InProductMarketing|GitLab provides static application security testing (SAST), dynamic application security testing (DAST), container scanning, and dependency scanning to help you deliver secure applications along with license compliance.'), - s_('InProductMarketing|By enabling code owners and required merge approvals the right person will review the right MR. This is a win-win: cleaner code and a more efficient review process.') - ][series] - end - - def body_line2 - [ - s_('InProductMarketing|Start a GitLab Ultimate trial today in less than one minute, no credit card required.'), - s_('InProductMarketing|Get started today with a 30-day GitLab Ultimate trial, no credit card required.'), - s_('InProductMarketing|Code owners and required merge approvals are part of the paid tiers of GitLab. You can start a free 30-day trial of GitLab Ultimate and enable these features in less than 5 minutes with no credit card required.') - ][series] - end - - def cta_text - [ - s_('InProductMarketing|Start a trial'), - s_('InProductMarketing|Beef up your security'), - s_('InProductMarketing|Start your trial now!') - ][series] - end - - def progress - super(current: series + 2, total: 4) - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/trial_short.rb b/lib/gitlab/email/message/in_product_marketing/trial_short.rb deleted file mode 100644 index 0fcd3fde4a6..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/trial_short.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class TrialShort < Base - def subject_line - s_('InProductMarketing|Be a DevOps hero') - end - - def tagline - nil - end - - def title - s_('InProductMarketing|Expand your DevOps journey with a free GitLab trial') - end - - def subtitle - s_('InProductMarketing|Start your trial today to experience single application success and discover all the features of GitLab Ultimate for free!') - end - - def body_line1 - '' - end - - def body_line2 - '' - end - - def cta_text - s_('InProductMarketing|Start a trial') - end - - def progress - super(total: 4, track_name: 'Trial') - end - - def logo_path - 'mailers/in_product_marketing/trial-0.png' - end - end - end - end - end -end diff --git a/lib/gitlab/email/message/in_product_marketing/verify.rb b/lib/gitlab/email/message/in_product_marketing/verify.rb deleted file mode 100644 index 3982a8b87fd..00000000000 --- a/lib/gitlab/email/message/in_product_marketing/verify.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Email - module Message - module InProductMarketing - class Verify < Base - def subject_line - [ - s_('InProductMarketing|Feel the need for speed?'), - s_('InProductMarketing|3 ways to dive into GitLab CI/CD'), - s_('InProductMarketing|Explore the power of GitLab CI/CD') - ][series] - end - - def tagline - [ - s_('InProductMarketing|Use GitLab CI/CD'), - s_('InProductMarketing|Test, create, deploy'), - s_('InProductMarketing|Are your runners ready?') - ][series] - end - - def title - [ - s_('InProductMarketing|Rapid development, simplified'), - s_('InProductMarketing|Get started with GitLab CI/CD'), - s_('InProductMarketing|Launch GitLab CI/CD in 20 minutes or less') - ][series] - end - - def subtitle - [ - s_('InProductMarketing|How to build and test faster'), - s_('InProductMarketing|Explore the options'), - s_('InProductMarketing|Follow our steps') - ][series] - end - - def body_line1 - [ - s_("InProductMarketing|Tired of wrestling with disparate tool chains, information silos and inefficient processes? GitLab's CI/CD is built on a DevOps platform with source code management, planning, monitoring and more ready to go. Find out %{ci_link}.") % { ci_link: ci_link }, - s_("InProductMarketing|GitLab's CI/CD makes software development easier. Don't believe us? Here are three ways you can take it for a fast (and satisfying) test drive:"), - s_("InProductMarketing|Get going with CI/CD quickly using our %{quick_start_link}. Start with an available runner and then create a CI .yml file – it's really that easy.") % { quick_start_link: quick_start_link } - ][series] - end - - def body_line2 - [ - nil, - list([ - s_('InProductMarketing|Start by %{performance_link}').html_safe % { performance_link: performance_link }, - s_('InProductMarketing|Move on to easily creating a Pages website %{ci_template_link}').html_safe % { ci_template_link: ci_template_link }, - s_('InProductMarketing|And finally %{deploy_link} a Python application.').html_safe % { deploy_link: deploy_link } - ]), - nil - ][series] - end - - def cta_text - [ - s_('InProductMarketing|Get to know GitLab CI/CD'), - s_('InProductMarketing|Try it yourself'), - s_('InProductMarketing|Explore GitLab CI/CD') - ][series] - end - - def invite_members? - user.can?(:admin_group_member, group) - end - - private - - def ci_link - link(s_('InProductMarketing|how easy it is to get started'), help_page_url('ci/index')) - end - - def quick_start_link - link(s_('InProductMarketing|quick start guide'), help_page_url('ci/quick_start/index')) - end - - def performance_link - link(s_('InProductMarketing|testing browser performance'), help_page_url('user/project/merge_requests/browser_performance_testing')) - end - - def ci_template_link - link(s_('InProductMarketing|using a CI/CD template'), help_page_url('user/project/pages/getting_started/pages_ci_cd_template')) - end - - def deploy_link - link(s_('InProductMarketing|test and deploy'), help_page_url('ci/examples/test-and-deploy-python-application-to-heroku')) - end - end - end - end - end -end diff --git a/lib/gitlab/email/service_desk/custom_email.rb b/lib/gitlab/email/service_desk/custom_email.rb new file mode 100644 index 00000000000..30ae435a6ec --- /dev/null +++ b/lib/gitlab/email/service_desk/custom_email.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Gitlab + module Email + module ServiceDesk + # Doesn't include Gitlab::Email::Common because a custom email doesn't + # support all features and methods of ingestable email addresses like + # incoming_email and service_desk_email. + module CustomEmail + class << self + def reply_address(issue, reply_key) + return if reply_key.nil? + + custom_email = issue&.project&.service_desk_setting&.custom_email + return if custom_email.nil? + + # Reply keys for custom email addresses always go before the @. + # We don't have a placeholder. + custom_email.sub('@', "+#{reply_key}@") + end + end + end + end + end +end |