* Add: テーブル定義、内部処理 * Add: 通知の定期削除処理、自動削除、テスト * Add: Web画面の表示、設定 * Fix test
This commit is contained in:
parent
2cc60253c4
commit
f8280ca5d9
27 changed files with 300 additions and 9 deletions
|
@ -11,6 +11,7 @@
|
|||
# updated_at :datetime not null
|
||||
# replies_policy :integer default("list"), not null
|
||||
# exclusive :boolean default(FALSE), not null
|
||||
# notify :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class List < ApplicationRecord
|
||||
|
@ -25,6 +26,8 @@ class List < ApplicationRecord
|
|||
has_many :list_accounts, inverse_of: :list, dependent: :destroy
|
||||
has_many :accounts, through: :list_accounts
|
||||
has_many :antennas, inverse_of: :list, dependent: :destroy
|
||||
has_many :list_statuses, inverse_of: :list, dependent: :destroy
|
||||
has_many :statuses, through: :list_statuses
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
|
|
21
app/models/list_status.rb
Normal file
21
app/models/list_status.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: list_statuses
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# list_id :bigint(8) not null
|
||||
# status_id :bigint(8) not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class ListStatus < ApplicationRecord
|
||||
belongs_to :list
|
||||
belongs_to :status
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :status, uniqueness: { scope: :list }
|
||||
end
|
|
@ -22,6 +22,7 @@ class Notification < ApplicationRecord
|
|||
LEGACY_TYPE_CLASS_MAP = {
|
||||
'Mention' => :mention,
|
||||
'Status' => :reblog,
|
||||
'ListStatus' => :list_status,
|
||||
'Follow' => :follow,
|
||||
'FollowRequest' => :follow_request,
|
||||
'Favourite' => :favourite,
|
||||
|
@ -34,6 +35,7 @@ class Notification < ApplicationRecord
|
|||
TYPES = %i(
|
||||
mention
|
||||
status
|
||||
list_status
|
||||
reblog
|
||||
status_reference
|
||||
follow
|
||||
|
@ -50,6 +52,7 @@ class Notification < ApplicationRecord
|
|||
|
||||
TARGET_STATUS_INCLUDES_BY_TYPE = {
|
||||
status: :status,
|
||||
list_status: [list_status: :status],
|
||||
reblog: [status: :reblog],
|
||||
status_reference: [status_reference: :status],
|
||||
mention: [mention: :status],
|
||||
|
@ -68,6 +71,7 @@ class Notification < ApplicationRecord
|
|||
with_options foreign_key: 'activity_id', optional: true do
|
||||
belongs_to :mention, inverse_of: :notification
|
||||
belongs_to :status, inverse_of: :notification
|
||||
belongs_to :list_status, inverse_of: :notification
|
||||
belongs_to :follow, inverse_of: :notification
|
||||
belongs_to :follow_request, inverse_of: :notification
|
||||
belongs_to :favourite, inverse_of: :notification
|
||||
|
@ -90,6 +94,8 @@ class Notification < ApplicationRecord
|
|||
case type
|
||||
when :status, :update
|
||||
status
|
||||
when :list_status
|
||||
list_status&.status
|
||||
when :reblog
|
||||
status&.reblog
|
||||
when :status_reference
|
||||
|
@ -143,6 +149,8 @@ class Notification < ApplicationRecord
|
|||
case notification.type
|
||||
when :status, :update
|
||||
notification.status = cached_status
|
||||
when :list_status
|
||||
notification.list_status.status = cached_status
|
||||
when :reblog
|
||||
notification.status.reblog = cached_status
|
||||
when :status_reference
|
||||
|
@ -182,7 +190,7 @@ class Notification < ApplicationRecord
|
|||
case activity_type
|
||||
when 'Status', 'Follow', 'Favourite', 'EmojiReaction', 'EmojiReact', 'FollowRequest', 'Poll', 'Report', 'AccountWarning'
|
||||
self.from_account_id = activity&.account_id
|
||||
when 'Mention', 'StatusReference'
|
||||
when 'Mention', 'StatusReference', 'ListStatus'
|
||||
self.from_account_id = activity&.status&.account_id
|
||||
when 'Account'
|
||||
self.from_account_id = activity&.id
|
||||
|
|
|
@ -111,6 +111,7 @@ class Status < ApplicationRecord
|
|||
has_one :trend, class_name: 'StatusTrend', inverse_of: :status
|
||||
has_one :scheduled_expiration_status, inverse_of: :status, dependent: :destroy
|
||||
has_one :circle_status, inverse_of: :status, dependent: :destroy
|
||||
has_many :list_status, inverse_of: :status, dependent: :destroy
|
||||
|
||||
validates :uri, uniqueness: true, presence: true, unless: :local?
|
||||
validates :text, presence: true, unless: -> { with_media? || reblog? }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue