diff --git a/app/controllers/admin/domain_blocks_controller.rb b/app/controllers/admin/domain_blocks_controller.rb index c91b9b71634298..edacbd5adc14fa 100644 --- a/app/controllers/admin/domain_blocks_controller.rb +++ b/app/controllers/admin/domain_blocks_controller.rb @@ -89,17 +89,17 @@ def set_domain_block def update_params params.require(:domain_block).permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, - :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) end def resource_params params.require(:domain_block).permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, - :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) end def form_domain_block_batch_params params.require(:form_domain_block_batch).permit(domain_blocks_attributes: [:enabled, :domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, - :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous]) + :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous]) end def action_from_button diff --git a/app/controllers/api/v1/admin/domain_blocks_controller.rb b/app/controllers/api/v1/admin/domain_blocks_controller.rb index bd0660dbaaa153..e157ed1e1fc965 100644 --- a/app/controllers/api/v1/admin/domain_blocks_controller.rb +++ b/app/controllers/api/v1/admin/domain_blocks_controller.rb @@ -70,7 +70,7 @@ def filtered_domain_blocks def domain_block_params params.permit(:severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_reports, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, - :reject_new_follow, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_new_follow, :reject_friend, :detect_invalid_subscription, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) end def insert_pagination_headers @@ -103,6 +103,6 @@ def pagination_params(core_params) def resource_params params.permit(:domain, :severity, :reject_media, :reject_favourite, :reject_reply, :reject_reply_exclude_followers, :reject_send_not_public_searchability, :reject_send_public_unlisted, :reject_send_dissubscribable, :reject_send_media, :reject_send_sensitive, :reject_hashtag, :reject_straight_follow, - :reject_new_follow, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) + :reject_new_follow, :reject_friend, :detect_invalid_subscription, :reject_reports, :private_comment, :public_comment, :obfuscate, :hidden, :hidden_anonymous) end end diff --git a/app/lib/activitypub/activity/follow.rb b/app/lib/activitypub/activity/follow.rb index b578f8fa1d4416..d02e9c01c6fd85 100644 --- a/app/lib/activitypub/activity/follow.rb +++ b/app/lib/activitypub/activity/follow.rb @@ -55,8 +55,12 @@ def request_follow_for_friend @friend = FriendDomain.create!(domain: @account.domain, passive_state: :pending, passive_follow_activity_id: @json['id']) end - # Send acception at after_commit of models/friend_domain.rb when unlocked is true - friend.accept! if already_accepted + if already_accepted || friend.unlocked || Setting.unlocked_friend + friend.accept! + else + # Notify for admin even if unlocked + notify_staff_about_pending_friend_server! + end end def friend @@ -101,4 +105,12 @@ def proxyable_software? def instance_info @instance_info ||= InstanceInfo.find_by(domain: @account.domain) end + + def notify_staff_about_pending_friend_server! + User.those_who_can(:manage_federation).includes(:account).find_each do |u| + next unless u.allows_pending_friend_server_emails? + + AdminMailer.with(recipient: u.account).new_pending_friend_server(friend).deliver_later + end + end end diff --git a/app/mailers/admin_mailer.rb b/app/mailers/admin_mailer.rb index 990b92c3377d2e..11262144be0576 100644 --- a/app/mailers/admin_mailer.rb +++ b/app/mailers/admin_mailer.rb @@ -35,6 +35,14 @@ def new_pending_account(user) end end + def new_pending_friend_server(friend_server) + @friend = friend_server + + locale_for_account(@me) do + mail subject: default_i18n_subject(instance: @instance, domain: @friend.domain) + end + end + def new_trends(links, tags, statuses) @links = links @tags = tags diff --git a/app/models/concerns/has_user_settings.rb b/app/models/concerns/has_user_settings.rb index ed5a5f429f29a7..820c41360d4efc 100644 --- a/app/models/concerns/has_user_settings.rb +++ b/app/models/concerns/has_user_settings.rb @@ -263,6 +263,10 @@ def allows_pending_account_emails? settings['notification_emails.pending_account'] end + def allows_pending_friend_server_emails? + settings['notification_emails.pending_friend_server'] + end + def allows_appeal_emails? settings['notification_emails.appeal'] end diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb index a2de73bd14b695..681b13814aa73d 100644 --- a/app/models/form/admin_settings.rb +++ b/app/models/form/admin_settings.rb @@ -48,6 +48,7 @@ class Form::AdminSettings enable_emoji_reaction check_lts_version_only enable_public_unlisted_visibility + unlocked_friend ).freeze INTEGER_KEYS = %i( @@ -76,6 +77,7 @@ class Form::AdminSettings enable_emoji_reaction check_lts_version_only enable_public_unlisted_visibility + unlocked_friend ).freeze UPLOAD_KEYS = %i( diff --git a/app/models/friend_domain.rb b/app/models/friend_domain.rb index e2c467c72be2c2..a3beb9b3574675 100644 --- a/app/models/friend_domain.rb +++ b/app/models/friend_domain.rb @@ -35,7 +35,6 @@ class FriendDomain < ApplicationRecord before_destroy :ensure_disabled after_commit :set_default_inbox_url - after_commit :auto_accept_when_unlocked def mutual? i_am_accepted? && they_are_accepted? @@ -161,8 +160,4 @@ def ensure_disabled def set_default_inbox_url self.inbox_url = default_inbox_url if inbox_url.blank? end - - def auto_accept_when_unlocked - accept! if unlocked && they_are_pending? - end end diff --git a/app/models/user_settings.rb b/app/models/user_settings.rb index 8518e2abf224a7..4bf64e338bbe01 100644 --- a/app/models/user_settings.rb +++ b/app/models/user_settings.rb @@ -80,6 +80,7 @@ class KeyError < Error; end setting :follow_request, default: true setting :report, default: true setting :pending_account, default: true + setting :pending_friend_server, default: true setting :trends, default: true setting :appeal, default: true setting :software_updates, default: 'critical', in: %w(none critical patch all) diff --git a/app/views/admin/domain_blocks/edit.html.haml b/app/views/admin/domain_blocks/edit.html.haml index 8a064415080510..cf83d383e9fcee 100644 --- a/app/views/admin/domain_blocks/edit.html.haml +++ b/app/views/admin/domain_blocks/edit.html.haml @@ -47,6 +47,9 @@ .fields-group = f.input :reject_new_follow, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_new_follow'), hint: I18n.t('admin.domain_blocks.reject_new_follow_hint') + .fields-group + = f.input :reject_friend, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_friend'), hint: I18n.t('admin.domain_blocks.reject_friend_hint') + .fields-group = f.input :detect_invalid_subscription, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.detect_invalid_subscription'), hint: I18n.t('admin.domain_blocks.detect_invalid_subscription_hint') diff --git a/app/views/admin/domain_blocks/new.html.haml b/app/views/admin/domain_blocks/new.html.haml index 606a784e127eda..ed5142934fd675 100644 --- a/app/views/admin/domain_blocks/new.html.haml +++ b/app/views/admin/domain_blocks/new.html.haml @@ -47,6 +47,9 @@ .fields-group = f.input :reject_new_follow, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_new_follow'), hint: I18n.t('admin.domain_blocks.reject_new_follow_hint') + .fields-group + = f.input :reject_friend, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.reject_friend'), hint: I18n.t('admin.domain_blocks.reject_friend_hint') + .fields-group = f.input :detect_invalid_subscription, as: :boolean, wrapper: :with_label, label: I18n.t('admin.domain_blocks.detect_invalid_subscription'), hint: I18n.t('admin.domain_blocks.detect_invalid_subscription_hint') diff --git a/app/views/admin/settings/discovery/show.html.haml b/app/views/admin/settings/discovery/show.html.haml index ee7d72ad320e9c..bedafdb49943a8 100644 --- a/app/views/admin/settings/discovery/show.html.haml +++ b/app/views/admin/settings/discovery/show.html.haml @@ -45,6 +45,11 @@ .fields-group = f.input :enable_public_unlisted_visibility, as: :boolean, wrapper: :with_label, kmyblue: true, hint: false + %h4= t('admin.settings.discovery.friend_servers') + + .fields-group + = f.input :unlocked_friend, as: :boolean, wrapper: :with_label, kmyblue: true, hint: false + %h4= t('admin.settings.discovery.publish_statistics') .fields-group diff --git a/app/views/admin_mailer/new_pending_friend_server.text.erb b/app/views/admin_mailer/new_pending_friend_server.text.erb new file mode 100644 index 00000000000000..89c9ec1b09ccd5 --- /dev/null +++ b/app/views/admin_mailer/new_pending_friend_server.text.erb @@ -0,0 +1,5 @@ +<%= raw t('application_mailer.salutation', name: display_name(@me)) %> + +<%= raw t('admin_mailer.new_pending_friend_server.body', domain: @friend.domain) %> + +<%= raw t('application_mailer.view')%> <%= admin_friend_servers_url %> diff --git a/app/views/settings/preferences/notifications/show.html.haml b/app/views/settings/preferences/notifications/show.html.haml index 06af9c136059f8..0f29221edec39e 100644 --- a/app/views/settings/preferences/notifications/show.html.haml +++ b/app/views/settings/preferences/notifications/show.html.haml @@ -22,13 +22,14 @@ .fields-group = ff.input :always_send_emails, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_always_send_emails'), hint: I18n.t('simple_form.hints.defaults.setting_always_send_emails') - - if current_user.can?(:manage_reports, :manage_appeals, :manage_users, :manage_taxonomies) || (SoftwareUpdate.check_enabled? && current_user.can?(:view_devops)) + - if current_user.can?(:manage_reports, :manage_appeals, :manage_users, :manage_taxonomies, :manage_federation) || (SoftwareUpdate.check_enabled? && current_user.can?(:view_devops)) %h4= t 'notifications.administration_emails' .fields-group = ff.input :'notification_emails.report', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.report') if current_user.can?(:manage_reports) = ff.input :'notification_emails.appeal', as: :boolean, wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.appeal') if current_user.can?(:manage_appeals) = ff.input :'notification_emails.pending_account', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.pending_account') if current_user.can?(:manage_users) + = ff.input :'notification_emails.pending_friend_server', as: :boolean, wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.notification_emails.pending_friend_server') if current_user.can?(:manage_federation) = ff.input :'notification_emails.trends', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.trending_tag') if current_user.can?(:manage_taxonomies) - if SoftwareUpdate.check_enabled? && current_user.can?(:view_devops) diff --git a/config/locales/en.yml b/config/locales/en.yml index 8633f4dfc03097..0b197616404398 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -426,6 +426,8 @@ en: public_comment_hint: Comment about this domain limitation for the general public, if advertising the list of domain limitations is enabled. reject_favourite: Reject favorites reject_favourite_hint: Reject favorites or emoji-reaction in the future + reject_friend: Reject friend server applications + reject_friend_hint: Reject friend server application in the future reject_hashtag: Reject hashtags reject_hashtag_hint: Reject hashtags in the future reject_media: Reject media files @@ -520,6 +522,7 @@ en: limited_federation_mode_description_html: You can chose whether to allow federation with this domain. policies: reject_favourite: Reject favorite + reject_friend: Reject friend server application reject_hashtag: Reject hashtags reject_media: Reject media reject_new_follow: Reject follows @@ -810,6 +813,7 @@ en: discovery: emoji_reactions: Stamp follow_recommendations: Follow recommendations + friend_servers: Friend servers preamble: Surfacing interesting content is instrumental in onboarding new users who may not know anyone Mastodon. Control how various discovery features work on your server. profile_directory: Profile directory public_timelines: Public timelines @@ -1050,6 +1054,9 @@ en: new_pending_account: body: The details of the new account are below. You can approve or reject this application. subject: New account up for review on %{instance} (%{username}) + new_pending_friend_server: + body: The new friend server %{domain} is waiting for your review. You can approve or reject this application. + subject: New friend server up for review on %{instance} (%{domain}) new_report: body: "%{reporter} has reported %{target}" body_remote: Someone from %{domain} has reported %{target} diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 87de99e51528f8..e38f2d1b4cfb8f 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -422,6 +422,8 @@ ja: public_comment_hint: ドメインブロックの公開を有効にしている場合、このコメントも公開されます。 reject_favourite: お気に入り、スタンプを拒否 reject_favourite_hint: 今後のお気に入り、スタンプを拒否します。停止とは無関係です + reject_friend: フレンドサーバー申請を拒否 + reject_friend_hint: 今後のフレンドサーバー申請を全て拒否します。停止とは無関係です reject_hashtag: ハッシュタグを拒否 reject_hashtag_hint: ハッシュタグで検索できなくなり、トレンドにも影響しなくなります。停止とは無関係です reject_media: メディアファイルを拒否 @@ -514,6 +516,7 @@ ja: policies: detect_invalid_subscription: 購読のプライバシーなし reject_favourite: お気に入りを拒否 + reject_friend: フレンドサーバー申請を拒否 reject_hashtag: ハッシュタグを拒否 reject_media: メディアを拒否する reject_new_follow: 新規フォローを拒否 @@ -807,6 +810,7 @@ ja: discovery: emoji_reactions: スタンプ follow_recommendations: おすすめフォロー + friend_servers: フレンドサーバー preamble: Mastodon を知らないユーザーを取り込むには、興味深いコンテンツを浮上させることが重要です。サーバー上で様々なディスカバリー機能がどのように機能するかを制御します。 profile_directory: ディレクトリ public_timelines: 公開タイムライン @@ -1043,6 +1047,9 @@ ja: new_pending_account: body: 新しいアカウントの詳細は以下の通りです。この申請を承認または却下することができます。 subject: '%{instance}で新しいアカウント (%{username}) が承認待ちです' + new_pending_friend_server: + body: 新しいフレンドサーバー %{domain} の申請が届いています。この申請を承認または却下することができます。 + subject: '%{instance}で新しいフレンドサーバー (%{domain}) が承認待ちです' new_report: body: "%{reporter}さんが%{target}さんを通報しました" body_remote: "%{domain}の誰かが%{target}さんを通報しました" diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index c37a6de56abf54..2b777aaa2b00c7 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -354,6 +354,7 @@ en: trendable_by_default: Allow trends without prior review trends: Enable trends trends_as_landing_page: Use trends as the landing page + unlocked_friend: Accept all friend server follows automatically interactions: must_be_follower: Block notifications from non-followers must_be_following: Block notifications from people you don't follow @@ -378,6 +379,7 @@ en: follow_request: Someone requested to follow you mention: Someone mentioned you pending_account: New account needs review + pending_friend_server: New friend server needs review reblog: Someone boosted your post report: New report is submitted software_updates: diff --git a/config/locales/simple_form.ja.yml b/config/locales/simple_form.ja.yml index 3904f757518bf6..41057cbed1b052 100644 --- a/config/locales/simple_form.ja.yml +++ b/config/locales/simple_form.ja.yml @@ -369,6 +369,7 @@ ja: trendable_by_default: 審査前のトレンドの掲載を許可する trends: トレンドを有効にする trends_as_landing_page: 新規登録画面にトレンドを表示する + unlocked_friend: 全てのフレンドサーバー申請を自動承認する interactions: must_be_follower: フォロワー以外からの通知をブロック must_be_following: フォローしていないユーザーからの通知をブロック @@ -393,6 +394,7 @@ ja: follow_request: フォローリクエストを受けた時 mention: 返信が来た時 pending_account: 新しいアカウントの承認が必要な時 + pending_friend_server: 新しいフレンドサーバーの承認が必要な時 reblog: 投稿がブーストされた時 report: 新しい通報が送信された時 software_updates: diff --git a/config/navigation.rb b/config/navigation.rb index e9552f4f7a6c64..25bc5ecd435b6d 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -66,6 +66,7 @@ s.item :custom_emojis, safe_join([fa_icon('smile-o fw'), t('admin.custom_emojis.title')]), admin_custom_emojis_path, highlights_on: %r{/admin/custom_emojis}, if: -> { current_user.can?(:manage_custom_emojis) } s.item :webhooks, safe_join([fa_icon('inbox fw'), t('admin.webhooks.title')]), admin_webhooks_path, highlights_on: %r{/admin/webhooks}, if: -> { current_user.can?(:manage_webhooks) } s.item :relays, safe_join([fa_icon('exchange fw'), t('admin.relays.title')]), admin_relays_path, highlights_on: %r{/admin/relays}, if: -> { !limited_federation_mode? && current_user.can?(:manage_federation) } + s.item :friend_servers, safe_join([fa_icon('users fw'), t('admin.friend_servers.title')]), admin_friend_servers_path, highlights_on: %r{/admin/friend_servers}, if: -> { current_user.can?(:manage_federation) } end n.item :sidekiq, safe_join([fa_icon('diamond fw'), 'Sidekiq']), sidekiq_path, link_html: { target: 'sidekiq' }, if: -> { current_user.can?(:view_devops) } diff --git a/config/settings.yml b/config/settings.yml index c0b5f4109bd6aa..1fb106e680a2e9 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -43,6 +43,7 @@ defaults: &defaults enable_emoji_reaction: true check_lts_version_only: true enable_public_unlisted_visibility: true + unlocked_friend: false development: <<: *defaults diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake index 7f8e72dd8f43b9..980823731e9e1f 100644 --- a/lib/tasks/tests.rake +++ b/lib/tasks/tests.rake @@ -136,7 +136,7 @@ namespace :tests do INSERT INTO "settings" (id, thing_type, thing_id, var, value, created_at, updated_at) VALUES - (3, 'User', 1, 'notification_emails', E'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfollow: false\nreblog: true\nfavourite: true\nmention: false\nfollow_request: true\ndigest: true\nreport: true\npending_account: false\ntrending_tag: true\nappeal: true\n', now(), now()), + (3, 'User', 1, 'notification_emails', E'--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\nfollow: false\nreblog: true\nfavourite: true\nmention: false\nfollow_request: true\ndigest: true\nreport: true\npending_account: false\npending_friend_server: true\ntrending_tag: true\nappeal: true\n', now(), now()), (4, 'User', 1, 'trends', E'--- false\n', now(), now()); INSERT INTO "accounts" diff --git a/spec/lib/activitypub/activity/follow_spec.rb b/spec/lib/activitypub/activity/follow_spec.rb index c6350d62488171..a69fa9b5634995 100644 --- a/spec/lib/activitypub/activity/follow_spec.rb +++ b/spec/lib/activitypub/activity/follow_spec.rb @@ -308,6 +308,8 @@ let(:sender) { Fabricate(:account, domain: 'abc.com', url: 'https://abc.com/#actor') } let!(:friend) { Fabricate(:friend_domain, domain: 'abc.com', passive_state: :idle) } + let!(:owner_user) { Fabricate(:user, role: UserRole.find_by(name: 'Owner')) } + let!(:patch_user) { Fabricate(:user, role: Fabricate(:user_role, name: 'OhagiOps', permissions: UserRole::FLAGS[:manage_federation])) } let(:json) do { @@ -340,6 +342,24 @@ end end + context 'with sending email' do + around do |example| + queue_adapter = ActiveJob::Base.queue_adapter + ActiveJob::Base.queue_adapter = :test + + example.run + + ActiveJob::Base.queue_adapter = queue_adapter + end + + it 'perform' do + expect { subject.perform }.to have_enqueued_mail(AdminMailer, :new_pending_friend_server) + .with(hash_including(params: { recipient: owner_user.account })).once + .and(have_enqueued_mail(AdminMailer, :new_pending_friend_server).with(hash_including(params: { recipient: patch_user.account })).once) + .and(have_enqueued_mail.at_most(2)) + end + end + context 'when after rejected' do before do friend.update(passive_state: :rejected) @@ -372,6 +392,26 @@ end end + context 'when unlocked on admin settings' do + before do + Form::AdminSettings.new(unlocked_friend: '1').save + 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 already accepted' do before do friend.update(passive_state: :accepted) diff --git a/spec/mailers/admin_mailer_spec.rb b/spec/mailers/admin_mailer_spec.rb index 423dce88ab09ee..23b99a68cc1619 100644 --- a/spec/mailers/admin_mailer_spec.rb +++ b/spec/mailers/admin_mailer_spec.rb @@ -64,6 +64,26 @@ end end + describe '.new_pending_friend_server' do + let(:recipient) { Fabricate(:account, username: 'Barklums') } + let(:friend) { Fabricate(:friend_domain, passive_state: :pending, domain: 'abc.com') } + let(:mail) { described_class.with(recipient: recipient).new_pending_friend_server(friend) } + + before do + recipient.user.update(locale: :en) + end + + it 'renders the headers' do + expect(mail.subject).to eq('New friend server up for review on cb6e6126.ngrok.io (abc.com)') + expect(mail.to).to eq [recipient.user_email] + expect(mail.from).to eq ['notifications@localhost'] + end + + it 'renders the body' do + expect(mail.body.encoded).to match 'The new friend server abc.com is waiting for your review. You can approve or reject this application.' + end + end + describe '.new_trends' do let(:recipient) { Fabricate(:account, username: 'Snurf') } let(:links) { [] } diff --git a/spec/mailers/previews/admin_mailer_preview.rb b/spec/mailers/previews/admin_mailer_preview.rb index bc8f0193b9cd7b..7ba6f08239ecb8 100644 --- a/spec/mailers/previews/admin_mailer_preview.rb +++ b/spec/mailers/previews/admin_mailer_preview.rb @@ -8,6 +8,11 @@ def new_pending_account AdminMailer.with(recipient: Account.first).new_pending_account(User.pending.first) end + # Preview this email at http://localhost:3000/rails/mailers/admin_mailer/new_pending_friend_server + def new_pending_friend_server + AdminMailer.with(recipient: Account.first).new_pending_friend_server(User.pending.first) + end + # Preview this email at http://localhost:3000/rails/mailers/admin_mailer/new_trends def new_trends AdminMailer.with(recipient: Account.first).new_trends(PreviewCard.joins(:trend).limit(3), Tag.limit(3), Status.joins(:trend).where(reblog_of_id: nil).limit(3)) diff --git a/spec/models/friend_domain_spec.rb b/spec/models/friend_domain_spec.rb index a26d8e09a51112..c3fa128b1621b6 100644 --- a/spec/models/friend_domain_spec.rb +++ b/spec/models/friend_domain_spec.rb @@ -53,17 +53,6 @@ object: 'ohagi', }))).to have_been_made.once end - - it 'call inbox when unlocked parameter is changed' do - friend.update(passive_follow_activity_id: 'ohagi', passive_state: :pending, unlocked: true) - expect(friend.they_are_accepted?).to be true - expect(a_request(:post, 'https://foo.bar/inbox').with(body: hash_including({ - id: 'ohagi#accepts/friends', - type: 'Accept', - actor: 'https://cb6e6126.ngrok.io/actor', - object: 'ohagi', - }))).to have_been_made.once - end end describe '#reject!' do