* Add: #699 引用・参照対応サーバーをAPIで取得 * Complete * ごめん
This commit is contained in:
parent
78b2707c08
commit
1c054ed3a3
22 changed files with 129 additions and 29 deletions
|
@ -31,6 +31,13 @@ export interface ApiAccountOtherSettingsJSON {
|
||||||
subscription_policy: 'allow' | 'followers_only' | 'block';
|
subscription_policy: 'allow' | 'followers_only' | 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApiServerFeaturesJSON {
|
||||||
|
circle: boolean;
|
||||||
|
emoji_reaction: boolean;
|
||||||
|
quote: boolean;
|
||||||
|
status_reference: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
// See app/serializers/rest/account_serializer.rb
|
// See app/serializers/rest/account_serializer.rb
|
||||||
export interface ApiAccountJSON {
|
export interface ApiAccountJSON {
|
||||||
acct: string;
|
acct: string;
|
||||||
|
@ -56,6 +63,7 @@ export interface ApiAccountJSON {
|
||||||
note: string;
|
note: string;
|
||||||
other_settings: ApiAccountOtherSettingsJSON;
|
other_settings: ApiAccountOtherSettingsJSON;
|
||||||
roles?: ApiAccountJSON[];
|
roles?: ApiAccountJSON[];
|
||||||
|
server_features: ApiServerFeaturesJSON;
|
||||||
subscribable: boolean;
|
subscribable: boolean;
|
||||||
statuses_count: number;
|
statuses_count: number;
|
||||||
uri: string;
|
uri: string;
|
||||||
|
|
|
@ -606,7 +606,7 @@ class Status extends ImmutablePureComponent {
|
||||||
let emojiReactionsBar = null;
|
let emojiReactionsBar = null;
|
||||||
if (!this.props.withoutEmojiReactions && status.get('emoji_reactions')) {
|
if (!this.props.withoutEmojiReactions && status.get('emoji_reactions')) {
|
||||||
const emojiReactions = status.get('emoji_reactions');
|
const emojiReactions = status.get('emoji_reactions');
|
||||||
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.getIn(['account', 'emoji_reaction_available_server']);
|
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.getIn(['account', 'server_features', 'emoji_reaction']);
|
||||||
if (emojiReactions.size > 0 && enableEmojiReaction && emojiReactionAvailableServer) {
|
if (emojiReactions.size > 0 && enableEmojiReaction && emojiReactionAvailableServer) {
|
||||||
emojiReactionsBar = <StatusEmojiReactionsBar emojiReactions={emojiReactions} myReactionOnly={!isShowItem('emoji_reaction_on_timeline')} status={status} onEmojiReact={this.props.onEmojiReact} onUnEmojiReact={this.props.onUnEmojiReact} />;
|
emojiReactionsBar = <StatusEmojiReactionsBar emojiReactions={emojiReactions} myReactionOnly={!isShowItem('emoji_reaction_on_timeline')} status={status} onEmojiReact={this.props.onEmojiReact} onUnEmojiReact={this.props.onUnEmojiReact} />;
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,11 +350,13 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancelReblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });
|
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancelReblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });
|
||||||
|
|
||||||
if (publicStatus) {
|
if (publicStatus) {
|
||||||
if (allowQuote) {
|
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
|
||||||
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
|
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
|
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
|
||||||
|
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,11 +441,13 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicStatus) {
|
if (publicStatus) {
|
||||||
if (allowQuote) {
|
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
|
||||||
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
|
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
|
||||||
}
|
}
|
||||||
|
|
||||||
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
|
||||||
|
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +489,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
||||||
<IconButton className='status__action-bar__button' title={intl.formatMessage(messages.hide)} icon='eye' iconComponent={VisibilityIcon} onClick={this.handleHideClick} />
|
<IconButton className='status__action-bar__button' title={intl.formatMessage(messages.hide)} icon='eye' iconComponent={VisibilityIcon} onClick={this.handleHideClick} />
|
||||||
);
|
);
|
||||||
|
|
||||||
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || account.get('emoji_reaction_available_server');
|
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || account.getIn(['server_features', 'emoji_reaction']);
|
||||||
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
|
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
|
||||||
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
|
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
|
||||||
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
|
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
|
||||||
|
|
|
@ -277,11 +277,13 @@ class ActionBar extends PureComponent {
|
||||||
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancel_reblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });
|
menu.push({ text: intl.formatMessage(status.get('reblogged') ? messages.cancel_reblog : messages.reblog), action: this.handleReblogForceModalClick, tag: 'reblog' });
|
||||||
|
|
||||||
if (publicStatus) {
|
if (publicStatus) {
|
||||||
if (allowQuote) {
|
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
|
||||||
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
|
menu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote, tag: 'reblog' });
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
|
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
|
||||||
|
menu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference, tag: 'reblog' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,11 +358,13 @@ class ActionBar extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (publicStatus) {
|
if (publicStatus) {
|
||||||
if (allowQuote) {
|
if (allowQuote && (account.getIn(['server_features', 'quote']) || !isHideItem('quote_unavailable_server'))) {
|
||||||
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
|
reblogMenu.push({ text: intl.formatMessage(messages.quote), action: this.handleQuote });
|
||||||
}
|
}
|
||||||
|
|
||||||
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
if (account.getIn(['server_features', 'status_reference']) || !isHideItem('status_reference_unavailable_server')) {
|
||||||
|
reblogMenu.push({ text: intl.formatMessage(messages.reference), action: this.handleReference });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +399,7 @@ class ActionBar extends PureComponent {
|
||||||
reblogMenu = [];
|
reblogMenu = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || account.get('emoji_reaction_available_server');
|
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || account.getIn(['server_features', 'emoji_reaction']);
|
||||||
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
|
const emojiReactionPolicy = account.getIn(['other_settings', 'emoji_reaction_policy']) || 'allow';
|
||||||
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
|
const following = emojiReactionPolicy !== 'following_only' || (relationship && relationship.get('following'));
|
||||||
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
|
const followed = emojiReactionPolicy !== 'followers_only' || (relationship && relationship.get('followed_by'));
|
||||||
|
|
|
@ -222,7 +222,7 @@ class DetailedStatus extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
let emojiReactionsBar = null;
|
let emojiReactionsBar = null;
|
||||||
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.getIn(['account', 'emoji_reaction_available_server']);
|
const emojiReactionAvailableServer = !isHideItem('emoji_reaction_unavailable_server') || status.getIn(['account', 'server_features', 'emoji_reaction']);
|
||||||
if (status.get('emoji_reactions')) {
|
if (status.get('emoji_reactions')) {
|
||||||
const emojiReactions = status.get('emoji_reactions');
|
const emojiReactions = status.get('emoji_reactions');
|
||||||
if (emojiReactions.size > 0 && enableEmojiReaction && emojiReactionAvailableServer) {
|
if (emojiReactions.size > 0 && enableEmojiReaction && emojiReactionAvailableServer) {
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
* | 'favourite_menu'
|
* | 'favourite_menu'
|
||||||
* | 'quote_in_home'
|
* | 'quote_in_home'
|
||||||
* | 'quote_in_public'
|
* | 'quote_in_public'
|
||||||
|
* | 'quote_unavailable_server'
|
||||||
* | 'recent_emojis'
|
* | 'recent_emojis'
|
||||||
* | 'relationships'
|
* | 'relationships'
|
||||||
|
* | 'status_reference_unavailable_server'
|
||||||
* } HideItemsDefinition
|
* } HideItemsDefinition
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import type {
|
||||||
ApiAccountRoleJSON,
|
ApiAccountRoleJSON,
|
||||||
ApiAccountOtherSettingsJSON,
|
ApiAccountOtherSettingsJSON,
|
||||||
ApiAccountJSON,
|
ApiAccountJSON,
|
||||||
|
ApiServerFeaturesJSON,
|
||||||
} from 'mastodon/api_types/accounts';
|
} from 'mastodon/api_types/accounts';
|
||||||
import type { ApiCustomEmojiJSON } from 'mastodon/api_types/custom_emoji';
|
import type { ApiCustomEmojiJSON } from 'mastodon/api_types/custom_emoji';
|
||||||
import emojify from 'mastodon/features/emoji/emoji';
|
import emojify from 'mastodon/features/emoji/emoji';
|
||||||
|
@ -61,6 +62,18 @@ const AccountOtherSettingsFactory = ImmutableRecord<AccountOtherSettingsShape>({
|
||||||
subscription_policy: 'allow',
|
subscription_policy: 'allow',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ServerFeatures
|
||||||
|
export type AccountServerFeaturesShape = ApiServerFeaturesJSON;
|
||||||
|
export type AccountServerFeatures = RecordOf<AccountServerFeaturesShape>;
|
||||||
|
|
||||||
|
const AccountServerFeaturesFactory =
|
||||||
|
ImmutableRecord<AccountServerFeaturesShape>({
|
||||||
|
circle: false,
|
||||||
|
emoji_reaction: false,
|
||||||
|
quote: false,
|
||||||
|
status_reference: false,
|
||||||
|
});
|
||||||
|
|
||||||
// Account
|
// Account
|
||||||
export interface AccountShape
|
export interface AccountShape
|
||||||
extends Required<
|
extends Required<
|
||||||
|
@ -88,6 +101,7 @@ export const accountDefaultValues: AccountShape = {
|
||||||
indexable: false,
|
indexable: false,
|
||||||
display_name: '',
|
display_name: '',
|
||||||
display_name_html: '',
|
display_name_html: '',
|
||||||
|
server_features: AccountServerFeaturesFactory(),
|
||||||
emoji_reaction_available_server: false,
|
emoji_reaction_available_server: false,
|
||||||
emojis: List<CustomEmoji>(),
|
emojis: List<CustomEmoji>(),
|
||||||
fields: List<AccountField>(),
|
fields: List<AccountField>(),
|
||||||
|
|
|
@ -31,6 +31,8 @@ class EntityCache
|
||||||
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
uncached ||= {}
|
||||||
|
|
||||||
shortcodes.filter_map { |shortcode| cached[to_key(:emoji, shortcode, domain)] || uncached[shortcode] }
|
shortcodes.filter_map { |shortcode| cached[to_key(:emoji, shortcode, domain)] || uncached[shortcode] }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,14 @@ module User::HasSettings
|
||||||
settings['web.hide_emoji_reaction_unavailable_server']
|
settings['web.hide_emoji_reaction_unavailable_server']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setting_hide_quote_unavailable_server
|
||||||
|
settings['web.hide_quote_unavailable_server']
|
||||||
|
end
|
||||||
|
|
||||||
|
def setting_hide_status_reference_unavailable_server
|
||||||
|
settings['web.hide_status_reference_unavailable_server']
|
||||||
|
end
|
||||||
|
|
||||||
def setting_hide_emoji_reaction_count
|
def setting_hide_emoji_reaction_count
|
||||||
settings['web.hide_emoji_reaction_count']
|
settings['web.hide_emoji_reaction_count']
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,12 @@ class InstanceInfo < ApplicationRecord
|
||||||
sharkey
|
sharkey
|
||||||
).freeze
|
).freeze
|
||||||
|
|
||||||
|
QUOTE_AVAILABLE_SOFTWARES = EMOJI_REACTION_AVAILABLE_SOFTWARES
|
||||||
|
|
||||||
|
STATUS_REFERENCE_AVAILABLE_SOFTWARES = %w(fedibird).freeze
|
||||||
|
|
||||||
|
CIRCLE_AVAILABLE_SOFTWARES = %w(fedibird).freeze
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
def emoji_reaction_available?(domain)
|
def emoji_reaction_available?(domain)
|
||||||
return Setting.enable_emoji_reaction if domain.nil?
|
return Setting.enable_emoji_reaction if domain.nil?
|
||||||
|
@ -38,12 +44,39 @@ class InstanceInfo < ApplicationRecord
|
||||||
Rails.cache.fetch("emoji_reaction_available_domain:#{domain}") { load_emoji_reaction_available(domain) }
|
Rails.cache.fetch("emoji_reaction_available_domain:#{domain}") { load_emoji_reaction_available(domain) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def available_features(domain)
|
||||||
|
return local_features if domain.nil?
|
||||||
|
|
||||||
|
Rails.cache.fetch("domain_available_features:#{domain}") { load_available_features(domain) }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def load_emoji_reaction_available(domain)
|
def load_available_features(domain)
|
||||||
|
return local_features if domain.nil?
|
||||||
|
|
||||||
info = InstanceInfo.find_by(domain: domain)
|
info = InstanceInfo.find_by(domain: domain)
|
||||||
|
|
||||||
|
{
|
||||||
|
emoji_reaction: feature_available?(info, EMOJI_REACTION_AVAILABLE_SOFTWARES, 'emoji_reaction'),
|
||||||
|
quote: feature_available?(info, QUOTE_AVAILABLE_SOFTWARES, 'quote'),
|
||||||
|
status_reference: feature_available?(info, STATUS_REFERENCE_AVAILABLE_SOFTWARES, 'status_reference'),
|
||||||
|
circle: feature_available?(info, CIRCLE_AVAILABLE_SOFTWARES, 'circle'),
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def local_features
|
||||||
|
{
|
||||||
|
emoji_reaction: Setting.enable_emoji_reaction,
|
||||||
|
quote: true,
|
||||||
|
status_reference: true,
|
||||||
|
circle: true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def feature_available?(info, softwares, feature_name)
|
||||||
return false if info.nil?
|
return false if info.nil?
|
||||||
return true if EMOJI_REACTION_AVAILABLE_SOFTWARES.include?(info['software'])
|
return true if softwares.include?(info['software'])
|
||||||
|
|
||||||
return false unless info.data.is_a?(Hash)
|
return false unless info.data.is_a?(Hash)
|
||||||
return false unless info.data['metadata'].is_a?(Hash)
|
return false unless info.data['metadata'].is_a?(Hash)
|
||||||
|
@ -51,7 +84,7 @@ class InstanceInfo < ApplicationRecord
|
||||||
features = info.data.dig('metadata', 'features')
|
features = info.data.dig('metadata', 'features')
|
||||||
return false unless features.is_a?(Array)
|
return false unless features.is_a?(Array)
|
||||||
|
|
||||||
features.include?('emoji_reaction')
|
features.include?(feature_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -59,5 +92,6 @@ class InstanceInfo < ApplicationRecord
|
||||||
|
|
||||||
def reset_cache
|
def reset_cache
|
||||||
Rails.cache.delete("emoji_reaction_available_domain:#{domain}")
|
Rails.cache.delete("emoji_reaction_available_domain:#{domain}")
|
||||||
|
Rails.cache.delete("domain_available_features:#{domain}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -555,8 +555,8 @@ class Status < ApplicationRecord
|
||||||
Status.where(id: status_ids).pluck(:account_id).uniq.index_with { |a| Account.find_by(id: a).show_emoji_reaction?(my_account) }
|
Status.where(id: status_ids).pluck(:account_id).uniq.index_with { |a| Account.find_by(id: a).show_emoji_reaction?(my_account) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reaction_availables_map(domains)
|
def available_features_map(domains)
|
||||||
domains.index_with { |d| InstanceInfo.emoji_reaction_available?(d) }
|
domains.index_with { |d| InstanceInfo.available_features(d) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_text(text)
|
def from_text(text)
|
||||||
|
|
|
@ -75,6 +75,8 @@ class UserSettings
|
||||||
setting :show_relationships, default: true
|
setting :show_relationships, default: true
|
||||||
setting :hide_blocking_quote, default: true
|
setting :hide_blocking_quote, default: true
|
||||||
setting :hide_emoji_reaction_unavailable_server, default: false
|
setting :hide_emoji_reaction_unavailable_server, default: false
|
||||||
|
setting :hide_quote_unavailable_server, default: false
|
||||||
|
setting :hide_status_reference_unavailable_server, default: false
|
||||||
setting :hide_favourite_menu, default: false
|
setting :hide_favourite_menu, default: false
|
||||||
setting :hide_emoji_reaction_count, default: false
|
setting :hide_emoji_reaction_count, default: false
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ class StatusRelationshipsPresenter
|
||||||
PINNABLE_VISIBILITIES = %w(public public_unlisted unlisted login private).freeze
|
PINNABLE_VISIBILITIES = %w(public public_unlisted unlisted login private).freeze
|
||||||
|
|
||||||
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map, :blocks_map, :domain_blocks_map,
|
attr_reader :reblogs_map, :favourites_map, :mutes_map, :pins_map, :blocks_map, :domain_blocks_map,
|
||||||
:bookmarks_map, :filters_map, :attributes_map, :emoji_reaction_allows_map, :emoji_reaction_availables_map
|
:bookmarks_map, :filters_map, :attributes_map, :emoji_reaction_allows_map
|
||||||
|
|
||||||
def initialize(statuses, current_account_id = nil, **options)
|
def initialize(statuses, current_account_id = nil, **options)
|
||||||
@current_account_id = current_account_id
|
@current_account_id = current_account_id
|
||||||
|
|
|
@ -42,6 +42,8 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
object_account_user.setting_hide_recent_emojis ? 'recent_emojis' : nil,
|
object_account_user.setting_hide_recent_emojis ? 'recent_emojis' : nil,
|
||||||
object_account_user.setting_hide_blocking_quote ? 'blocking_quote' : nil,
|
object_account_user.setting_hide_blocking_quote ? 'blocking_quote' : nil,
|
||||||
object_account_user.setting_hide_emoji_reaction_unavailable_server ? 'emoji_reaction_unavailable_server' : nil,
|
object_account_user.setting_hide_emoji_reaction_unavailable_server ? 'emoji_reaction_unavailable_server' : nil,
|
||||||
|
object_account_user.setting_hide_quote_unavailable_server ? 'quote_unavailable_server' : nil,
|
||||||
|
object_account_user.setting_hide_status_reference_unavailable_server ? 'status_reference_unavailable_server' : nil,
|
||||||
object_account_user.setting_hide_emoji_reaction_count ? 'emoji_reaction_count' : nil,
|
object_account_user.setting_hide_emoji_reaction_count ? 'emoji_reaction_count' : nil,
|
||||||
object_account_user.setting_show_emoji_reaction_on_timeline ? nil : 'emoji_reaction_on_timeline',
|
object_account_user.setting_show_emoji_reaction_on_timeline ? nil : 'emoji_reaction_on_timeline',
|
||||||
object_account_user.setting_show_quote_in_home ? nil : 'quote_in_home',
|
object_account_user.setting_show_quote_in_home ? nil : 'quote_in_home',
|
||||||
|
|
|
@ -8,7 +8,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :indexable, :group, :created_at,
|
attributes :id, :username, :acct, :display_name, :locked, :bot, :discoverable, :indexable, :group, :created_at,
|
||||||
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static, :subscribable, :emoji_reaction_available_server,
|
:note, :url, :uri, :avatar, :avatar_static, :header, :header_static, :subscribable, :emoji_reaction_available_server,
|
||||||
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections, :other_settings, :noindex
|
:followers_count, :following_count, :statuses_count, :last_status_at, :hide_collections, :other_settings, :noindex,
|
||||||
|
:server_features
|
||||||
|
|
||||||
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
|
||||||
|
|
||||||
|
@ -120,9 +121,11 @@ class REST::AccountSerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def emoji_reaction_available_server
|
def emoji_reaction_available_server
|
||||||
return Setting.enable_emoji_reaction if object.local?
|
server_features[:emoji_reaction]
|
||||||
|
end
|
||||||
|
|
||||||
InstanceInfo.emoji_reaction_available?(object.domain)
|
def server_features
|
||||||
|
InstanceInfo.available_features(object.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
def moved_to_account
|
def moved_to_account
|
||||||
|
|
|
@ -66,9 +66,16 @@
|
||||||
- if Setting.enable_emoji_reaction
|
- if Setting.enable_emoji_reaction
|
||||||
= ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction')
|
= ff.input :'web.enable_emoji_reaction', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_enable_emoji_reaction'), hint: I18n.t('simple_form.hints.defaults.setting_enable_emoji_reaction')
|
||||||
= ff.input :'web.show_emoji_reaction_on_timeline', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_on_timeline')
|
= ff.input :'web.show_emoji_reaction_on_timeline', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_on_timeline')
|
||||||
= ff.input :'web.hide_emoji_reaction_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_emoji_reaction_unavailable_server')
|
|
||||||
= ff.input :'web.show_emoji_reaction_count', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_count')
|
= ff.input :'web.show_emoji_reaction_count', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_show_emoji_reaction_count')
|
||||||
|
|
||||||
|
%h4= t 'appearance.remote_server_features'
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
- if Setting.enable_emoji_reaction
|
||||||
|
= ff.input :'web.hide_emoji_reaction_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_emoji_reaction_unavailable_server')
|
||||||
|
= ff.input :'web.hide_quote_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_quote_unavailable_server')
|
||||||
|
= ff.input :'web.hide_status_reference_unavailable_server', wrapper: :with_label, kmyblue: true, label: I18n.t('simple_form.labels.defaults.setting_hide_status_reference_unavailable_server')
|
||||||
|
|
||||||
%h4= t 'appearance.saved_posts'
|
%h4= t 'appearance.saved_posts'
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -1337,6 +1337,7 @@ en:
|
||||||
guide_link_text: Everyone can contribute.
|
guide_link_text: Everyone can contribute.
|
||||||
media: Media
|
media: Media
|
||||||
quotes: Quotes
|
quotes: Quotes
|
||||||
|
remote_server_features: Other server features
|
||||||
saved_posts: Saving posts
|
saved_posts: Saving posts
|
||||||
sensitive_content: Sensitive content
|
sensitive_content: Sensitive content
|
||||||
status_action_bar: Post menu
|
status_action_bar: Post menu
|
||||||
|
|
|
@ -1330,6 +1330,7 @@ ja:
|
||||||
guide_link_text: 誰でも参加することができます。
|
guide_link_text: 誰でも参加することができます。
|
||||||
media: メディア
|
media: メディア
|
||||||
quotes: 引用
|
quotes: 引用
|
||||||
|
remote_server_features: 他のサーバーの機能
|
||||||
saved_posts: 投稿の記録
|
saved_posts: 投稿の記録
|
||||||
sensitive_content: 閲覧注意コンテンツ
|
sensitive_content: 閲覧注意コンテンツ
|
||||||
status_action_bar: 投稿のメニュー
|
status_action_bar: 投稿のメニュー
|
||||||
|
|
|
@ -280,6 +280,8 @@ en:
|
||||||
setting_expand_spoilers: Always expand posts marked with content warnings
|
setting_expand_spoilers: Always expand posts marked with content warnings
|
||||||
setting_hide_emoji_reaction_unavailable_server: Hide emoji reaction button from unavailable server
|
setting_hide_emoji_reaction_unavailable_server: Hide emoji reaction button from unavailable server
|
||||||
setting_hide_network: Hide your social graph
|
setting_hide_network: Hide your social graph
|
||||||
|
setting_hide_quote_unavailable_server: Hide quote menu from unavailable server
|
||||||
|
setting_hide_status_reference_unavailable_server: Hide quiet quote (reference named by Fedibird) menu from unavailable server
|
||||||
setting_lock_follow_from_bot: Request approval about bot follow
|
setting_lock_follow_from_bot: Request approval about bot follow
|
||||||
setting_public_post_to_unlisted: Convert public post to public unlisted if not using Web app
|
setting_public_post_to_unlisted: Convert public post to public unlisted if not using Web app
|
||||||
setting_reduce_motion: Reduce motion in animations
|
setting_reduce_motion: Reduce motion in animations
|
||||||
|
|
|
@ -287,6 +287,8 @@ ja:
|
||||||
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
|
setting_expand_spoilers: 閲覧注意としてマークされた投稿を常に展開する
|
||||||
setting_hide_emoji_reaction_unavailable_server: 絵文字リアクションに対応していないと思われるサーバーの投稿から絵文字リアクション機能を隠す
|
setting_hide_emoji_reaction_unavailable_server: 絵文字リアクションに対応していないと思われるサーバーの投稿から絵文字リアクション機能を隠す
|
||||||
setting_hide_network: 繋がりを隠す
|
setting_hide_network: 繋がりを隠す
|
||||||
|
setting_hide_quote_unavailable_server: 引用に対応していないと思われるサーバーの投稿からメニューを隠す
|
||||||
|
setting_hide_status_reference_unavailable_server: ひかえめな引用(Fedibirdの参照)に対応していないと思われるサーバーの投稿からメニューを隠す
|
||||||
setting_lock_follow_from_bot: botからのフォローを承認制にする
|
setting_lock_follow_from_bot: botからのフォローを承認制にする
|
||||||
setting_show_blocking_quote: ブロックしたユーザーの投稿を引用した投稿を表示する
|
setting_show_blocking_quote: ブロックしたユーザーの投稿を引用した投稿を表示する
|
||||||
setting_show_emoji_reaction_count: 投稿につけられた各絵文字の数を表示する
|
setting_show_emoji_reaction_count: 投稿につけられた各絵文字の数を表示する
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe InstanceInfo do
|
RSpec.describe InstanceInfo do
|
||||||
describe '.emoji_reaction_availables_map' do
|
describe '.available_features' do
|
||||||
subject { described_class.emoji_reaction_available?('example.com') }
|
subject { described_class.available_features('example.com')[:emoji_reaction] }
|
||||||
|
|
||||||
|
it 'availables if local account' do
|
||||||
|
expect(described_class.available_features(nil)[:emoji_reaction]).to be true
|
||||||
|
end
|
||||||
|
|
||||||
it 'availables if features contains emoji_reaction' do
|
it 'availables if features contains emoji_reaction' do
|
||||||
Fabricate(:instance_info, domain: 'example.com', software: 'mastodon', data: { metadata: { features: ['emoji_reaction'] } })
|
Fabricate(:instance_info, domain: 'example.com', software: 'mastodon', data: { metadata: { features: ['emoji_reaction'] } })
|
||||||
|
|
|
@ -460,8 +460,8 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.emoji_reaction_availables_map' do
|
describe '.available_features_map' do
|
||||||
subject { described_class.emoji_reaction_availables_map(domains) }
|
subject { described_class.available_features_map(domains) }
|
||||||
|
|
||||||
let(:domains) { %w(features_available.com mastodon.com misskey.com) }
|
let(:domains) { %w(features_available.com mastodon.com misskey.com) }
|
||||||
|
|
||||||
|
@ -472,15 +472,15 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'availables if features contains emoji_reaction' do
|
it 'availables if features contains emoji_reaction' do
|
||||||
expect(subject['features_available.com']).to be true
|
expect(subject['features_available.com'][:emoji_reaction]).to be true
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'unavailables if mastodon server' do
|
it 'unavailables if mastodon server' do
|
||||||
expect(subject['mastodon.com']).to be false
|
expect(subject['mastodon.com'][:emoji_reaction]).to be false
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'availables if misskey server' do
|
it 'availables if misskey server' do
|
||||||
expect(subject['misskey.com']).to be true
|
expect(subject['misskey.com'][:emoji_reaction]).to be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue