Change: 単方向の承認だけでフレンドサーバーが有効になるようにする (#74)
* Test: テストを先に作成 * Fix: テスト不備 * Wip: フレンドサーバーのテストを修正 * Wip: エラーを修正 * 項目のラベリングを修正 * 新しい設定が変更できないのを修正 * Wip: 削除時の処理を修正 * フレンド自動承認設定を削除 * Fix: 申請を受けたドメインのINBOXが空になる問題 * Change: #75 フレンドでないサーバーからのローカル公開を未収載に変換 (#77)
This commit is contained in:
parent
521932c802
commit
1eb2d78b5d
24 changed files with 314 additions and 126 deletions
|
@ -35,7 +35,7 @@ module Admin
|
||||||
def update
|
def update
|
||||||
authorize :friend_server, :update?
|
authorize :friend_server, :update?
|
||||||
|
|
||||||
if @friend.update(resource_params)
|
if @friend.update(update_resource_params)
|
||||||
redirect_to admin_friend_servers_path
|
redirect_to admin_friend_servers_path
|
||||||
else
|
else
|
||||||
render action: :edit
|
render action: :edit
|
||||||
|
@ -79,7 +79,11 @@ module Admin
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_params
|
def resource_params
|
||||||
params.require(:friend_domain).permit(:domain, :inbox_url, :available, :pseudo_relay, :unlocked, :allow_all_posts)
|
params.require(:friend_domain).permit(:domain, :inbox_url, :available, :pseudo_relay, :delivery_local, :unlocked, :allow_all_posts)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update_resource_params
|
||||||
|
params.require(:friend_domain).permit(:inbox_url, :available, :pseudo_relay, :delivery_local, :unlocked, :allow_all_posts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def warn_signatures_not_enabled!
|
def warn_signatures_not_enabled!
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def accept_follow_for_friend
|
def accept_follow_for_friend
|
||||||
friend.update!(active_state: :accepted)
|
friend.update!(active_state: :accepted, passive_state: :idle)
|
||||||
end
|
end
|
||||||
|
|
||||||
def friend
|
def friend
|
||||||
|
|
|
@ -114,7 +114,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_status_params
|
def process_status_params
|
||||||
@status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object, account: @account)
|
@status_parser = ActivityPub::Parser::StatusParser.new(@json, followers_collection: @account.followers_url, object: @object, account: @account, friend_domain: friend_domain?)
|
||||||
|
|
||||||
@params = {
|
@params = {
|
||||||
uri: @status_parser.uri,
|
uri: @status_parser.uri,
|
||||||
|
@ -506,6 +506,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
FriendDomain.free_receivings.exists?(domain: @account.domain)
|
FriendDomain.free_receivings.exists?(domain: @account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def friend_domain?
|
||||||
|
FriendDomain.enabled.find_by(domain: @account.domain)&.accepted?
|
||||||
|
end
|
||||||
|
|
||||||
def quote
|
def quote
|
||||||
@quote ||= @object['quote'] || @object['quoteUrl'] || @object['quoteURL'] || @object['_misskey_quote']
|
@quote ||= @object['quote'] || @object['quoteUrl'] || @object['quoteURL'] || @object['_misskey_quote']
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,16 +49,20 @@ class ActivityPub::Activity::Follow < ActivityPub::Activity
|
||||||
already_accepted = false
|
already_accepted = false
|
||||||
|
|
||||||
if friend.present?
|
if friend.present?
|
||||||
already_accepted = friend.they_are_accepted?
|
already_accepted = friend.accepted?
|
||||||
friend.update!(passive_state: :pending, passive_follow_activity_id: @json['id'])
|
friend.update!(passive_state: :pending, active_state: :idle, passive_follow_activity_id: @json['id'])
|
||||||
else
|
else
|
||||||
@friend = FriendDomain.create!(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id'])
|
@friend = FriendDomain.new(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id'])
|
||||||
|
@friend.initialize_inbox_url!
|
||||||
|
@friend.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
if already_accepted || friend.unlocked || Setting.unlocked_friend
|
if already_accepted || Setting.unlocked_friend
|
||||||
friend.accept!
|
friend.accept!
|
||||||
else
|
|
||||||
# Notify for admin even if unlocked
|
# Notify for admin even if unlocked
|
||||||
|
notify_staff_about_pending_friend_server! unless already_accepted
|
||||||
|
else
|
||||||
notify_staff_about_pending_friend_server!
|
notify_staff_about_pending_friend_server!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ActivityPub::Activity::Reject < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def reject_follow_for_friend
|
def reject_follow_for_friend
|
||||||
friend.update!(active_state: :rejected)
|
friend.update!(active_state: :rejected, passive_state: :idle)
|
||||||
end
|
end
|
||||||
|
|
||||||
def friend
|
def friend
|
||||||
|
|
|
@ -103,7 +103,7 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_follow_from_friend
|
def remove_follow_from_friend
|
||||||
friend.update!(passive_state: :idle, passive_follow_activity_id: nil)
|
friend.destroy_without_signal!
|
||||||
end
|
end
|
||||||
|
|
||||||
def friend
|
def friend
|
||||||
|
|
|
@ -11,6 +11,7 @@ class ActivityPub::Parser::StatusParser
|
||||||
@object = magic_values[:object] || json['object'] || json
|
@object = magic_values[:object] || json['object'] || json
|
||||||
@magic_values = magic_values
|
@magic_values = magic_values
|
||||||
@account = magic_values[:account]
|
@account = magic_values[:account]
|
||||||
|
@friend = magic_values[:friend_domain]
|
||||||
end
|
end
|
||||||
|
|
||||||
def uri
|
def uri
|
||||||
|
@ -76,7 +77,7 @@ class ActivityPub::Parser::StatusParser
|
||||||
def visibility
|
def visibility
|
||||||
if audience_to.any? { |to| ActivityPub::TagManager.instance.public_collection?(to) }
|
if audience_to.any? { |to| ActivityPub::TagManager.instance.public_collection?(to) }
|
||||||
:public
|
:public
|
||||||
elsif audience_to.include?('LocalPublic')
|
elsif audience_to.include?('LocalPublic') && @friend
|
||||||
:public_unlisted
|
:public_unlisted
|
||||||
elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) }
|
elsif audience_cc.any? { |cc| ActivityPub::TagManager.instance.public_collection?(cc) }
|
||||||
:unlisted
|
:unlisted
|
||||||
|
@ -200,7 +201,7 @@ class ActivityPub::Parser::StatusParser
|
||||||
:public
|
:public
|
||||||
elsif audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
elsif audience_searchable_by.include?('kmyblue:Limited') || audience_searchable_by.include?('as:Limited')
|
||||||
:limited
|
:limited
|
||||||
elsif audience_searchable_by.include?('LocalPublic')
|
elsif audience_searchable_by.include?('LocalPublic') && @friend
|
||||||
:public_unlisted
|
:public_unlisted
|
||||||
elsif audience_searchable_by.include?(@account.followers_url)
|
elsif audience_searchable_by.include?(@account.followers_url)
|
||||||
:private
|
:private
|
||||||
|
|
|
@ -10,7 +10,7 @@ class StatusReachFinder
|
||||||
end
|
end
|
||||||
|
|
||||||
def inboxes
|
def inboxes
|
||||||
(reached_account_inboxes + followers_inboxes + relay_inboxes).uniq
|
(reached_account_inboxes + followers_inboxes + relay_inboxes + nolocal_friend_inboxes).uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
def inboxes_for_misskey
|
def inboxes_for_misskey
|
||||||
|
@ -147,7 +147,15 @@ class StatusReachFinder
|
||||||
|
|
||||||
def friend_inboxes
|
def friend_inboxes
|
||||||
if @status.public_visibility? || @status.public_unlisted_visibility? || (@status.unlisted_visibility? && (@status.public_searchability? || @status.public_unlisted_searchability?))
|
if @status.public_visibility? || @status.public_unlisted_visibility? || (@status.unlisted_visibility? && (@status.public_searchability? || @status.public_unlisted_searchability?))
|
||||||
DeliveryFailureTracker.without_unavailable(FriendDomain.distributables.pluck(:inbox_url))
|
DeliveryFailureTracker.without_unavailable(FriendDomain.distributables.where(delivery_local: true).pluck(:inbox_url))
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def nolocal_friend_inboxes
|
||||||
|
if @status.public_visibility?
|
||||||
|
DeliveryFailureTracker.without_unavailable(FriendDomain.distributables.where(delivery_local: false).pluck(:inbox_url))
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
# passive_follow_activity_id :string
|
# passive_follow_activity_id :string
|
||||||
# available :boolean default(TRUE), not null
|
# available :boolean default(TRUE), not null
|
||||||
# pseudo_relay :boolean default(FALSE), not null
|
# pseudo_relay :boolean default(FALSE), not null
|
||||||
# unlocked :boolean default(FALSE), not null
|
|
||||||
# allow_all_posts :boolean default(TRUE), not null
|
# allow_all_posts :boolean default(TRUE), not null
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
|
# delivery_local :boolean default(TRUE), not null
|
||||||
#
|
#
|
||||||
|
|
||||||
class FriendDomain < ApplicationRecord
|
class FriendDomain < ApplicationRecord
|
||||||
|
@ -27,24 +27,31 @@ class FriendDomain < ApplicationRecord
|
||||||
enum passive_state: { idle: 0, pending: 1, accepted: 2, rejected: 3 }, _prefix: :they_are
|
enum passive_state: { idle: 0, pending: 1, accepted: 2, rejected: 3 }, _prefix: :they_are
|
||||||
|
|
||||||
scope :by_domain_and_subdomains, ->(domain) { where(domain: Instance.by_domain_and_subdomains(domain).select(:domain)) }
|
scope :by_domain_and_subdomains, ->(domain) { where(domain: Instance.by_domain_and_subdomains(domain).select(:domain)) }
|
||||||
scope :enabled, -> { where(available: true) }
|
scope :enabled, -> { where(active_state: :accepted).or(FriendDomain.where(passive_state: :accepted)).where(available: true) }
|
||||||
scope :mutuals, -> { enabled.where(active_state: :accepted, passive_state: :accepted) }
|
scope :distributables, -> { enabled.where(pseudo_relay: true) }
|
||||||
scope :distributables, -> { mutuals.where(pseudo_relay: true) }
|
scope :deliver_locals, -> { enabled.where(delivery_local: true) }
|
||||||
scope :deliver_locals, -> { enabled.where(active_state: :accepted) }
|
scope :free_receivings, -> { enabled.where(allow_all_posts: true) }
|
||||||
scope :free_receivings, -> { mutuals.where(allow_all_posts: true) }
|
|
||||||
|
|
||||||
before_destroy :ensure_disabled
|
before_destroy :ensure_disabled
|
||||||
after_commit :set_default_inbox_url
|
after_commit :set_default_inbox_url
|
||||||
|
|
||||||
def mutual?
|
def accepted?
|
||||||
i_am_accepted? && they_are_accepted?
|
i_am_accepted? || they_are_accepted?
|
||||||
|
end
|
||||||
|
|
||||||
|
def pending?
|
||||||
|
!accepted? && (i_am_pending? || they_are_pending?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def idle?
|
||||||
|
(i_am_idle? || i_am_rejected?) && (they_are_idle? || they_are_rejected?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def follow!
|
def follow!
|
||||||
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
||||||
payload = Oj.dump(follow_activity(activity_id))
|
payload = Oj.dump(follow_activity(activity_id))
|
||||||
|
|
||||||
update!(active_state: :pending, active_follow_activity_id: activity_id)
|
update!(active_state: :pending, passive_state: :idle, active_follow_activity_id: activity_id)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
DeliveryFailureTracker.reset!(inbox_url)
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
@ -53,7 +60,7 @@ class FriendDomain < ApplicationRecord
|
||||||
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
activity_id = ActivityPub::TagManager.instance.generate_uri_for(nil)
|
||||||
payload = Oj.dump(unfollow_activity(activity_id))
|
payload = Oj.dump(unfollow_activity(activity_id))
|
||||||
|
|
||||||
update!(active_state: :idle, active_follow_activity_id: nil)
|
update!(active_state: :idle, passive_state: :idle, active_follow_activity_id: nil)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
DeliveryFailureTracker.reset!(inbox_url)
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
@ -64,7 +71,7 @@ class FriendDomain < ApplicationRecord
|
||||||
activity_id = passive_follow_activity_id
|
activity_id = passive_follow_activity_id
|
||||||
payload = Oj.dump(accept_follow_activity(activity_id))
|
payload = Oj.dump(accept_follow_activity(activity_id))
|
||||||
|
|
||||||
update!(passive_state: :accepted)
|
update!(passive_state: :accepted, active_state: :idle)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
DeliveryFailureTracker.reset!(inbox_url)
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
@ -75,11 +82,21 @@ class FriendDomain < ApplicationRecord
|
||||||
activity_id = passive_follow_activity_id
|
activity_id = passive_follow_activity_id
|
||||||
payload = Oj.dump(reject_follow_activity(activity_id))
|
payload = Oj.dump(reject_follow_activity(activity_id))
|
||||||
|
|
||||||
update!(passive_state: :rejected, passive_follow_activity_id: nil)
|
update!(passive_state: :rejected, active_state: :idle, passive_follow_activity_id: nil)
|
||||||
DeliveryFailureTracker.reset!(inbox_url)
|
DeliveryFailureTracker.reset!(inbox_url)
|
||||||
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
ActivityPub::DeliveryWorker.perform_async(payload, some_local_account.id, inbox_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy_without_signal!
|
||||||
|
self.active_state = :idle
|
||||||
|
self.passive_state = :idle
|
||||||
|
destroy!
|
||||||
|
end
|
||||||
|
|
||||||
|
def initialize_inbox_url!
|
||||||
|
self.inbox_url = default_inbox_url
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def default_inbox_url
|
def default_inbox_url
|
||||||
|
@ -154,7 +171,7 @@ class FriendDomain < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_disabled
|
def ensure_disabled
|
||||||
delete_for_friend! unless i_am_idle? && they_are_idle?
|
delete_for_friend! unless id.nil? || (i_am_idle? && they_are_idle?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_default_inbox_url
|
def set_default_inbox_url
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
= t 'admin.friend_servers.disabled'
|
= t 'admin.friend_servers.disabled'
|
||||||
%samp= friend.domain
|
%samp= friend.domain
|
||||||
%td
|
%td
|
||||||
- if friend.i_am_accepted?
|
- if friend.accepted?
|
||||||
%span.positive-hint
|
%span.positive-hint
|
||||||
= fa_icon('check')
|
= fa_icon('check')
|
||||||
= ' '
|
= ' '
|
||||||
|
@ -16,21 +16,11 @@
|
||||||
= fa_icon('hourglass')
|
= fa_icon('hourglass')
|
||||||
= ' '
|
= ' '
|
||||||
= t 'admin.friend_servers.pending'
|
= t 'admin.friend_servers.pending'
|
||||||
- else
|
|
||||||
%span.negative-hint
|
|
||||||
= fa_icon('times')
|
|
||||||
= ' '
|
|
||||||
= t 'admin.friend_servers.disabled'
|
|
||||||
%td
|
|
||||||
- if friend.they_are_accepted?
|
|
||||||
%span.positive-hint
|
|
||||||
= fa_icon('check')
|
|
||||||
= ' '
|
|
||||||
= t 'admin.friend_servers.enabled'
|
|
||||||
- elsif friend.they_are_pending?
|
- elsif friend.they_are_pending?
|
||||||
= fa_icon('hourglass')
|
%span.warning-hint
|
||||||
= ' '
|
= fa_icon('hourglass')
|
||||||
= t 'admin.friend_servers.pending'
|
= ' '
|
||||||
|
= t 'admin.friend_servers.pending_you'
|
||||||
- else
|
- else
|
||||||
%span.negative-hint
|
%span.negative-hint
|
||||||
= fa_icon('times')
|
= fa_icon('times')
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :available, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.available')
|
= f.input :available, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.available')
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= f.input :delivery_local, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.delivery_local'), hint: t('admin.friend_servers.edit.delivery_local_hint')
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :pseudo_relay, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.pseudo_relay'), hint: t('admin.friend_servers.edit.pseudo_relay_hint')
|
= f.input :pseudo_relay, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.pseudo_relay'), hint: t('admin.friend_servers.edit.pseudo_relay_hint')
|
||||||
|
|
||||||
.fields-group
|
|
||||||
= f.input :unlocked, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.unlocked')
|
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
= f.input :allow_all_posts, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.allow_all_posts'), hint: t('admin.friend_servers.edit.allow_all_posts_hint')
|
= f.input :allow_all_posts, as: :boolean, wrapper: :with_label, label: t('admin.friend_servers.edit.allow_all_posts'), hint: t('admin.friend_servers.edit.allow_all_posts_hint')
|
||||||
|
|
|
@ -6,35 +6,14 @@
|
||||||
= render 'friend_fields', f: f, friend: @friend
|
= render 'friend_fields', f: f, friend: @friend
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
%h4= t('admin.friend_servers.active_status')
|
%h4= t('admin.friend_servers.status')
|
||||||
.fields-group
|
.fields-group
|
||||||
- if @friend.i_am_accepted?
|
- if @friend.accepted?
|
||||||
%span.positive-hint
|
%span.positive-hint
|
||||||
= fa_icon('check')
|
= fa_icon('check')
|
||||||
= ' '
|
= ' '
|
||||||
= t 'admin.friend_servers.enabled'
|
= t 'admin.friend_servers.enabled'
|
||||||
- elsif @friend.i_am_pending?
|
- elsif @friend.pending?
|
||||||
= fa_icon('hourglass')
|
|
||||||
= ' '
|
|
||||||
= t 'admin.friend_servers.pending'
|
|
||||||
- else
|
|
||||||
%span.negative-hint
|
|
||||||
= fa_icon('times')
|
|
||||||
= ' '
|
|
||||||
= t 'admin.friend_servers.disabled'
|
|
||||||
.action-buttons
|
|
||||||
%div
|
|
||||||
= link_to t('admin.friend_servers.follow'), follow_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.i_am_idle? || @friend.i_am_rejected?
|
|
||||||
= link_to t('admin.friend_servers.unfollow'), unfollow_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.i_am_pending? || @friend.i_am_accepted?
|
|
||||||
|
|
||||||
%h4= t('admin.friend_servers.passive_status')
|
|
||||||
.fields-gtoup
|
|
||||||
- if @friend.they_are_accepted?
|
|
||||||
%span.positive-hint
|
|
||||||
= fa_icon('check')
|
|
||||||
= ' '
|
|
||||||
= t 'admin.friend_servers.enabled'
|
|
||||||
- elsif @friend.they_are_pending?
|
|
||||||
= fa_icon('hourglass')
|
= fa_icon('hourglass')
|
||||||
= ' '
|
= ' '
|
||||||
= t 'admin.friend_servers.pending'
|
= t 'admin.friend_servers.pending'
|
||||||
|
@ -45,6 +24,7 @@
|
||||||
= t 'admin.friend_servers.disabled'
|
= t 'admin.friend_servers.disabled'
|
||||||
.action-buttons
|
.action-buttons
|
||||||
%div
|
%div
|
||||||
|
= link_to t('admin.friend_servers.follow'), follow_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.idle?
|
||||||
= link_to t('admin.friend_servers.accept'), accept_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.they_are_pending?
|
= link_to t('admin.friend_servers.accept'), accept_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.they_are_pending?
|
||||||
= link_to t('admin.friend_servers.reject'), reject_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.they_are_pending?
|
= link_to t('admin.friend_servers.reject'), reject_admin_friend_server_path(@friend), class: 'button', method: :post, data: { confirm: t('admin.accounts.are_you_sure') } if @friend.they_are_pending?
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th= t('admin.friend_servers.domain')
|
%th= t('admin.friend_servers.domain')
|
||||||
%th= t('admin.friend_servers.active_status')
|
%th= t('admin.friend_servers.status')
|
||||||
%th= t('admin.friend_servers.passive_status')
|
|
||||||
%th
|
%th
|
||||||
%tbody
|
%tbody
|
||||||
- @friends.each do |friend|
|
- @friends.each do |friend|
|
||||||
|
|
|
@ -501,7 +501,6 @@ en:
|
||||||
unsuppress: Restore follow recommendation
|
unsuppress: Restore follow recommendation
|
||||||
friend_servers:
|
friend_servers:
|
||||||
accept: Accept
|
accept: Accept
|
||||||
active_status: My status
|
|
||||||
add_new: Add and make a new application
|
add_new: Add and make a new application
|
||||||
delete: Delete
|
delete: Delete
|
||||||
description_html: <strong>フレンドサーバー</strong>とは、お互いのローカル公開・ローカル検索許可の投稿をそのまま交換するシステムです。
|
description_html: <strong>フレンドサーバー</strong>とは、お互いのローカル公開・ローカル検索許可の投稿をそのまま交換するシステムです。
|
||||||
|
@ -511,6 +510,8 @@ en:
|
||||||
allow_all_posts: Receive all posts
|
allow_all_posts: Receive all posts
|
||||||
allow_all_posts_hint: 通常は自分のサーバーの誰もフォローしていないアカウントの投稿は例外を除き受け入れがブロックされます。そのブロックを解除します。スパムが発生した場合など、いつでもブロックを再開できます。
|
allow_all_posts_hint: 通常は自分のサーバーの誰もフォローしていないアカウントの投稿は例外を除き受け入れがブロックされます。そのブロックを解除します。スパムが発生した場合など、いつでもブロックを再開できます。
|
||||||
available: Available
|
available: Available
|
||||||
|
delivery_local: Deliver without changing public unlisted visibility and searchability
|
||||||
|
delivery_local_hint: Public unlisted posts will be added the friend's global timeline
|
||||||
description: フレンドサーバーは、登録と同時に相手方のサーバーへ申請されます。
|
description: フレンドサーバーは、登録と同時に相手方のサーバーへ申請されます。
|
||||||
domain: Domain
|
domain: Domain
|
||||||
inbox_url: Friend server inbox URL
|
inbox_url: Friend server inbox URL
|
||||||
|
@ -521,8 +522,8 @@ en:
|
||||||
edit_friend: Edit
|
edit_friend: Edit
|
||||||
enabled: Enabled
|
enabled: Enabled
|
||||||
follow: Request
|
follow: Request
|
||||||
passive_status: Partner status
|
|
||||||
pending: Pending
|
pending: Pending
|
||||||
|
pending_you: Your review requested
|
||||||
reject: Reject
|
reject: Reject
|
||||||
save_and_enable: Save and enable
|
save_and_enable: Save and enable
|
||||||
setup: Add and make a new application
|
setup: Add and make a new application
|
||||||
|
|
|
@ -496,7 +496,6 @@ ja:
|
||||||
unsuppress: おすすめフォローを復元
|
unsuppress: おすすめフォローを復元
|
||||||
friend_servers:
|
friend_servers:
|
||||||
accept: 相手の申請を承認する
|
accept: 相手の申請を承認する
|
||||||
active_status: 自分の状態
|
|
||||||
add_new: フレンドサーバーを追加・申請
|
add_new: フレンドサーバーを追加・申請
|
||||||
delete: 削除
|
delete: 削除
|
||||||
description_html: <strong>フレンドサーバー</strong>とは、お互いのローカル公開・ローカル検索許可の投稿をそのまま交換するシステムです。
|
description_html: <strong>フレンドサーバー</strong>とは、お互いのローカル公開・ローカル検索許可の投稿をそのまま交換するシステムです。
|
||||||
|
@ -506,6 +505,8 @@ ja:
|
||||||
allow_all_posts: このサーバーからの投稿を無条件で受け入れる
|
allow_all_posts: このサーバーからの投稿を無条件で受け入れる
|
||||||
allow_all_posts_hint: 通常は自分のサーバーの誰もフォローしていないアカウントの投稿は例外を除き受け入れがブロックされます。そのブロックを解除します。スパムが発生した場合など、いつでもブロックを再開できます。
|
allow_all_posts_hint: 通常は自分のサーバーの誰もフォローしていないアカウントの投稿は例外を除き受け入れがブロックされます。そのブロックを解除します。スパムが発生した場合など、いつでもブロックを再開できます。
|
||||||
available: 有効にする
|
available: 有効にする
|
||||||
|
delivery_local: ローカル公開の公開範囲・検索許可を持った投稿をそのまま相手と共有する
|
||||||
|
delivery_local_hint: ローカル公開投稿は、通常は非収載に変換されて配送されます。その処理をせず、相手サーバーにもローカル公開と認識されるようにします。相手の連合タイムラインに掲載されます
|
||||||
description: フレンドサーバーは、登録と同時に相手方のサーバーへ申請されます。
|
description: フレンドサーバーは、登録と同時に相手方のサーバーへ申請されます。
|
||||||
domain: ドメイン
|
domain: ドメイン
|
||||||
inbox_url: フレンドサーバーの inbox URL
|
inbox_url: フレンドサーバーの inbox URL
|
||||||
|
@ -516,8 +517,8 @@ ja:
|
||||||
edit_friend: 編集
|
edit_friend: 編集
|
||||||
enabled: 有効
|
enabled: 有効
|
||||||
follow: こちらから申請する
|
follow: こちらから申請する
|
||||||
passive_status: 相手の状態
|
|
||||||
pending: 承認待ち
|
pending: 承認待ち
|
||||||
|
pending_you: あなたの承認が必要
|
||||||
reject: 相手からの申請を却下する
|
reject: 相手からの申請を却下する
|
||||||
save_and_enable: 保存して有効にする
|
save_and_enable: 保存して有効にする
|
||||||
setup: フレンドサーバーを追加・申請
|
setup: フレンドサーバーを追加・申請
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
|
||||||
|
|
||||||
|
class AddDeliveryLocalToFriendDomains < ActiveRecord::Migration[7.0]
|
||||||
|
include Mastodon::MigrationHelpers
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
add_column_with_default :friend_domains, :delivery_local, :boolean, default: true, allow_null: false
|
||||||
|
remove_column :friend_domains, :unlocked
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
safety_assured do
|
||||||
|
remove_column :friend_domains, :delivery_local
|
||||||
|
add_column_with_default :friend_domains, :unlocked, :boolean, default: false, allow_null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.0].define(version: 2023_10_07_090808) do
|
ActiveRecord::Schema[7.0].define(version: 2023_10_09_235215) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -686,10 +686,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_07_090808) do
|
||||||
t.string "passive_follow_activity_id"
|
t.string "passive_follow_activity_id"
|
||||||
t.boolean "available", default: true, null: false
|
t.boolean "available", default: true, null: false
|
||||||
t.boolean "pseudo_relay", default: false, null: false
|
t.boolean "pseudo_relay", default: false, null: false
|
||||||
t.boolean "unlocked", default: false, null: false
|
|
||||||
t.boolean "allow_all_posts", default: true, null: false
|
t.boolean "allow_all_posts", default: true, null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.boolean "delivery_local", default: true, null: false
|
||||||
t.index ["domain"], name: "index_friend_domains_on_domain", unique: true
|
t.index ["domain"], name: "index_friend_domains_on_domain", unique: true
|
||||||
t.index ["inbox_url"], name: "index_friend_domains_on_inbox_url", unique: true
|
t.index ["inbox_url"], name: "index_friend_domains_on_inbox_url", unique: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,5 +118,26 @@ RSpec.describe ActivityPub::Activity::Accept do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(friend.reload.i_am_accepted?).to be true
|
expect(friend.reload.i_am_accepted?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'when the friend server is pending' do
|
||||||
|
friend.update(passive_state: :pending)
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_idle?).to be true
|
||||||
|
expect(friend.i_am_accepted?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'when the friend server is accepted' do
|
||||||
|
friend.update(passive_state: :accepted)
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_idle?).to be true
|
||||||
|
expect(friend.i_am_accepted?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'when my server is not pending' do
|
||||||
|
friend.update(active_state: :idle)
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.i_am_idle?).to be true
|
||||||
|
expect(friend.they_are_idle?).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,9 +30,11 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
|
|
||||||
let(:sender_software) { 'mastodon' }
|
let(:sender_software) { 'mastodon' }
|
||||||
let(:custom_before) { false }
|
let(:custom_before) { false }
|
||||||
|
let(:active_friend) { false }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
Fabricate(:instance_info, domain: 'example.com', software: sender_software)
|
Fabricate(:instance_info, domain: 'example.com', software: sender_software)
|
||||||
|
Fabricate(:friend_domain, domain: 'example.com', active_state: :accepted) if active_friend
|
||||||
subject.perform unless custom_before
|
subject.perform unless custom_before
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -245,6 +247,26 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'creates status' do
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status.visibility).to eq 'unlisted'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when public_unlisted with LocalPublic from friend-server' do
|
||||||
|
let(:object_json) do
|
||||||
|
{
|
||||||
|
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||||
|
type: 'Note',
|
||||||
|
content: 'Lorem ipsum',
|
||||||
|
to: ['http://example.com/followers', 'LocalPublic'],
|
||||||
|
cc: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
}
|
||||||
|
end
|
||||||
|
let(:active_friend) { true }
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
@ -433,6 +455,18 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
context 'with public_unlisted with LocalPublic' do
|
context 'with public_unlisted with LocalPublic' do
|
||||||
let(:searchable_by) { ['http://example.com/followers', 'LocalPublic'] }
|
let(:searchable_by) { ['http://example.com/followers', 'LocalPublic'] }
|
||||||
|
|
||||||
|
it 'create status' do
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status.searchability).to eq 'private'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with public_unlisted with LocalPublic from friend-server' do
|
||||||
|
let(:searchable_by) { ['http://example.com/followers', 'LocalPublic'] }
|
||||||
|
let(:active_friend) { true }
|
||||||
|
|
||||||
it 'create status' do
|
it 'create status' do
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
@ -1506,11 +1540,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
context 'when sender is in friend server' do
|
context 'when sender is in friend server' do
|
||||||
subject { described_class.new(json, sender, delivery: true) }
|
subject { described_class.new(json, sender, delivery: true) }
|
||||||
|
|
||||||
before do
|
let!(:friend) { Fabricate(:friend_domain, domain: sender.domain, active_state: :accepted) }
|
||||||
Fabricate(:friend_domain, domain: sender.domain, active_state: :accepted, passive_state: :accepted)
|
|
||||||
subject.perform
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:object_json) do
|
let(:object_json) do
|
||||||
{
|
{
|
||||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||||
|
@ -1520,11 +1550,20 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'creates status' do
|
it 'creates status' do
|
||||||
|
subject.perform
|
||||||
status = sender.statuses.first
|
status = sender.statuses.first
|
||||||
|
|
||||||
expect(status).to_not be_nil
|
expect(status).to_not be_nil
|
||||||
expect(status.text).to eq 'Lorem ipsum'
|
expect(status.text).to eq 'Lorem ipsum'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'whey no-relay not creates status' do
|
||||||
|
friend.update(allow_all_posts: false)
|
||||||
|
subject.perform
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when the sender has no relevance to local activity' do
|
context 'when the sender has no relevance to local activity' do
|
||||||
|
|
|
@ -339,6 +339,37 @@ RSpec.describe ActivityPub::Activity::Follow do
|
||||||
expect(friend).to_not be_nil
|
expect(friend).to_not be_nil
|
||||||
expect(friend.they_are_pending?).to be true
|
expect(friend.they_are_pending?).to be true
|
||||||
expect(friend.passive_follow_activity_id).to eq 'foo'
|
expect(friend.passive_follow_activity_id).to eq 'foo'
|
||||||
|
expect(friend.inbox_url).to eq 'https://abc.com/inbox'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when my server is pending' do
|
||||||
|
before do
|
||||||
|
friend.update(active_state: :pending)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'marks me as idle' do
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_pending?).to be true
|
||||||
|
expect(friend.i_am_idle?).to be true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when my server is already accepted' do
|
||||||
|
before do
|
||||||
|
friend.update(active_state: :accepted)
|
||||||
|
stub_request(:post, 'https://example.com/inbox')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'marks me as idle and the friend as accepted' do
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_accepted?).to be true
|
||||||
|
expect(friend.i_am_idle?).to be true
|
||||||
|
expect(a_request(:post, 'https://example.com/inbox').with(body: hash_including({
|
||||||
|
id: 'foo#accepts/friends',
|
||||||
|
type: 'Accept',
|
||||||
|
object: 'foo',
|
||||||
|
}))).to have_been_made.once
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -372,26 +403,6 @@ RSpec.describe ActivityPub::Activity::Follow do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when unlocked' do
|
|
||||||
before do
|
|
||||||
friend.update(unlocked: true)
|
|
||||||
stub_request(:post, 'https://example.com/inbox')
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'marks the friend as accepted' do
|
|
||||||
subject.perform
|
|
||||||
|
|
||||||
friend = FriendDomain.find_by(domain: 'abc.com')
|
|
||||||
expect(friend).to_not be_nil
|
|
||||||
expect(friend.they_are_accepted?).to be true
|
|
||||||
expect(a_request(:post, 'https://example.com/inbox').with(body: hash_including({
|
|
||||||
id: 'foo#accepts/friends',
|
|
||||||
type: 'Accept',
|
|
||||||
object: 'foo',
|
|
||||||
}))).to have_been_made.once
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when unlocked on admin settings' do
|
context 'when unlocked on admin settings' do
|
||||||
before do
|
before do
|
||||||
Form::AdminSettings.new(unlocked_friend: '1').save
|
Form::AdminSettings.new(unlocked_friend: '1').save
|
||||||
|
|
|
@ -192,5 +192,19 @@ RSpec.describe ActivityPub::Activity::Reject do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(friend.reload.i_am_rejected?).to be true
|
expect(friend.reload.i_am_rejected?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'when the friend server is pending' do
|
||||||
|
friend.update(passive_state: :pending)
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_idle?).to be true
|
||||||
|
expect(friend.i_am_rejected?).to be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'when the friend server is accepted' do
|
||||||
|
friend.update(passive_state: :accepted)
|
||||||
|
subject.perform
|
||||||
|
expect(friend.reload.they_are_idle?).to be true
|
||||||
|
expect(friend.i_am_rejected?).to be true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -149,7 +149,7 @@ RSpec.describe ActivityPub::Activity::Undo do
|
||||||
friend = Fabricate(:friend_domain, domain: sender.domain, passive_state: :accepted)
|
friend = Fabricate(:friend_domain, domain: sender.domain, passive_state: :accepted)
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(sender.following?(recipient)).to be false
|
expect(sender.following?(recipient)).to be false
|
||||||
expect(friend.they_are_accepted?).to be true
|
expect(friend.reload.they_are_accepted?).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with only object uri' do
|
context 'with only object uri' do
|
||||||
|
@ -175,8 +175,19 @@ RSpec.describe ActivityPub::Activity::Undo do
|
||||||
|
|
||||||
it 'deletes follow from this server to friend' do
|
it 'deletes follow from this server to friend' do
|
||||||
subject.perform
|
subject.perform
|
||||||
expect(friend.reload.they_are_idle?).to be true
|
expect(FriendDomain.exists?(domain: 'abc.com')).to be false
|
||||||
expect(friend.passive_follow_activity_id).to be_nil
|
end
|
||||||
|
|
||||||
|
it 'when my server is pending' do
|
||||||
|
friend.update(active_state: :pending)
|
||||||
|
subject.perform
|
||||||
|
expect(FriendDomain.exists?(domain: 'abc.com')).to be false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'when my server is accepted' do
|
||||||
|
friend.update(active_state: :accepted)
|
||||||
|
subject.perform
|
||||||
|
expect(FriendDomain.exists?(domain: 'abc.com')).to be false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -99,7 +99,7 @@ describe StatusReachFinder do
|
||||||
let(:sender_software) { 'misskey' }
|
let(:sender_software) { 'misskey' }
|
||||||
let(:searchability) { :public }
|
let(:searchability) { :public }
|
||||||
|
|
||||||
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, passive_state: :accepted, pseudo_relay: true) }
|
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, pseudo_relay: true) }
|
||||||
|
|
||||||
it 'send status without friend server' do
|
it 'send status without friend server' do
|
||||||
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
||||||
|
@ -114,7 +114,7 @@ describe StatusReachFinder do
|
||||||
|
|
||||||
context 'with follower' do
|
context 'with follower' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,9 +124,21 @@ describe StatusReachFinder do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with non-follower' do
|
context 'with follower but not local-distributable' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, delivery_local: false)
|
||||||
|
bob.follow!(alice)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'send status' do
|
||||||
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
||||||
|
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with non-follower and non-relay' do
|
||||||
|
before do
|
||||||
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'send status' do
|
it 'send status' do
|
||||||
|
@ -137,7 +149,7 @@ describe StatusReachFinder do
|
||||||
|
|
||||||
context 'with pending' do
|
context 'with pending' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :pending)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :pending)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -147,21 +159,21 @@ describe StatusReachFinder do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with idle' do
|
context 'with unidirection from them' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :idle, passive_state: :accepted)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :idle, passive_state: :accepted)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'send status' do
|
it 'send status' do
|
||||||
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
||||||
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
|
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when unavailable' do
|
context 'when unavailable' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, available: false)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, available: false)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -173,7 +185,18 @@ describe StatusReachFinder do
|
||||||
|
|
||||||
context 'when distributable' do
|
context 'when distributable' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', active_state: :accepted, passive_state: :accepted, pseudo_relay: true)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'send status' do
|
||||||
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
||||||
|
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when distributable and following' do
|
||||||
|
before do
|
||||||
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
|
||||||
bob.follow!(alice)
|
bob.follow!(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -183,9 +206,9 @@ describe StatusReachFinder do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when distributable and not following' do
|
context 'when distributable reverse' do
|
||||||
before do
|
before do
|
||||||
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true)
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', active_state: :accepted, pseudo_relay: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'send status' do
|
it 'send status' do
|
||||||
|
@ -193,10 +216,35 @@ describe StatusReachFinder do
|
||||||
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
|
expect(subject.inboxes_for_friend).to include 'https://foo.bar/inbox'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when distributable but not local distributable' do
|
||||||
|
before do
|
||||||
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'send status' do
|
||||||
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
||||||
|
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when distributable and following but not local distributable' do
|
||||||
|
before do
|
||||||
|
Fabricate(:friend_domain, domain: 'foo.bar', passive_state: :accepted, pseudo_relay: true, delivery_local: false)
|
||||||
|
bob.follow!(alice)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'send status' do
|
||||||
|
expect(subject.inboxes).to include 'https://foo.bar/inbox'
|
||||||
|
expect(subject.inboxes_for_friend).to_not include 'https://foo.bar/inbox'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when it contains distributable friend server' do
|
context 'when it contains distributable friend server' do
|
||||||
before { Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', available: true, active_state: :accepted, passive_state: :accepted, pseudo_relay: true) }
|
before do
|
||||||
|
Fabricate(:friend_domain, domain: 'foo.bar', inbox_url: 'https://foo.bar/inbox', passive_state: :accepted, pseudo_relay: true)
|
||||||
|
end
|
||||||
|
|
||||||
it 'includes the inbox of the mentioned account' do
|
it 'includes the inbox of the mentioned account' do
|
||||||
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
expect(subject.inboxes).to_not include 'https://foo.bar/inbox'
|
||||||
|
@ -381,9 +429,11 @@ describe StatusReachFinder do
|
||||||
Fabricate(:friend_domain, domain: 'def.com', inbox_url: 'https://def.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
|
Fabricate(:friend_domain, domain: 'def.com', inbox_url: 'https://def.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
|
||||||
Fabricate(:friend_domain, domain: 'ghi.com', inbox_url: 'https://ghi.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: false)
|
Fabricate(:friend_domain, domain: 'ghi.com', inbox_url: 'https://ghi.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: false)
|
||||||
Fabricate(:friend_domain, domain: 'jkl.com', inbox_url: 'https://jkl.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: false, available: true)
|
Fabricate(:friend_domain, domain: 'jkl.com', inbox_url: 'https://jkl.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: false, available: true)
|
||||||
Fabricate(:friend_domain, domain: 'mno.com', inbox_url: 'https://mno.com/inbox', active_state: :accepted, passive_state: :pending, pseudo_relay: true, available: true)
|
Fabricate(:friend_domain, domain: 'mno.com', inbox_url: 'https://mno.com/inbox', active_state: :accepted, passive_state: :idle, pseudo_relay: true, available: true)
|
||||||
Fabricate(:friend_domain, domain: 'pqr.com', inbox_url: 'https://pqr.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
|
Fabricate(:friend_domain, domain: 'pqr.com', inbox_url: 'https://pqr.com/inbox', active_state: :accepted, passive_state: :accepted, pseudo_relay: true, available: true)
|
||||||
Fabricate(:unavailable_domain, domain: 'pqr.com')
|
Fabricate(:unavailable_domain, domain: 'pqr.com')
|
||||||
|
Fabricate(:friend_domain, domain: 'stu.com', inbox_url: 'https://stu.com/inbox', active_state: :idle, passive_state: :accepted, pseudo_relay: true, available: true)
|
||||||
|
Fabricate(:friend_domain, domain: 'vwx.com', inbox_url: 'https://vwx.com/inbox', active_state: :idle, passive_state: :accepted, pseudo_relay: true, available: true, delivery_local: false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns friend servers' do
|
it 'returns friend servers' do
|
||||||
|
@ -399,8 +449,13 @@ describe StatusReachFinder do
|
||||||
expect(subject).to_not include 'https://jkl.com/inbox'
|
expect(subject).to_not include 'https://jkl.com/inbox'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not contains no-mutual friends' do
|
it 'contains no-mutual friends' do
|
||||||
expect(subject).to_not include 'https://mno.com/inbox'
|
expect(subject).to include 'https://mno.com/inbox'
|
||||||
|
expect(subject).to include 'https://stu.com/inbox'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'not contains un local distable' do
|
||||||
|
expect(subject).to_not include 'https://vwx.com/inbox'
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'not contains unavailable domain friends' do
|
it 'not contains unavailable domain friends' do
|
||||||
|
|
|
@ -11,9 +11,11 @@ describe FriendDomain do
|
||||||
|
|
||||||
describe '#follow!' do
|
describe '#follow!' do
|
||||||
it 'call inbox' do
|
it 'call inbox' do
|
||||||
|
friend.update(active_state: :accepted, passive_state: :accepted)
|
||||||
friend.follow!
|
friend.follow!
|
||||||
expect(friend.active_follow_activity_id).to_not be_nil
|
expect(friend.active_follow_activity_id).to_not be_nil
|
||||||
expect(friend.i_am_pending?).to be true
|
expect(friend.i_am_pending?).to be true
|
||||||
|
expect(friend.they_are_idle?).to be true
|
||||||
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
||||||
id: friend.active_follow_activity_id,
|
id: friend.active_follow_activity_id,
|
||||||
type: 'Follow',
|
type: 'Follow',
|
||||||
|
@ -25,10 +27,11 @@ describe FriendDomain do
|
||||||
|
|
||||||
describe '#unfollow!' do
|
describe '#unfollow!' do
|
||||||
it 'call inbox' do
|
it 'call inbox' do
|
||||||
friend.update(active_follow_activity_id: 'ohagi')
|
friend.update(active_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :accepted)
|
||||||
friend.unfollow!
|
friend.unfollow!
|
||||||
expect(friend.active_follow_activity_id).to be_nil
|
expect(friend.active_follow_activity_id).to be_nil
|
||||||
expect(friend.i_am_idle?).to be true
|
expect(friend.i_am_idle?).to be true
|
||||||
|
expect(friend.they_are_idle?).to be true
|
||||||
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
||||||
type: 'Undo',
|
type: 'Undo',
|
||||||
object: {
|
object: {
|
||||||
|
@ -43,9 +46,10 @@ describe FriendDomain do
|
||||||
|
|
||||||
describe '#accept!' do
|
describe '#accept!' do
|
||||||
it 'call inbox' do
|
it 'call inbox' do
|
||||||
friend.update(passive_follow_activity_id: 'ohagi', passive_state: :pending)
|
friend.update(passive_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :pending)
|
||||||
friend.accept!
|
friend.accept!
|
||||||
expect(friend.they_are_accepted?).to be true
|
expect(friend.they_are_accepted?).to be true
|
||||||
|
expect(friend.i_am_idle?).to be true
|
||||||
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
||||||
id: 'ohagi#accepts/friends',
|
id: 'ohagi#accepts/friends',
|
||||||
type: 'Accept',
|
type: 'Accept',
|
||||||
|
@ -57,9 +61,10 @@ describe FriendDomain do
|
||||||
|
|
||||||
describe '#reject!' do
|
describe '#reject!' do
|
||||||
it 'call inbox' do
|
it 'call inbox' do
|
||||||
friend.update(passive_follow_activity_id: 'ohagi', passive_state: :pending)
|
friend.update(passive_follow_activity_id: 'ohagi', active_state: :accepted, passive_state: :pending)
|
||||||
friend.reject!
|
friend.reject!
|
||||||
expect(friend.they_are_rejected?).to be true
|
expect(friend.they_are_rejected?).to be true
|
||||||
|
expect(friend.i_am_idle?).to be true
|
||||||
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({
|
||||||
id: 'ohagi#rejects/friends',
|
id: 'ohagi#rejects/friends',
|
||||||
type: 'Reject',
|
type: 'Reject',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue