Skip to content

Commit

Permalink
ブロック設定追加、バグ修正
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 2, 2023
1 parent 8da842d commit 153c1c8
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/javascript/mastodon/actions/importer/normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export function normalizeStatus(status, normalOldStatus) {
normalStatus.spoiler_text = normalOldStatus.get('spoiler_text');
normalStatus.hidden = normalOldStatus.get('hidden');

// for quoted post
if (!normalStatus.filtered && normalOldStatus.get('filtered')) {
normalStatus.filtered = normalOldStatus.get('filtered');
}

if (normalOldStatus.get('translation')) {
normalStatus.translation = normalOldStatus.get('translation');
}
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/mastodon/initial_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* @property {boolean} enable_local_privacy
* @property {boolean} enable_dtl_menu
* @property {boolean=} expand_spoilers
* @property {boolean} hide_blocking_quote
* @property {boolean} hide_recent_emojis
* @property {boolean} limited_federation_mode
* @property {string} locale
Expand Down Expand Up @@ -138,6 +139,7 @@ export const enableLoginPrivacy = getMeta('enable_login_privacy');
export const enableDtlMenu = getMeta('enable_dtl_menu');
export const expandSpoilers = getMeta('expand_spoilers');
export const forceSingleColumn = !getMeta('advanced_layout');
export const hideBlockingQuote = getMeta('hide_blocking_quote');
export const hideRecentEmojis = getMeta('hide_recent_emojis');
export const limitedFederationMode = getMeta('limited_federation_mode');
export const mascot = getMeta('mascot');
Expand Down
6 changes: 5 additions & 1 deletion app/javascript/mastodon/selectors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createSelector } from 'reselect';

import { toServerSideType } from 'mastodon/utils/filters';

import { me } from '../initial_state';
import { me, hideBlockingQuote } from '../initial_state';

const getAccountBase = (state, id) => state.getIn(['accounts', id], null);
const getAccountCounters = (state, id) => state.getIn(['accounts_counters', id], null);
Expand Down Expand Up @@ -53,6 +53,10 @@ export const makeGetStatus = () => {
statusReblog = null;
}

if (hideBlockingQuote && statusBase.getIn(['quote', 'quote_muted'])) {
return null;
}

let filtered = false;
let filterAction = 'warn';
if ((accountReblog || accountBase).get('id') !== me && filters) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8490,7 +8490,7 @@ noscript {

&.status__wrapper__compact {
border-radius: 4px;
border: 1px solid $base-border-color;
border: 1px solid $ui-primary-color;
margin-block-start: 16px;
cursor: pointer;
}
Expand Down
4 changes: 4 additions & 0 deletions app/models/concerns/has_user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def setting_show_quote_in_public
settings['web.show_quote_in_public']
end

def setting_hide_blocking_quote
settings['web.hide_blocking_quote']
end

def setting_allow_quote
settings['allow_quote']
end
Expand Down
1 change: 1 addition & 0 deletions app/models/user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class KeyError < Error; end
setting :simple_timeline_menu, default: false
setting :show_quote_in_home, default: true
setting :show_quote_in_public, default: false
setting :hide_blocking_quote, default: true
end

namespace :notification_emails do
Expand Down
1 change: 1 addition & 0 deletions app/serializers/initial_state_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def meta
store[:simple_timeline_menu] = object.current_account.user.setting_simple_timeline_menu
store[:show_quote_in_home] = object.current_account.user.setting_show_quote_in_home
store[:show_quote_in_public] = object.current_account.user.setting_show_quote_in_public
store[:hide_blocking_quote] = object.current_account.user.setting_hide_blocking_quote
else
store[:auto_play_gif] = Setting.auto_play_gif
store[:display_media] = Setting.display_media
Expand Down
1 change: 1 addition & 0 deletions app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
.fields-group
= ff.input :'web.show_quote_in_home', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_quote_in_home'), hint: false
= ff.input :'web.show_quote_in_public', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_quote_in_public'), hint: false
= ff.input :'web.hide_blocking_quote', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_blocking_quote'), hint: false

.fields-group
= ff.input :'web.simple_timeline_menu', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_simple_timeline_menu')
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ en:
mutuals_only: Mutuals only
outside_only: Followings or followers only
setting_expand_spoilers: Always expand posts marked with content warnings
setting_hide_blocking_quote: Hide posts which have a quote written by the user you are blocking
setting_hide_followers_count: Hide followers count
setting_hide_following_count: Hide following count
setting_hide_network: Hide your social graph
Expand Down
1 change: 1 addition & 0 deletions config/locales/simple_form.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ ja:
setting_emoji_reaction_streaming_notify_impl2: Nyastodon, Catstodon, glitch-soc互換のスタンプ機能を有効にする
setting_enable_emoji_reaction: スタンプ機能を使用する
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
setting_hide_blocking_quote: ブロックしたユーザーの投稿を引用した投稿を隠す
setting_hide_followers_count: フォロワー数を隠す
setting_hide_following_count: フォロー数を隠す
setting_hide_network: 繋がりを隠す
Expand Down
53 changes: 53 additions & 0 deletions spec/services/process_references_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ def notify?(target_status_id = nil)
end
end

context 'with quote as parameter and embed' do
let(:text) { "Hello QT #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }

it 'post status' do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end

context 'with quote as parameter but embed is not quote' do
let(:text) { "Hello RE #{target_status_uri}" }
let(:quote_urls) { [ActivityPub::TagManager.instance.uri_for(target_status)] }

it 'post status' do
expect(subject.size).to eq 1
expect(subject.pluck(0)).to include target_status.id
expect(subject.pluck(1)).to include 'QT'
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?).to be true
end
end

context 'with quote and reference' do
let(:target_status2) { Fabricate(:status) }
let(:target_status2_uri) { ActivityPub::TagManager.instance.uri_for(target_status2) }
Expand Down Expand Up @@ -293,5 +321,30 @@ def notify?(target_status_id = nil)
expect(notify?(target_status2.id)).to be true
end
end

context 'when change quote to reference', pending: 'Will fix later' do
let(:text) { "QT #{target_status_uri}" }
let(:new_text) { "RT #{target_status_uri}" }

it 'post status' do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to be_nil
expect(notify?(target_status.id)).to be true
end
end

context 'when change reference to quote', pending: 'Will fix later' do
let(:text) { "RT #{target_status_uri}" }
let(:new_text) { "QT #{target_status_uri}" }

it 'post status' do
expect(subject.size).to eq 1
expect(subject).to include target_status.id
expect(status.quote).to_not be_nil
expect(status.quote.id).to eq target_status.id
expect(notify?(target_status.id)).to be true
end
end
end
end

0 comments on commit 153c1c8

Please sign in to comment.