diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 19672b2a28f..e8551748d66 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -135,7 +135,7 @@ class User < ActiveRecord::Base has_many :custom_attributes, class_name: 'UserCustomAttribute' has_many :pipeline_subscriptions, class_name: 'Ci::PipelineSubscription' - has_many :subscribed_pipelines, through: :pipeline_subscriptions, class_name: 'Ci::Pipeline', source: :pipeline + has_many :subscribed_pipelines, through: :pipeline_subscriptions, class_name: 'Ci::Pipeline', source: :pipeline, foreign_key: 'ci_pipeline_id' # # Validations @@ -168,7 +168,6 @@ class User < ActiveRecord::Base validates :webpush_p256dh, uniqueness: true, allow_nil: true validates :webpush_auth, uniqueness: true, allow_nil: true validates :webpush_endpoint, uniqueness: true, allow_nil: true - before_validation :sanitize_attrs before_validation :set_notification_email, if: :email_changed? @@ -1188,6 +1187,10 @@ class User < ActiveRecord::Base max_member_access_for_group_ids([group_id])[group_id] end + def is_subscribed?(pipeline) + subscribed_pipelines.exists?(pipeline.id) + end + protected # override, from Devise::Validatable |