Add dissubscribable config

This commit is contained in:
KMY 2023-04-24 09:12:17 +09:00
parent 7faaee5f0e
commit 306d8c358a
15 changed files with 49 additions and 6 deletions

View file

@ -30,6 +30,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
:bot,
:discoverable,
:searchability,
:dissubscribable,
:hide_collections,
fields_attributes: [:name, :value]
)

View file

@ -20,7 +20,7 @@ class Settings::ProfilesController < Settings::BaseController
private
def account_params
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :searchability, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :searchability, :dissubscribable, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
end
def set_account

View file

@ -23,6 +23,7 @@ module ContextHelper
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' } },
subscribable_by: { 'kmyblue' => 'http://kmy.blue/ns#', 'subscribableBy' => { '@id' => "kmyblue:subscribableBy", '@type' => '@id' } },
olm: { 'toot' => 'http://joinmastodon.org/ns#', 'Device' => 'toot:Device', 'Ed25519Signature' => 'toot:Ed25519Signature', 'Ed25519Key' => 'toot:Ed25519Key', 'Curve25519Key' => 'toot:Curve25519Key', 'EncryptedMessage' => 'toot:EncryptedMessage', 'publicKeyBase64' => 'toot:publicKeyBase64', 'deviceId' => 'toot:deviceId', 'claim' => { '@type' => '@id', '@id' => 'toot:claim' }, 'fingerprintKey' => { '@type' => '@id', '@id' => 'toot:fingerprintKey' }, 'identityKey' => { '@type' => '@id', '@id' => 'toot:identityKey' }, 'devices' => { '@type' => '@id', '@id' => 'toot:devices' }, 'messageFranking' => 'toot:messageFranking', 'messageType' => 'toot:messageType', 'cipherText' => 'toot:cipherText' },
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
}.freeze

View file

@ -186,6 +186,10 @@ class ActivityPub::TagManager
nil
end
def subscribable_by(account)
account.dissubscribable ? [] : [COLLECTIONS[:public]]
end
def searchable_by(status)
searchable_by =
case status.compute_searchability_activitypub

View file

@ -52,6 +52,7 @@
# requested_review_at :datetime
# group_allow_private_message :boolean
# searchability :integer default("private"), not null
# dissubscribable :boolean default(FALSE), not null
#
class Account < ApplicationRecord

View file

@ -16,6 +16,7 @@
# created_at :datetime not null
# updated_at :datetime not null
# expires_at :datetime
# with_media_only :boolean default(FALSE), not null
#
class Antenna < ApplicationRecord
include Expireable

View file

@ -7,13 +7,13 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
context :security
context_extensions :manually_approves_followers, :featured, :also_known_as,
:moved_to, :property_value, :discoverable, :olm, :suspended, :searchable_by
:moved_to, :property_value, :discoverable, :olm, :suspended, :searchable_by, :subscribable_by
attributes :id, :type, :following, :followers,
:inbox, :outbox, :featured, :featured_tags,
:preferred_username, :name, :summary,
:url, :manually_approves_followers,
:discoverable, :published, :searchable_by
:discoverable, :published, :searchable_by, :subscribable_by
has_one :public_key, serializer: ActivityPub::PublicKeySerializer
@ -166,6 +166,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
ActivityPub::TagManager.instance.account_searchable_by(object)
end
def subscribable_by
ActivityPub::TagManager.instance.subscribable_by(object)
end
class CustomEmojiSerializer < ActivityPub::EmojiSerializer
end

View file

@ -5,7 +5,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
include FormattingHelper
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :group, :created_at,
:note, :url, :avatar, :avatar_static, :header, :header_static, :searchability,
:note, :url, :avatar, :avatar_static, :header, :header_static, :searchability, :dissubscribable,
:followers_count, :following_count, :statuses_count, :last_status_at
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?

View file

@ -78,6 +78,7 @@ class ActivityPub::ProcessAccountService < BaseService
@account.suspension_origin = :local if auto_suspend?
@account.silenced_at = domain_block.created_at if auto_silence?
@account.searchability = :private # not null
@account.dissubscribable = false # not null
@account.save
end
@ -115,6 +116,7 @@ class ActivityPub::ProcessAccountService < BaseService
@account.also_known_as = as_array(@json['alsoKnownAs'] || []).map { |item| value_or_id(item) }
@account.discoverable = @json['discoverable'] || false
@account.searchability = searchability_from_audience
@account.dissubscribable = !subscribable(@account.note)
end
def set_fetchable_key!
@ -249,6 +251,20 @@ class ActivityPub::ProcessAccountService < BaseService
end
end
def subscribable_by
return nil if @json['subscribableBy'].nil?
@subscribable_by = as_array(@json['subscribableBy']).map { |x| value_or_id(x) }
end
def subscribable(note)
if subscribable_by.nil?
!note.include?('[subscribable:no]')
else
subscribable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
end
end
def property_values
return unless @json['attachment'].is_a?(Array)

View file

@ -49,7 +49,7 @@ class FanOutOnWriteService < BaseService
when :public, :unlisted, :public_unlisted, :private
deliver_to_all_followers!
deliver_to_lists!
deliver_to_antennas! if [:public, :public_unlisted].include?(@status.visibility.to_sym)
deliver_to_antennas! if [:public, :public_unlisted].include?(@status.visibility.to_sym) && !@status.account.dissubscribable
when :limited
deliver_to_mentioned_followers!
else

View file

@ -38,6 +38,9 @@
.fields-group
= f.input :hide_collections, as: :boolean, wrapper: :with_label, label: t('simple_form.labels.defaults.setting_hide_network'), hint: t('simple_form.hints.defaults.setting_hide_network')
.fields-group
= f.input :dissubscribable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.dissubscribable')
%hr.spacer/
.fields-row

View file

@ -38,6 +38,7 @@ en:
current_username: To confirm, please enter the username of the current account
digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence
discoverable: Allow your account to be discovered by strangers through recommendations, trends and other features
dissubscribable: Your post is not picked by antenna
email: You will be sent a confirmation e-mail
fields: You can have up to 4 items displayed as a table on your profile
group: Reps sent to this account will be automatically BT'd and distributed to all accounts you follow!
@ -179,6 +180,7 @@ en:
data: Data
discoverable: Suggest account to others
display_name: Display name
dissubscribable: Reject any subscriptions
email: E-mail address
expires_in: Expire after
fields: Profile metadata

View file

@ -38,6 +38,7 @@ ja:
current_username: 確認のため、現在のアカウントのユーザー名を入力してください
digest: 長期間使用していない場合と不在時に返信を受けた場合のみ送信されます
discoverable: レコメンド、トレンド、その他の機能により、あなたのアカウントを他の人から見つけられるようにします
dissubscribable: あなたの投稿はすべてのアンテナに掲載されなくなります。Fedibirdからの購読やMisskeyのアンテナを拒否することはできません
email: 確認のメールが送信されます
fields: プロフィールに表として4つまでの項目を表示することができます
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
@ -180,6 +181,7 @@ ja:
data: データ
discoverable: ディレクトリに掲載する
display_name: 表示名
dissubscribable: 購読を拒否する
email: メールアドレス
expires_in: 有効期限
fields: プロフィール補足情報

View file

@ -0,0 +1,6 @@
class AddDissubscribableToAccounts < ActiveRecord::Migration[6.1]
def change
add_column :antennas, :with_media_only, :boolean, null: false, default: false, index: true
add_column :accounts, :dissubscribable, :boolean, null: false, default: false
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2023_04_23_002728) do
ActiveRecord::Schema.define(version: 2023_04_23_233429) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -191,6 +191,7 @@ ActiveRecord::Schema.define(version: 2023_04_23_002728) do
t.datetime "requested_review_at"
t.boolean "group_allow_private_message"
t.integer "searchability", default: 2, null: false
t.boolean "dissubscribable", 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 ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id", where: "(moved_to_account_id IS NOT NULL)"
@ -300,6 +301,7 @@ ActiveRecord::Schema.define(version: 2023_04_23_002728) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.datetime "expires_at"
t.boolean "with_media_only", default: false, null: false
t.index ["account_id"], name: "index_antennas_on_account_id"
t.index ["any_accounts"], name: "index_antennas_on_any_accounts"
t.index ["any_domains"], name: "index_antennas_on_any_domains"