diff --git a/app/helpers/context_helper.rb b/app/helpers/context_helper.rb index ffa8e479e6..9a4f5eb2b5 100644 --- a/app/helpers/context_helper.rb +++ b/app/helpers/context_helper.rb @@ -20,6 +20,7 @@ module ContextHelper focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } }, blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' }, discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' }, + indexable: { 'toot' => 'http://joinmastodon.org/ns#', 'indexable' => 'toot:indexable' }, voters_count: { 'toot' => 'http://joinmastodon.org/ns#', 'votersCount' => 'toot:votersCount' }, emoji_reactions: { 'fedibird' => 'http://fedibird.com/ns#', 'emojiReactions' => { '@id' => 'fedibird:emojiReactions', '@type' => '@id' } }, searchable_by: { 'fedibird' => 'http://fedibird.com/ns#', 'searchableBy' => { '@id' => 'fedibird:searchableBy', '@type' => '@id' } }, diff --git a/app/models/account.rb b/app/models/account.rb index 0da8a4f274..d36315132a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -54,6 +54,7 @@ # searchability :integer default("direct"), not null # dissubscribable :boolean default(FALSE), not null # settings :jsonb +# indexable :boolean default(FALSE), not null # class Account < ApplicationRecord diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 4149fd9c4e..32b300c353 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -123,6 +123,7 @@ class ActivityPub::ProcessAccountService < BaseService @account.fields = property_values || {} @account.also_known_as = as_array(@json['alsoKnownAs'] || []).map { |item| value_or_id(item) } @account.discoverable = @json['discoverable'] || false + @account.indexable = @json['indexable'] || false @account.searchability = searchability_from_audience @account.dissubscribable = !subscribable(@account.note) @account.settings = other_settings diff --git a/db/migrate/20230814223300_add_indexable_to_accounts.rb b/db/migrate/20230814223300_add_indexable_to_accounts.rb new file mode 100644 index 0000000000..6729c05ef2 --- /dev/null +++ b/db/migrate/20230814223300_add_indexable_to_accounts.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require Rails.root.join('lib', 'mastodon', 'migration_helpers') + +class AddIndexableToAccounts < ActiveRecord::Migration[7.0] + include Mastodon::MigrationHelpers + + disable_ddl_transaction! + + def up + safety_assured { add_column_with_default :accounts, :indexable, :boolean, default: false, allow_null: false } + end + + def down + remove_column :accounts, :indexable + end +end diff --git a/db/schema.rb b/db/schema.rb index e79bfd3746..db17c0b4f6 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[7.0].define(version: 2023_08_12_130612) do +ActiveRecord::Schema[7.0].define(version: 2023_08_14_223300) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -192,6 +192,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_12_130612) do t.integer "searchability", default: 2, null: false t.boolean "dissubscribable", default: false, null: false t.jsonb "settings" + t.boolean "indexable", default: false, null: false t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin t.index "lower((username)::text), COALESCE(lower((domain)::text), ''::text)", name: "index_accounts_on_username_and_domain_lower", unique: true t.index ["domain", "id"], name: "index_accounts_on_domain_and_id"