1
0
Fork 0
forked from gitea/nas

Add: #586 保留中のリモートアカウントからのフォローが飛んできた場合に記録する (#590)

* Add: #586 保留中のリモートアカウントからのフォローが飛んできた場合に記録する

* 本家に戻す処理を修正

* Fix test

* Fix worker link

* Fix test

* リモートアカウント拒否時に既存のリクエストを削除
This commit is contained in:
KMY(雪あすか) 2024-02-18 10:48:48 +09:00 committed by GitHub
parent 1b3c0e3fb7
commit dfc9f35d71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 262 additions and 31 deletions

View file

@ -300,10 +300,13 @@ class Account < ApplicationRecord
def approve_remote!
update!(remote_pending: false)
unsuspend!
EnableFollowRequestsWorker.perform_async(id)
end
def reject_remote!
update!(remote_pending: false, suspension_origin: :local)
pending_follow_requests.destroy_all
suspend!
end
def sensitized?

View file

@ -74,6 +74,7 @@ module Account::Interactions
included do
# Follow relations
has_many :follow_requests, dependent: :destroy
has_many :pending_follow_requests, dependent: :destroy
with_options class_name: 'Follow', dependent: :destroy do
has_many :active_relationships, foreign_key: 'account_id', inverse_of: :account

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: pending_follow_requests
#
# id :bigint(8) not null, primary key
# account_id :bigint(8) not null
# target_account_id :bigint(8) not null
# uri :string not null
# created_at :datetime not null
# updated_at :datetime not null
#
class PendingFollowRequest < ApplicationRecord
belongs_to :account
belongs_to :target_account, class_name: 'Account'
validates :account_id, uniqueness: { scope: :target_account_id }
end