diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..05f4b6fd --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,13 @@ +## Describe your changes + +## Repo/gem name with Github repo url + +## Branch name + +## Issue ticket number and link + +## Checklist before requesting a review +- [ ] I have performed a self-review of my code +- [ ] If it is a core feature, I have added thorough tests. +- [ ] Do we need to implement analytics? +- [ ] Will this be part of a product update? If yes, please write one phrase about this update. diff --git a/app/jobs/update_accounts_discoverability_job.rb b/app/jobs/update_accounts_discoverability_job.rb new file mode 100644 index 00000000..019d98cc --- /dev/null +++ b/app/jobs/update_accounts_discoverability_job.rb @@ -0,0 +1,8 @@ +class UpdateAccountsDiscoverabilityJob < ApplicationJob + queue_as :default + retry_on StandardError, attempts: 1 + + def perform(value) + Account.update_all_discoverability(value) + end +end diff --git a/app/models/account.rb b/app/models/account.rb index 151ccabf..6949a3db 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -28,7 +28,6 @@ # hide_collections :boolean # inbox_url :string default(""), not null # indexable :boolean default(FALSE), not null -# is_banned :boolean default(FALSE) # last_webfingered_at :datetime # locked :boolean default(FALSE), not null # memorial :boolean default(FALSE), not null @@ -150,4 +149,10 @@ def following_ids(account_id = nil) (follow_ids + follow_request_ids).uniq end + def self.update_all_discoverability(value = false) + update_all( + discoverable: value, + indexable: value + ) + end end diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 2dca84cc..30bc43d1 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -4,16 +4,20 @@ # # Table name: domain_blocks # -# id :bigint(8) not null, primary key +# id :bigint not null, primary key # domain :string default(""), not null -# created_at :datetime not null -# updated_at :datetime not null -# severity :integer default("silence") -# reject_media :boolean default(FALSE), not null -# reject_reports :boolean default(FALSE), not null +# obfuscate :boolean default(FALSE), not null # private_comment :text # public_comment :text -# obfuscate :boolean default(FALSE), not null +# reject_media :boolean default(FALSE), not null +# reject_reports :boolean default(FALSE), not null +# severity :integer default("silence") +# created_at :datetime not null +# updated_at :datetime not null +# +# Indexes +# +# index_domain_blocks_on_domain (domain) UNIQUE # class DomainBlock < ApplicationRecord diff --git a/app/models/server_setting.rb b/app/models/server_setting.rb index 3d94885b..ddd689c7 100644 --- a/app/models/server_setting.rb +++ b/app/models/server_setting.rb @@ -20,7 +20,9 @@ class ServerSetting < ApplicationRecord belongs_to :parent, class_name: "ServerSetting", optional: true has_many :children, class_name: "ServerSetting", foreign_key: "parent_id", dependent: :destroy - after_update :invoke_keyword_schedule, if: :saved_change_to_value?, if: :content_or_spam_filters? + after_update :invoke_keyword_schedule, if: -> { saved_change_to_value? && content_or_spam_filters? } + + after_update :update_accounts_discoverable, if: -> { saved_change_to_value? && search_opt_out_filter? } after_commit :sync_setting @@ -45,4 +47,12 @@ def content_or_spam_filters? def sync_setting SyncSettingService.new(self).call if saved_change_to_value? && has_parent? end + + def search_opt_out_filter? + name == "Search opt-out" + end + + def update_accounts_discoverable + UpdateAccountsDiscoverabilityJob.perform_later(value) + end end diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index f8aa9313..1e0089e6 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -7,7 +7,7 @@ - else = 'Dashboard' | - = 'Patchwork' + = application_name(0) %meta{content: "width=device-width,initial-scale=1", name: "viewport"}/ = csrf_meta_tags diff --git a/db/schema.rb b/db/schema.rb index b7d0f89c..0ea46644 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -199,7 +199,6 @@ t.boolean "indexable", default: false, null: false t.string "attribution_domains", default: [], array: true t.string "devices_url" - t.boolean "is_banned", default: 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" @@ -690,9 +689,7 @@ t.integer "thumbnail_file_size" t.datetime "thumbnail_updated_at", precision: nil t.string "thumbnail_remote_url" - t.bigint "patchwork_drafted_status_id" t.index ["account_id", "status_id"], name: "index_media_attachments_on_account_id_and_status_id", order: { status_id: :desc } - t.index ["patchwork_drafted_status_id"], name: "index_media_attachments_on_patchwork_drafted_status_id", where: "(patchwork_drafted_status_id IS NOT NULL)" t.index ["scheduled_status_id"], name: "index_media_attachments_on_scheduled_status_id", where: "(scheduled_status_id IS NOT NULL)" t.index ["shortcode"], name: "index_media_attachments_on_shortcode", unique: true, opclass: :text_pattern_ops, where: "(shortcode IS NOT NULL)" t.index ["status_id"], name: "index_media_attachments_on_status_id" @@ -919,6 +916,7 @@ t.datetime "updated_at", null: false t.string "filter_type", default: "filter_out", null: false t.index ["keyword", "is_filter_hashtag", "patchwork_community_id"], name: "index_on_keyword_is_filter_hashtag_and_patchwork_community_id", unique: true + t.index ["keyword", "is_filter_hashtag"], name: "idx_on_keyword_is_filter_hashtag_de4b77f0f4", unique: true t.index ["patchwork_community_id"], name: "idx_on_patchwork_community_id_eadde3c87b" end @@ -1003,11 +1001,10 @@ create_table "patchwork_community_types", force: :cascade do |t| t.string "name", null: false - t.string "slug", null: false t.integer "sorting_index", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["slug"], name: "index_patchwork_community_types_on_slug", unique: true + t.string "slug" end create_table "patchwork_content_types", force: :cascade do |t| @@ -1019,14 +1016,6 @@ t.index ["patchwork_community_id"], name: "index_patchwork_content_types_on_patchwork_community_id" end - create_table "patchwork_drafted_statuses", force: :cascade do |t| - t.bigint "account_id" - t.jsonb "params" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["account_id"], name: "index_patchwork_drafted_statuses_on_account_id" - end - create_table "patchwork_joined_communities", force: :cascade do |t| t.bigint "account_id", null: false t.bigint "patchwork_community_id", null: false @@ -1384,7 +1373,6 @@ t.datetime "edited_at", precision: nil t.boolean "trendable" t.bigint "ordered_media_attachment_ids", array: true - t.boolean "is_banned", default: false t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)" t.index ["account_id"], name: "index_statuses_on_account_id" t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)" @@ -1645,7 +1633,6 @@ add_foreign_key "login_activities", "users", on_delete: :cascade add_foreign_key "markers", "users", on_delete: :cascade add_foreign_key "media_attachments", "accounts", name: "fk_96dd81e81b", on_delete: :nullify - add_foreign_key "media_attachments", "patchwork_drafted_statuses", on_delete: :nullify add_foreign_key "media_attachments", "scheduled_statuses", on_delete: :nullify add_foreign_key "media_attachments", "statuses", on_delete: :nullify add_foreign_key "mentions", "accounts", name: "fk_970d43f9d1", on_delete: :cascade @@ -1681,7 +1668,6 @@ add_foreign_key "patchwork_community_post_types", "patchwork_communities", on_delete: :cascade add_foreign_key "patchwork_community_rules", "patchwork_communities", on_delete: :cascade, validate: false add_foreign_key "patchwork_content_types", "patchwork_communities", on_delete: :cascade - add_foreign_key "patchwork_drafted_statuses", "accounts", on_delete: :cascade add_foreign_key "patchwork_joined_communities", "accounts", on_delete: :cascade, validate: false add_foreign_key "patchwork_joined_communities", "patchwork_communities", on_delete: :cascade, validate: false add_foreign_key "patchwork_notification_tokens", "accounts", on_delete: :cascade