diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/concerns/account_associations.rb | 3 | ||||
-rw-r--r-- | app/models/queued_boost.rb | 17 | ||||
-rw-r--r-- | app/models/status.rb | 2 | ||||
-rw-r--r-- | app/models/user.rb | 26 |
4 files changed, 45 insertions, 3 deletions
diff --git a/app/models/concerns/account_associations.rb b/app/models/concerns/account_associations.rb index 0c3725e54..a90104943 100644 --- a/app/models/concerns/account_associations.rb +++ b/app/models/concerns/account_associations.rb @@ -58,5 +58,8 @@ module AccountAssociations # Hashtags has_and_belongs_to_many :tags has_many :featured_tags, -> { includes(:tag) }, dependent: :destroy, inverse_of: :account + + # queued boosts + has_many :queued_boosts, dependent: :destroy, inverse_of: :account end end diff --git a/app/models/queued_boost.rb b/app/models/queued_boost.rb new file mode 100644 index 000000000..b23282697 --- /dev/null +++ b/app/models/queued_boost.rb @@ -0,0 +1,17 @@ +# == Schema Information +# +# Table name: queued_boosts +# +# id :bigint(8) not null, primary key +# account_id :bigint(8) +# status_id :bigint(8) +# created_at :datetime not null +# updated_at :datetime not null +# + +class QueuedBoost < ApplicationRecord + belongs_to :account, inverse_of: :queued_boosts + belongs_to :status, inverse_of: :queued_boosts + + validates :account_id, uniqueness: { scope: :status_id } +end diff --git a/app/models/status.rb b/app/models/status.rb index 9f11e6d5d..a2d64ecf0 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -76,6 +76,8 @@ class Status < ApplicationRecord has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status has_many :media_attachments, dependent: :nullify + has_many :queued_boosts, dependent: :destroy, inverse_of: :status + has_and_belongs_to_many :tags has_and_belongs_to_many :preview_cards diff --git a/app/models/user.rb b/app/models/user.rb index 479392642..a0786aa69 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -131,6 +131,10 @@ class User < ApplicationRecord :roar_lifespan, :delayed_roars, :delayed_for, + :boost_interval, + :boost_random, + :boost_interval_from, + :boost_interval_to, :show_cursor, :auto_play_gif, @@ -303,11 +307,11 @@ class User < ApplicationRecord end def max_public_history - @_max_public_history ||= (settings.max_public_history || 6) + @_max_public_history ||= [1, (settings.max_public_history || 6).to_i].max end def roar_lifespan - @_roar_lifespan ||= (settings.roar_lifespan || 0) + @_roar_lifespan ||= [0, (settings.roar_lifespan || 0).to_i].max end def delayed_roars? @@ -315,7 +319,23 @@ class User < ApplicationRecord end def delayed_for - @_delayed_for ||= (settings.delayed_for || 60) + @_delayed_for ||= [5, (settings.delayed_for || 60).to_i].max + end + + def boost_interval? + @boost_interval ||= (settings.boost_interval || false) + end + + def boost_random? + @boost_random ||= (settings.boost_random || false) + end + + def boost_interval_from + @boost_interval_from ||= [1, (settings.boost_interval_from || 1).to_i].max + end + + def boost_interval_to + @boost_interval_to ||= [2, (settings.boost_interval_to || 15).to_i].max end def shows_cursor? |