Add switch private messages support
This commit is contained in:
parent
38100df205
commit
4439f0255c
8 changed files with 24 additions and 7 deletions
|
@ -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, :group_message_following_only, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_message_following_only, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
end
|
||||
|
||||
def set_account
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
# reviewed_at :datetime
|
||||
# requested_review_at :datetime
|
||||
# group_message_following_only :boolean
|
||||
# group_allow_private_message :boolean
|
||||
#
|
||||
|
||||
class Account < ApplicationRecord
|
||||
|
|
|
@ -5,16 +5,17 @@ class GroupReblogService < BaseService
|
|||
|
||||
def call(status)
|
||||
visibility = status.visibility.to_sym
|
||||
return nil if !%i(public public_unlisted unlisted private).include?(visibility)
|
||||
return nil if !%i(public public_unlisted unlisted private direct).include?(visibility)
|
||||
|
||||
accounts = status.mentions.map(&:account) | status.active_mentions.map(&:account)
|
||||
transcription = visibility == :private
|
||||
transcription = %i(private direct).include?(visibility)
|
||||
|
||||
accounts.each do |account|
|
||||
next unless account.local?
|
||||
next if account.group_message_following_only && !account.following?(status.account)
|
||||
next unless account.group?
|
||||
next if account.id == status.account_id
|
||||
next if transcription && !account.group_allow_private_message
|
||||
|
||||
ReblogService.new.call(account, status, { visibility: status.visibility }) if !transcription
|
||||
|
||||
|
@ -33,14 +34,16 @@ class GroupReblogService < BaseService
|
|||
end
|
||||
end
|
||||
|
||||
text = status.account.local? ? status.text : strip_tags(status.text.gsub(/<br>/, "\n").gsub(/<br \/>/, "\n").gsub(/<\/p>/, "\n\n").strip)
|
||||
|
||||
PostStatusService.new.call(
|
||||
account,
|
||||
text: "Private message by @#{username}\n\\-\\-\\-\\-\n#{status.text}",
|
||||
text: "Private message by @#{username}\n\\-\\-\\-\\-\n#{text}",
|
||||
thread: status.thread,
|
||||
media_ids: media_attachments.map(&:id),
|
||||
sensitive: status.sensitive,
|
||||
spoiler_text: status.spoiler_text,
|
||||
visibility: status.visibility,
|
||||
visibility: :private,
|
||||
language: status.language,
|
||||
poll: status.poll,
|
||||
with_rate_limit: true
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
.fields-group
|
||||
= f.input :group_message_following_only, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_message_following_only')
|
||||
|
||||
.fields-group
|
||||
= f.input :group_allow_private_message, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.group_allow_private_message')
|
||||
|
||||
.fields-group
|
||||
= f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable'), recommended: true
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ en:
|
|||
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!
|
||||
group_allow_private_message: Posts are duplicated and cannot be edited or deleted by the post
|
||||
group_message_following_only: Effective as an anti-troll/spam measure, but requires the effort to follow up with subscribers
|
||||
header: PNG, GIF or JPG. At most %{size}. Will be downscaled to %{dimensions}px
|
||||
inbox_url: Copy the URL from the frontpage of the relay you want to use
|
||||
|
@ -183,6 +184,7 @@ en:
|
|||
expires_in: Expire after
|
||||
fields: Profile metadata
|
||||
group: This is a group account
|
||||
group_allow_private_message: For group accounts, duplicate private or direct message
|
||||
group_message_following_only: For group accounts, BT only mentions from people you are following
|
||||
header: Header
|
||||
honeypot: "%{label} (do not fill in)"
|
||||
|
|
|
@ -40,7 +40,8 @@ ja:
|
|||
discoverable: レコメンド、トレンド、その他の機能により、あなたのアカウントを他の人から見つけられるようにします
|
||||
email: 確認のメールが送信されます
|
||||
fields: プロフィールに表として4つまでの項目を表示することができます
|
||||
group: このアカウントに送られたリプは自動でBTされ、フォローしている全てのアカウントに配信されます
|
||||
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
|
||||
group_allow_private_message: 投稿は複製されるため、投稿者が編集・削除することはできません
|
||||
group_message_following_only: 荒らし・スパム対策として有効ですが、加入者をフォローする手間が発生します
|
||||
header: "%{size}までのPNG、GIF、JPGが利用可能です。 %{dimensions}pxまで縮小されます"
|
||||
inbox_url: 使用したいリレーサーバーのトップページからURLをコピーします
|
||||
|
@ -183,6 +184,7 @@ ja:
|
|||
expires_in: 有効期限
|
||||
fields: プロフィール補足情報
|
||||
group: これはグループアカウントです
|
||||
group_allow_private_message: グループアカウントの場合、フォロワーのみ・ダイレクトのメンションを複製する
|
||||
group_message_following_only: グループアカウントの場合、自分がフォローしている相手からのメンションのみをBTする
|
||||
header: ヘッダー
|
||||
honeypot: "%{label} (入力しない)"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_allow_private_message, :boolean
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2023_03_14_021909) do
|
||||
ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -187,6 +187,7 @@ ActiveRecord::Schema.define(version: 2023_03_14_021909) do
|
|||
t.datetime "reviewed_at"
|
||||
t.datetime "requested_review_at"
|
||||
t.boolean "group_message_following_only"
|
||||
t.boolean "group_allow_private_message"
|
||||
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)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue