Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/jira_connect_installation.rb')
-rw-r--r--app/models/jira_connect_installation.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/jira_connect_installation.rb b/app/models/jira_connect_installation.rb
new file mode 100644
index 00000000000..7480800abc3
--- /dev/null
+++ b/app/models/jira_connect_installation.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class JiraConnectInstallation < ApplicationRecord
+ attr_encrypted :shared_secret,
+ mode: :per_attribute_iv,
+ algorithm: 'aes-256-gcm',
+ key: Settings.attr_encrypted_db_key_base_32
+
+ has_many :subscriptions, class_name: 'JiraConnectSubscription'
+
+ validates :client_key, presence: true, uniqueness: true
+ validates :shared_secret, presence: true
+ validates :base_url, presence: true, public_url: true
+
+ scope :for_project, -> (project) {
+ distinct
+ .joins(:subscriptions)
+ .where(jira_connect_subscriptions: {
+ id: JiraConnectSubscription.for_project(project)
+ })
+ }
+end