diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 13:34:06 +0300 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /app/models/user_status.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'app/models/user_status.rb')
-rw-r--r-- | app/models/user_status.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/user_status.rb b/app/models/user_status.rb index 0e1ae0b7338..1c8634e47c3 100644 --- a/app/models/user_status.rb +++ b/app/models/user_status.rb @@ -7,6 +7,16 @@ class UserStatus < ApplicationRecord DEFAULT_EMOJI = 'speech_balloon' + CLEAR_STATUS_QUICK_OPTIONS = { + '30_minutes' => 30.minutes, + '3_hours' => 3.hours, + '8_hours' => 8.hours, + '1_day' => 1.day, + '3_days' => 3.days, + '7_days' => 7.days, + '30_days' => 30.days + }.freeze + belongs_to :user enum availability: { not_set: 0, busy: 1 } @@ -15,5 +25,11 @@ class UserStatus < ApplicationRecord validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names } validates :message, length: { maximum: 100 }, allow_blank: true + scope :scheduled_for_cleanup, -> { where(arel_table[:clear_status_at].lteq(Time.current)) } + cache_markdown_field :message, pipeline: :emoji + + def clear_status_after=(value) + self.clear_status_at = CLEAR_STATUS_QUICK_OPTIONS[value]&.from_now + end end |