Merge branch 'kb_development' into kb_migration
This commit is contained in:
commit
d6008cffb5
19 changed files with 161 additions and 23 deletions
|
@ -4,7 +4,7 @@ module Admin
|
|||
class StatusesController < BaseController
|
||||
before_action :set_account
|
||||
before_action :set_statuses, except: :show
|
||||
before_action :set_status, only: :show
|
||||
before_action :set_status, only: [:show, :remove_history, :remove_media, :force_sensitive, :force_cw, :remove_status]
|
||||
|
||||
PER_PAGE = 20
|
||||
|
||||
|
@ -29,6 +29,61 @@ module Admin
|
|||
redirect_to after_create_redirect_path
|
||||
end
|
||||
|
||||
def remove_history
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
no_history: true
|
||||
)
|
||||
log_action(:remove_history, @status)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def remove_media
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
media_ids: [],
|
||||
media_attributes: []
|
||||
)
|
||||
log_action(:remove_media, @status)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def force_sensitive
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
sensitive: true
|
||||
)
|
||||
log_action(:force_sensitive, @status)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def force_cw
|
||||
authorize [:admin, @status], :show?
|
||||
UpdateStatusService.new.call(
|
||||
@status,
|
||||
@account.id,
|
||||
spoiler_text: 'CW'
|
||||
)
|
||||
log_action(:force_cw, @status)
|
||||
redirect_to admin_account_status_path
|
||||
end
|
||||
|
||||
def remove_status
|
||||
authorize [:admin, @status], :show?
|
||||
@status.discard_with_reblogs
|
||||
StatusPin.find_by(status: @status)&.destroy
|
||||
@status.account.statuses_count = @status.account.statuses_count - 1
|
||||
RemovalWorker.perform_async(@status.id, { 'redraft' => false })
|
||||
log_action(:remove_status, @status)
|
||||
redirect_to admin_account_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def admin_status_batch_action_params
|
||||
|
|
|
@ -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, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :my_actor_type, :group_allow_private_message, :discoverable, :hide_collections, fields_attributes: [:name, :value])
|
||||
end
|
||||
|
||||
def set_account
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
# trendable :boolean
|
||||
# reviewed_at :datetime
|
||||
# requested_review_at :datetime
|
||||
# group_message_following_only :boolean
|
||||
# group_allow_private_message :boolean
|
||||
#
|
||||
|
||||
|
|
|
@ -4,14 +4,15 @@
|
|||
#
|
||||
# Table name: account_stats
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# statuses_count :bigint(8) default(0), not null
|
||||
# following_count :bigint(8) default(0), not null
|
||||
# followers_count :bigint(8) default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# last_status_at :datetime
|
||||
# id :bigint(8) not null, primary key
|
||||
# account_id :bigint(8) not null
|
||||
# statuses_count :bigint(8) default(0), not null
|
||||
# following_count :bigint(8) default(0), not null
|
||||
# followers_count :bigint(8) default(0), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# last_status_at :datetime
|
||||
# group_activitypub_count :integer
|
||||
#
|
||||
|
||||
class AccountStat < ApplicationRecord
|
||||
|
@ -33,4 +34,8 @@ class AccountStat < ApplicationRecord
|
|||
def statuses_count
|
||||
[attributes['statuses_count'], 0].max
|
||||
end
|
||||
|
||||
def group_activitypub_count
|
||||
[attributes['group_activitypub_count'] || 0, 0].max
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,6 +16,8 @@ module AccountCounters
|
|||
:following_count=,
|
||||
:followers_count,
|
||||
:followers_count=,
|
||||
:group_activitypub_count,
|
||||
:group_activitypub_count=,
|
||||
:last_status_at,
|
||||
to: :account_stat
|
||||
|
||||
|
|
|
@ -3,7 +3,11 @@
|
|||
class GroupReblogService < BaseService
|
||||
include RoutingHelper
|
||||
|
||||
ACTIVITYPUB_CONTINUOUS_SIZE = 30
|
||||
|
||||
def call(status)
|
||||
return nil if status.account.group?
|
||||
|
||||
visibility = status.visibility.to_sym
|
||||
return nil if !%i(public public_unlisted unlisted private direct).include?(visibility)
|
||||
|
||||
|
@ -12,11 +16,22 @@ class GroupReblogService < BaseService
|
|||
|
||||
accounts.each do |account|
|
||||
next unless account.local?
|
||||
next if account.group_message_following_only && !account.following?(status.account)
|
||||
next unless status.account.following?(account)
|
||||
next unless account.group?
|
||||
next if account.id == status.account_id
|
||||
next if transcription && !account.group_allow_private_message
|
||||
|
||||
if status.account.activitypub? && ACTIVITYPUB_CONTINUOUS_SIZE > 0
|
||||
next if account.group_activitypub_count >= ACTIVITYPUB_CONTINUOUS_SIZE
|
||||
account.group_activitypub_count = account.group_activitypub_count + 1
|
||||
account.save!
|
||||
else
|
||||
if account.group_activitypub_count > 0
|
||||
account.group_activitypub_count = 0
|
||||
account.save!
|
||||
end
|
||||
end
|
||||
|
||||
ReblogService.new.call(account, status, { visibility: status.visibility }) if !transcription
|
||||
|
||||
if transcription
|
||||
|
|
|
@ -23,12 +23,14 @@ class UpdateStatusService < BaseService
|
|||
@media_attachments_changed = false
|
||||
@poll_changed = false
|
||||
|
||||
clear_histories! if @options[:no_history]
|
||||
|
||||
Status.transaction do
|
||||
create_previous_edit!
|
||||
create_previous_edit! unless @options[:no_history]
|
||||
update_media_attachments! if @options.key?(:media_ids)
|
||||
update_poll! if @options.key?(:poll)
|
||||
update_immediate_attributes!
|
||||
create_edit!
|
||||
create_edit! unless @options[:no_history]
|
||||
end
|
||||
|
||||
queue_poll_notifications!
|
||||
|
@ -166,4 +168,10 @@ class UpdateStatusService < BaseService
|
|||
def significant_changes?
|
||||
@status.changed? || @poll_changed || @media_attachments_changed
|
||||
end
|
||||
|
||||
def clear_histories!
|
||||
@status.edits.destroy_all
|
||||
@status.edited_at = nil
|
||||
@status.save!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,6 +45,19 @@
|
|||
%th= t('admin.statuses.favourites')
|
||||
%td= friendly_number_to_human @status.favourites_count
|
||||
|
||||
%div.action-buttons
|
||||
%div
|
||||
- if @account.local?
|
||||
= link_to t('admin.statuses.remove_history'), remove_history_admin_account_status_path(@account.id), method: :post, class: 'button' if can?(:warn, @account)
|
||||
- if @account.local? && @status.with_media?
|
||||
= link_to t('admin.statuses.remove_media'), remove_media_admin_account_status_path(@account.id), method: :post, class: 'button' if can?(:warn, @account)
|
||||
- if @account.local? && !@status.sensitive && @status.with_media?
|
||||
= link_to t('admin.statuses.force_nsfw'), force_sensitive_admin_account_status_path(@account.id), method: :post, class: 'button' if can?(:warn, @account)
|
||||
- if @account.local? && !@status.spoiler_text.present?
|
||||
= link_to t('admin.statuses.force_cw'), force_cw_admin_account_status_path(@account.id), method: :post, class: 'button' if can?(:warn, @account)
|
||||
- if @account.local?
|
||||
= link_to t('admin.statuses.remove'), remove_status_admin_account_status_path(@account.id), method: :post, class: 'button' if can?(:warn, @account)
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('admin.statuses.history')
|
||||
|
|
|
@ -29,9 +29,6 @@
|
|||
.fields-group
|
||||
= f.input :my_actor_type, collection: ['person', 'bot', 'group'],label_method: lambda { |item| safe_join([t("simple_form.labels.defaults.#{item}"), content_tag(:span, I18n.t("simple_form.hints.defaults.#{item}"), class: 'hint')]) }, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label
|
||||
|
||||
.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')
|
||||
|
||||
|
|
|
@ -264,11 +264,16 @@ en:
|
|||
enable_custom_emoji_html: "%{name} enabled emoji %{target}"
|
||||
enable_sign_in_token_auth_user_html: "%{name} enabled e-mail token authentication for %{target}"
|
||||
enable_user_html: "%{name} enabled login for user %{target}"
|
||||
force_cw_status_html: "%{name} turned post by %{target} cw"
|
||||
force_sensitive_status_html: "%{name} turned post by %{target} sensitive"
|
||||
memorialize_account_html: "%{name} turned %{target}'s account into a memoriam page"
|
||||
promote_user_html: "%{name} promoted user %{target}"
|
||||
reject_appeal_html: "%{name} rejected moderation decision appeal from %{target}"
|
||||
reject_user_html: "%{name} rejected sign-up from %{target}"
|
||||
remove_avatar_user_html: "%{name} removed %{target}'s avatar"
|
||||
remove_history_status_html: "%{name} removed post edit histories by %{target}"
|
||||
remove_media_status_html: "%{name} removed post medias by %{target}"
|
||||
remove_status_status_html: "%{name} removed post by %{target}"
|
||||
reopen_report_html: "%{name} reopened report %{target}"
|
||||
resend_user_html: "%{name} resent confirmation e-mail for %{target}"
|
||||
reset_password_user_html: "%{name} reset password of user %{target}"
|
||||
|
@ -774,6 +779,8 @@ en:
|
|||
report: Report
|
||||
deleted: Deleted
|
||||
favourites: Favourites
|
||||
force_cw: Force CW
|
||||
force_nsfw: Force NSFW
|
||||
history: Version history
|
||||
in_reply_to: Replying to
|
||||
language: Language
|
||||
|
@ -784,6 +791,9 @@ en:
|
|||
open: Open post
|
||||
original_status: Original post
|
||||
reblogs: Reblogs
|
||||
remove: Remove post
|
||||
remove_media: Remove medias
|
||||
remove_history: Remove edit history
|
||||
status_changed: Post changed
|
||||
title: Account posts
|
||||
trending: Trending
|
||||
|
|
|
@ -261,11 +261,16 @@ ja:
|
|||
enable_custom_emoji_html: "%{name}さんがカスタム絵文字 %{target}を有効化しました"
|
||||
enable_sign_in_token_auth_user_html: "%{name}さんが%{target}さんのメールトークン認証を有効にしました"
|
||||
enable_user_html: "%{name}さんが%{target}さんのログインを有効化しました"
|
||||
force_cw_status_html: "%{name}さんが%{target}さんの投稿を強制的にCWにしました"
|
||||
force_sensitive_status_html: "%{name}さんが%{target}さんの投稿を強制的に閲覧注意にしました"
|
||||
memorialize_account_html: "%{name}さんが%{target}さんを追悼アカウントページに登録しました"
|
||||
promote_user_html: "%{name}さんが%{target}さんを昇格しました"
|
||||
reject_appeal_html: "%{name}さんが%{target}からの抗議を却下しました"
|
||||
reject_user_html: "%{name}さんが%{target}さんからの登録を拒否しました"
|
||||
remove_avatar_user_html: "%{name}さんが%{target}さんのアイコンを削除しました"
|
||||
remove_history_status_html: "%{name}さんが%{target}さんの投稿の編集履歴を削除しました"
|
||||
remove_media_status_html: "%{name}さんが%{target}さんの投稿のメディアを削除しました"
|
||||
remove_status_status_html: "%{name}さんが%{target}さんの投稿を削除しました"
|
||||
reopen_report_html: "%{name}さんが通報 %{target}を未解決に戻しました"
|
||||
resend_user_html: "%{name}さんが%{target}の確認メールを再送信しました"
|
||||
reset_password_user_html: "%{name}さんが%{target}さんのパスワードをリセットしました"
|
||||
|
@ -760,6 +765,8 @@ ja:
|
|||
report: 通報
|
||||
deleted: 削除済み
|
||||
favourites: お気に入り
|
||||
force_cw: 強制CW
|
||||
force_nsfw: 強制NSFW
|
||||
history: 更新履歴
|
||||
in_reply_to: 返信先
|
||||
language: 言語
|
||||
|
@ -770,6 +777,9 @@ ja:
|
|||
open: 投稿を開く
|
||||
original_status: オリジナルの投稿
|
||||
reblogs: ブースト
|
||||
remove: 投稿を削除
|
||||
remove_media: メディアを削除
|
||||
remove_history: 編集履歴を削除
|
||||
status_changed: 投稿を変更しました
|
||||
title: 投稿一覧
|
||||
trending: トレンド
|
||||
|
|
|
@ -42,7 +42,6 @@ en:
|
|||
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
|
||||
irreversible: Filtered posts will disappear irreversibly, even if filter is later removed
|
||||
|
@ -185,7 +184,6 @@ en:
|
|||
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)"
|
||||
inbox_url: URL of the relay inbox
|
||||
|
|
|
@ -42,7 +42,6 @@ ja:
|
|||
fields: プロフィールに表として4つまでの項目を表示することができます
|
||||
group: このアカウントに送られたメンションは自動でBTされ、フォローしている全てのアカウントに配信されます
|
||||
group_allow_private_message: 投稿は複製されるため、投稿者が編集・削除することはできません
|
||||
group_message_following_only: 荒らし・スパム対策として有効ですが、加入者をフォローする手間が発生します
|
||||
header: "%{size}までのPNG、GIF、JPGが利用可能です。 %{dimensions}pxまで縮小されます"
|
||||
inbox_url: 使用したいリレーサーバーのトップページからURLをコピーします
|
||||
irreversible: フィルターが後で削除されても、除外された投稿は元に戻せなくなります
|
||||
|
@ -185,7 +184,6 @@ ja:
|
|||
fields: プロフィール補足情報
|
||||
group: これはグループアカウントです
|
||||
group_allow_private_message: グループアカウントの場合、フォロワーのみ・ダイレクトのメンションを複製する
|
||||
group_message_following_only: グループアカウントの場合、自分がフォローしている相手からのメンションのみをBTする
|
||||
header: ヘッダー
|
||||
honeypot: "%{label} (入力しない)"
|
||||
inbox_url: リレーサーバーの inbox URL
|
||||
|
|
|
@ -355,6 +355,14 @@ Rails.application.routes.draw do
|
|||
resource :action, only: [:new, :create], controller: 'account_actions'
|
||||
|
||||
resources :statuses, only: [:index, :show] do
|
||||
member do
|
||||
post :remove_history
|
||||
post :remove_media
|
||||
post :force_sensitive
|
||||
post :force_cw
|
||||
post :remove_status
|
||||
end
|
||||
|
||||
collection do
|
||||
post :batch
|
||||
end
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupMessageFollowingOnlyToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_message_following_only, :boolean
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupAllowPrivateMessageToAccounts < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :accounts, :group_allow_private_message, :boolean
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddGroupActivityPubCountToAccountStats < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :account_stats, :group_activitypub_count, :integer
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveGroupMessageFollowingOnlyFromAccounts < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
safety_assured { remove_column :accounts, :group_message_following_only, :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_081013) do
|
||||
ActiveRecord::Schema.define(version: 2023_03_14_121142) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -99,6 +99,7 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
|||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "last_status_at"
|
||||
t.integer "group_activitypub_count"
|
||||
t.index ["account_id"], name: "index_account_stats_on_account_id", unique: true
|
||||
end
|
||||
|
||||
|
@ -186,7 +187,6 @@ ActiveRecord::Schema.define(version: 2023_03_14_081013) do
|
|||
t.boolean "trendable"
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue