From 930f7145374adb79e92e9bdfcbc0d0044690b6c8 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Wed, 18 Nov 2020 22:10:15 -0600 Subject: Always use indirect federation --- app/controllers/api/v1/accounts/credentials_controller.rb | 2 +- app/controllers/settings/profiles_controller.rb | 2 +- app/controllers/statuses_controller.rb | 2 +- app/lib/activitypub/adapter.rb | 1 - app/models/account.rb | 5 ++--- app/presenters/activitypub/activity_presenter.rb | 4 ++-- app/serializers/activitypub/actor_serializer.rb | 4 ++-- app/serializers/activitypub/outbox_serializer.rb | 2 +- app/serializers/activitypub/undo_announce_serializer.rb | 2 +- app/serializers/rest/account_serializer.rb | 2 +- app/services/activitypub/process_account_service.rb | 1 - app/services/backup_service.rb | 2 +- app/services/process_mentions_service.rb | 2 +- app/services/reblog_service.rb | 2 +- app/views/settings/profiles/show.html.haml | 7 ------- app/workers/activitypub/distribution_worker.rb | 2 +- app/workers/activitypub/reply_distribution_worker.rb | 2 +- config/locales/simple_form.en-MP.yml | 2 -- .../20201119035441_drop_require_dereference_from_accounts.rb | 7 +++++++ db/schema.rb | 3 +-- 20 files changed, 25 insertions(+), 31 deletions(-) create mode 100644 db/migrate/20201119035441_drop_require_dereference_from_accounts.rb diff --git a/app/controllers/api/v1/accounts/credentials_controller.rb b/app/controllers/api/v1/accounts/credentials_controller.rb index 3c8187a99..886c00282 100644 --- a/app/controllers/api/v1/accounts/credentials_controller.rb +++ b/app/controllers/api/v1/accounts/credentials_controller.rb @@ -22,7 +22,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController def account_params params.permit(:display_name, :note, :avatar, :header, :locked, :bot, :discoverable, - :require_dereference, :show_replies, :show_unlisted, + :show_replies, :show_unlisted, fields_attributes: [:name, :value]) end diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb index 541ba2d5d..e71ebbb10 100644 --- a/app/controllers/settings/profiles_controller.rb +++ b/app/controllers/settings/profiles_controller.rb @@ -21,7 +21,7 @@ class Settings::ProfilesController < Settings::BaseController def account_params params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, :discoverable, - :require_dereference, :show_replies, :show_unlisted, :private, :require_auth, + :show_replies, :show_unlisted, :private, :require_auth, fields_attributes: [:name, :value]) end diff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rb index 596ce9b84..a3ba43d7b 100644 --- a/app/controllers/statuses_controller.rb +++ b/app/controllers/statuses_controller.rb @@ -46,7 +46,7 @@ class StatusesController < ApplicationController def activity expires_in 3.minutes, public: @status.distributable? && public_fetch_mode? - render_with_cache json: ActivityPub::ActivityPresenter.from_status(@status, current_account&.domain), + render_with_cache json: ActivityPub::ActivityPresenter.from_status(@status, current_account&.domain, embed: true), content_type: 'application/activity+json', serializer: ActivityPub::ActivitySerializer, adapter: ActivityPub::Adapter, diff --git a/app/lib/activitypub/adapter.rb b/app/lib/activitypub/adapter.rb index bf5a49f05..3063f7a4b 100644 --- a/app/lib/activitypub/adapter.rb +++ b/app/lib/activitypub/adapter.rb @@ -9,7 +9,6 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base CONTEXT_EXTENSION_MAP = { direct_message: { 'litepub': 'http://litepub.social/ns#', 'directMessage': 'litepub:directMessage' }, edited: { 'mp' => 'https://the.monsterpit.net/ns#', 'edited' => 'mp:edited' }, - require_dereference: { 'mp' => 'https://the.monsterpit.net/ns#', 'requireDereference' => 'mp:requireDereference' }, show_replies: { 'mp' => 'https://the.monsterpit.net/ns#', 'showReplies' => 'mp:showReplies' }, show_unlisted: { 'mp' => 'https://the.monsterpit.net/ns#', 'showUnlisted' => 'mp:showUnlisted' }, private: { 'mp' => 'https://the.monsterpit.net/ns#', 'private' => 'mp:private' }, diff --git a/app/models/account.rb b/app/models/account.rb index b0def4028..90145ceb2 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -50,14 +50,13 @@ # avatar_storage_schema_version :integer # header_storage_schema_version :integer # devices_url :string -# sensitized_at :datetime -# suspension_origin :integer -# require_dereference :boolean default(FALSE), not null # show_replies :boolean default(TRUE), not null # show_unlisted :boolean default(TRUE), not null # private :boolean default(FALSE), not null # require_auth :boolean default(FALSE), not null # last_synced_at :datetime +# sensitized_at :datetime +# suspension_origin :integer # class Account < ApplicationRecord diff --git a/app/presenters/activitypub/activity_presenter.rb b/app/presenters/activitypub/activity_presenter.rb index 88aed1e4e..7f640ee9f 100644 --- a/app/presenters/activitypub/activity_presenter.rb +++ b/app/presenters/activitypub/activity_presenter.rb @@ -4,7 +4,7 @@ class ActivityPub::ActivityPresenter < ActiveModelSerializers::Model attributes :id, :type, :actor, :published, :to, :cc, :virtual_object class << self - def from_status(status, domain, update: false, embed: true) + def from_status(status, domain, update: false, embed: false) new.tap do |presenter| default_activity = update && status.edited.positive? ? 'Update' : 'Create' presenter.id = ActivityPub::TagManager.instance.activity_uri_for(status) @@ -14,7 +14,7 @@ class ActivityPub::ActivityPresenter < ActiveModelSerializers::Model presenter.to = ActivityPub::TagManager.instance.to(status, domain) presenter.cc = ActivityPub::TagManager.instance.cc(status, domain) - unless embed || !status.account.require_dereference + unless embed && !update presenter.virtual_object = ActivityPub::TagManager.instance.uri_for(status.proper) next end diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb index 0c6205d7f..38c566937 100644 --- a/app/serializers/activitypub/actor_serializer.rb +++ b/app/serializers/activitypub/actor_serializer.rb @@ -25,8 +25,8 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer attribute :also_known_as, if: :also_known_as? attribute :suspended, if: :suspended? - context_extensions :require_dereference, :show_replies, :private, :require_auth, :metadata, :server_metadata - attributes :require_dereference, :show_replies, :show_unlisted, :private, :require_auth + context_extensions :show_replies, :private, :require_auth, :metadata, :server_metadata + attributes :show_replies, :show_unlisted, :private, :require_auth attributes :metadata, :server_metadata class EndpointsSerializer < ActivityPub::Serializer diff --git a/app/serializers/activitypub/outbox_serializer.rb b/app/serializers/activitypub/outbox_serializer.rb index d1708cc36..4de619efc 100644 --- a/app/serializers/activitypub/outbox_serializer.rb +++ b/app/serializers/activitypub/outbox_serializer.rb @@ -10,6 +10,6 @@ class ActivityPub::OutboxSerializer < ActivityPub::CollectionSerializer end def items - object.items.map { |status| ActivityPub::ActivityPresenter.from_status(status, instance_options[:domain], embed: false) } + object.items.map { |status| ActivityPub::ActivityPresenter.from_status(status, instance_options[:domain]) } end end diff --git a/app/serializers/activitypub/undo_announce_serializer.rb b/app/serializers/activitypub/undo_announce_serializer.rb index d48fcff73..535cda20a 100644 --- a/app/serializers/activitypub/undo_announce_serializer.rb +++ b/app/serializers/activitypub/undo_announce_serializer.rb @@ -22,6 +22,6 @@ class ActivityPub::UndoAnnounceSerializer < ActivityPub::Serializer end def virtual_object - ActivityPub::ActivityPresenter.from_status(object, instance_options[:domain], embed: false) + ActivityPub::ActivityPresenter.from_status(object, instance_options[:domain]) end end diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb index 133f66201..1b780da90 100644 --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@ -7,7 +7,7 @@ class REST::AccountSerializer < ActiveModel::Serializer :note, :url, :avatar, :avatar_static, :header, :header_static, :followers_count, :following_count, :statuses_count, :last_status_at - attributes :require_dereference, :show_replies, :show_unlisted + attributes :show_replies, :show_unlisted has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested? diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 7e50dc776..ec1041b3d 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -92,7 +92,6 @@ class ActivityPub::ProcessAccountService < BaseService @account.also_known_as = as_array(@json['alsoKnownAs'] || []).map { |item| value_or_id(item) } @account.actor_type = actor_type @account.discoverable = @json['discoverable'] || false - @account.require_dereference = @json['requireDereference'] || false @account.show_replies = @json['showReplies'] || true @account.show_unlisted = @json['showUnlisted'] || true @account.private = @json['private'] || false diff --git a/app/services/backup_service.rb b/app/services/backup_service.rb index b83c08a98..e4d4c5a89 100644 --- a/app/services/backup_service.rb +++ b/app/services/backup_service.rb @@ -22,7 +22,7 @@ class BackupService < BaseService account.statuses.with_includes.reorder(nil).find_in_batches do |statuses| statuses.each do |status| - item = serialize_payload(ActivityPub::ActivityPresenter.from_status(status, nil), ActivityPub::ActivitySerializer, signer: @account, allow_local_only: true) + item = serialize_payload(ActivityPub::ActivityPresenter.from_status(status, nil, embed: true), ActivityPub::ActivitySerializer, signer: @account, allow_local_only: true) item.delete(:'@context') unless item[:type] == 'Announce' || item[:object][:attachment].blank? diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb index 51c368264..6ee8550c4 100644 --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@ -37,7 +37,7 @@ class ProcessMentionsService < BaseService end def activitypub_json(domain) - @activitypub_json[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain, embed: false), ActivityPub::ActivitySerializer, signer: @status.account, domain: domain)) + @activitypub_json[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain), ActivityPub::ActivitySerializer, signer: @status.account, domain: domain)) end def check_for_spam(status) diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 93b0c160b..ef7468194 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -61,7 +61,7 @@ class ReblogService < BaseService end def build_json(reblog) - Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(reblog, reblog.account.domain, embed: false), ActivityPub::ActivitySerializer, signer: reblog.account, domain: reblog.account.domain)) + Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(reblog, reblog.account.domain), ActivityPub::ActivitySerializer, signer: reblog.account, domain: reblog.account.domain)) end def curate!(status) diff --git a/app/views/settings/profiles/show.html.haml b/app/views/settings/profiles/show.html.haml index 1b7765f32..ef2600169 100644 --- a/app/views/settings/profiles/show.html.haml +++ b/app/views/settings/profiles/show.html.haml @@ -49,13 +49,6 @@ .fields-group = f.input :require_auth, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.require_auth') - %h4= t 'settings.profiles.advanced_privacy' - - %p.hint= t 'settings.profiles.advanced_privacy_html' - - .fields-group - = f.input :require_dereference, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.require_dereference_html') - %hr.spacer/ .fields-row diff --git a/app/workers/activitypub/distribution_worker.rb b/app/workers/activitypub/distribution_worker.rb index 948393c12..a8365ce8d 100644 --- a/app/workers/activitypub/distribution_worker.rb +++ b/app/workers/activitypub/distribution_worker.rb @@ -48,7 +48,7 @@ class ActivityPub::DistributionWorker def payload(inbox_url) domain = Addressable::URI.parse(inbox_url).normalized_host - @payload[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain, update: true, embed: false), ActivityPub::ActivitySerializer, signer: @account, domain: domain)) + @payload[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain, update: true), ActivityPub::ActivitySerializer, signer: @account, domain: domain)) end def relay! diff --git a/app/workers/activitypub/reply_distribution_worker.rb b/app/workers/activitypub/reply_distribution_worker.rb index 6b807e8bc..437a47a6e 100644 --- a/app/workers/activitypub/reply_distribution_worker.rb +++ b/app/workers/activitypub/reply_distribution_worker.rb @@ -32,6 +32,6 @@ class ActivityPub::ReplyDistributionWorker def payload(inbox_url) domain = Addressable::URI.parse(inbox_url).normalized_host - @payload[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain, update: true, embed: false), ActivityPub::ActivitySerializer, signer: @status.account, domain: domain)) + @payload[domain] ||= Oj.dump(serialize_payload(ActivityPub::ActivityPresenter.from_status(@status, domain, update: true), ActivityPub::ActivitySerializer, signer: @status.account, domain: domain)) end end diff --git a/config/locales/simple_form.en-MP.yml b/config/locales/simple_form.en-MP.yml index 488c1c885..0430b02e2 100644 --- a/config/locales/simple_form.en-MP.yml +++ b/config/locales/simple_form.en-MP.yml @@ -15,7 +15,6 @@ en-MP: phrase: Will be matched regardless of casing in text or content warning of a roar private: Only allow authenticated followers to view your local profile. require_auth: Require viewers to log in to access your profile, roars, and threads from Monsterpit. - require_dereference_html: "When enabled, Monsterpit will deliver your roars to other servers as pointers and require an authenticated request to access their (non-public) content. This allows permissions and blocks you've set to be enforced more stringently. This feature will make your roars inaccessible from Mastodon servers older than 3.2.0." setting_aggregate_reblogs: Do not show new boosts for roars that have been recently boosted (only affects newly-received boosts) setting_default_content_type_html: When composing roars, assume they are written in raw HTML, unless specified otherwise setting_default_content_type_markdown: When composing roars, assume they are using Markdown for rich text formatting, unless specified otherwise @@ -49,7 +48,6 @@ en-MP: bot: This is an automated account private: Private mode require_auth: Disallow anonymous access - require_dereference: Indirect federation mode setting_crop_images: Crop images in non-expanded roars to 16x9 setting_default_content_type: Default format for roars setting_default_language: Roar language diff --git a/db/migrate/20201119035441_drop_require_dereference_from_accounts.rb b/db/migrate/20201119035441_drop_require_dereference_from_accounts.rb new file mode 100644 index 000000000..e677fbb16 --- /dev/null +++ b/db/migrate/20201119035441_drop_require_dereference_from_accounts.rb @@ -0,0 +1,7 @@ +class DropRequireDereferenceFromAccounts < ActiveRecord::Migration[5.2] + def change + safety_assured do + remove_column :accounts, :require_dereference, :boolean, null: false, default: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 328f50a8d..273e942f5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2020_10_17_234926) do +ActiveRecord::Schema.define(version: 2020_11_19_035441) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -206,7 +206,6 @@ ActiveRecord::Schema.define(version: 2020_10_17_234926) do t.integer "avatar_storage_schema_version" t.integer "header_storage_schema_version" t.string "devices_url" - t.boolean "require_dereference", default: false, null: false t.boolean "show_replies", default: true, null: false t.boolean "show_unlisted", default: true, null: false t.boolean "private", default: false, null: false -- cgit