Fix searchability api to compat with fedibird
This commit is contained in:
parent
6735a422ab
commit
de9e4b964c
9 changed files with 32 additions and 33 deletions
|
@ -10,12 +10,12 @@ import { Icon } from 'mastodon/components/icon';
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
public_short: { id: 'searchability.public.short', defaultMessage: 'Public' },
|
public_short: { id: 'searchability.public.short', defaultMessage: 'Public' },
|
||||||
public_long: { id: 'searchability.public.long', defaultMessage: 'Anyone can find' },
|
public_long: { id: 'searchability.public.long', defaultMessage: 'Anyone can find' },
|
||||||
unlisted_short: { id: 'searchability.unlisted.short', defaultMessage: 'Followers' },
|
private_short: { id: 'searchability.unlisted.short', defaultMessage: 'Followers' },
|
||||||
unlisted_long: { id: 'searchability.unlisted.long', defaultMessage: 'Your followers can find' },
|
private_long: { id: 'searchability.unlisted.long', defaultMessage: 'Your followers can find' },
|
||||||
private_short: { id: 'searchability.private.short', defaultMessage: 'Reactionners' },
|
direct_short: { id: 'searchability.private.short', defaultMessage: 'Reactionners' },
|
||||||
private_long: { id: 'searchability.private.long', defaultMessage: 'Reacter of this post can find' },
|
direct_long: { id: 'searchability.private.long', defaultMessage: 'Reacter of this post can find' },
|
||||||
direct_short: { id: 'searchability.direct.short', defaultMessage: 'Self only' },
|
limited_short: { id: 'searchability.direct.short', defaultMessage: 'Self only' },
|
||||||
direct_long: { id: 'searchability.direct.long', defaultMessage: 'Nobody can find, but you can' },
|
limited_long: { id: 'searchability.direct.long', defaultMessage: 'Nobody can find, but you can' },
|
||||||
change_searchability: { id: 'searchability.change', defaultMessage: 'Set status searchability' },
|
change_searchability: { id: 'searchability.change', defaultMessage: 'Set status searchability' },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -212,14 +212,14 @@ class SearchabilityDropdown extends React.PureComponent {
|
||||||
this.props.onChange(value);
|
this.props.onChange(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillMount () {
|
UNSAFE_componentWillMount () {
|
||||||
const { intl: { formatMessage } } = this.props;
|
const { intl: { formatMessage } } = this.props;
|
||||||
|
|
||||||
this.options = [
|
this.options = [
|
||||||
{ icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
{ icon: 'globe', value: 'public', text: formatMessage(messages.public_short), meta: formatMessage(messages.public_long) },
|
||||||
{ icon: 'unlock', value: 'unlisted', text: formatMessage(messages.unlisted_short), meta: formatMessage(messages.unlisted_long) },
|
{ icon: 'unlock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
||||||
{ icon: 'lock', value: 'private', text: formatMessage(messages.private_short), meta: formatMessage(messages.private_long) },
|
{ icon: 'lock', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
||||||
{ icon: 'at', value: 'direct', text: formatMessage(messages.direct_short), meta: formatMessage(messages.direct_long) },
|
{ icon: 'at', value: 'limited', text: formatMessage(messages.limited_short), meta: formatMessage(messages.limited_long) },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ const mapStateToProps = state => ({
|
||||||
needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']),
|
needsLockWarning: state.getIn(['compose', 'privacy']) === 'private' && !state.getIn(['accounts', me, 'locked']),
|
||||||
hashtagWarning: ['public', 'public_unlisted'].indexOf(state.getIn(['compose', 'privacy'])) < 0 && HASHTAG_PATTERN_REGEX.test(state.getIn(['compose', 'text'])),
|
hashtagWarning: ['public', 'public_unlisted'].indexOf(state.getIn(['compose', 'privacy'])) < 0 && HASHTAG_PATTERN_REGEX.test(state.getIn(['compose', 'text'])),
|
||||||
directMessageWarning: state.getIn(['compose', 'privacy']) === 'direct',
|
directMessageWarning: state.getIn(['compose', 'privacy']) === 'direct',
|
||||||
searchabilityWarning: state.getIn(['compose', 'searchability']) === 'direct',
|
searchabilityWarning: state.getIn(['compose', 'searchability']) === 'limited',
|
||||||
});
|
});
|
||||||
|
|
||||||
const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning, searchabilityWarning }) => {
|
const WarningWrapper = ({ needsLockWarning, hashtagWarning, directMessageWarning, searchabilityWarning }) => {
|
||||||
|
|
|
@ -26,9 +26,9 @@ const messages = defineMessages({
|
||||||
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
private_short: { id: 'privacy.private.short', defaultMessage: 'Followers-only' },
|
||||||
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
direct_short: { id: 'privacy.direct.short', defaultMessage: 'Direct' },
|
||||||
searchability_public_short: { id: 'searchability.public.short', defaultMessage: 'Public' },
|
searchability_public_short: { id: 'searchability.public.short', defaultMessage: 'Public' },
|
||||||
searchability_unlisted_short: { id: 'searchability.unlisted.short', defaultMessage: 'Followers' },
|
searchability_private_short: { id: 'searchability.unlisted.short', defaultMessage: 'Followers' },
|
||||||
searchability_private_short: { id: 'searchability.private.short', defaultMessage: 'Reactionners' },
|
searchability_direct_short: { id: 'searchability.private.short', defaultMessage: 'Reactionners' },
|
||||||
searchability_direct_short: { id: 'searchability.direct.short', defaultMessage: 'Self only' },
|
searchability_limited_short: { id: 'searchability.direct.short', defaultMessage: 'Self only' },
|
||||||
});
|
});
|
||||||
|
|
||||||
class DetailedStatus extends ImmutablePureComponent {
|
class DetailedStatus extends ImmutablePureComponent {
|
||||||
|
@ -223,9 +223,9 @@ class DetailedStatus extends ImmutablePureComponent {
|
||||||
|
|
||||||
const searchabilityIconInfo = {
|
const searchabilityIconInfo = {
|
||||||
'public': { icon: 'globe', text: intl.formatMessage(messages.searchability_public_short) },
|
'public': { icon: 'globe', text: intl.formatMessage(messages.searchability_public_short) },
|
||||||
'unlisted': { icon: 'unlock', text: intl.formatMessage(messages.searchability_unlisted_short) },
|
'private': { icon: 'unlock', text: intl.formatMessage(messages.searchability_private_short) },
|
||||||
'private': { icon: 'lock', text: intl.formatMessage(messages.searchability_private_short) },
|
'direct': { icon: 'lock', text: intl.formatMessage(messages.searchability_direct_short) },
|
||||||
'direct': { icon: 'at', text: intl.formatMessage(messages.searchability_direct_short) },
|
'limited': { icon: 'at', text: intl.formatMessage(messages.searchability_limited_short) },
|
||||||
};
|
};
|
||||||
|
|
||||||
const searchabilityIcon = searchabilityIconInfo[status.get('searchability')];
|
const searchabilityIcon = searchabilityIconInfo[status.get('searchability')];
|
||||||
|
|
|
@ -475,9 +475,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
elsif audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
|
elsif audience_searchable_by.any? { |uri| ActivityPub::TagManager.instance.public_collection?(uri) }
|
||||||
:public
|
:public
|
||||||
elsif audience_searchable_by.include?(@account.followers_url)
|
elsif audience_searchable_by.include?(@account.followers_url)
|
||||||
:unlisted # Followers only in kmyblue (generics: private)
|
:private
|
||||||
else
|
else
|
||||||
:private # Reaction only in kmyblue (generics: direct)
|
:direct
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -507,9 +507,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
if searchability == visibility
|
if searchability == visibility
|
||||||
searchability
|
searchability
|
||||||
elsif [:public, :unlisted].include?(searchability) && [:public, :unlisted].include?(visibility) # unlisted is Followers only in kmyblue (generics: private)
|
elsif [:public, :unlisted].include?(searchability) && [:public, :unlisted].include?(visibility) # unlisted is Followers only in kmyblue (generics: private)
|
||||||
:unlisted
|
:private
|
||||||
else
|
else
|
||||||
:private # Reaction only in kmyblue (generics: direct)
|
:direct
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -211,11 +211,9 @@ class ActivityPub::TagManager
|
||||||
case status.compute_searchability_activitypub
|
case status.compute_searchability_activitypub
|
||||||
when 'public'
|
when 'public'
|
||||||
[COLLECTIONS[:public]]
|
[COLLECTIONS[:public]]
|
||||||
when 'unlisted' # Followers only in kmyblue (generics: private)
|
when 'private'
|
||||||
[account_followers_url(status.account)]
|
[account_followers_url(status.account)]
|
||||||
# when 'private' # Reaction only in kmyblue (generics: direct)
|
when 'direct'
|
||||||
# []
|
|
||||||
when 'limited'
|
|
||||||
status.conversation_id.present? ? [uri_for(status.conversation)] : []
|
status.conversation_id.present? ? [uri_for(status.conversation)] : []
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
@ -228,7 +226,7 @@ class ActivityPub::TagManager
|
||||||
case account.searchability
|
case account.searchability
|
||||||
when 'public'
|
when 'public'
|
||||||
[COLLECTIONS[:public]]
|
[COLLECTIONS[:public]]
|
||||||
when 'unlisted', 'private'
|
when 'private', 'direct'
|
||||||
[account_followers_url(account)]
|
[account_followers_url(account)]
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Status < ApplicationRecord
|
||||||
update_index('statuses', :proper)
|
update_index('statuses', :proper)
|
||||||
|
|
||||||
enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :visibility
|
enum visibility: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :visibility
|
||||||
enum searchability: { public: 0, unlisted: 1, private: 2, direct: 3, limited: 4, public_unlisted: 10 }, _suffix: :searchability
|
enum searchability: { public: 0, private: 1, direct: 2, limited: 3, public_unlisted: 10 }, _suffix: :searchability
|
||||||
|
|
||||||
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
|
belongs_to :application, class_name: 'Doorkeeper::Application', optional: true
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
:enable_wide_emoji,
|
:enable_wide_emoji,
|
||||||
:enable_wide_emoji_reaction,
|
:enable_wide_emoji_reaction,
|
||||||
:kmyblue_searchability,
|
:kmyblue_searchability,
|
||||||
|
:searchability,
|
||||||
:kmyblue_markdown,
|
:kmyblue_markdown,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
:enable_wide_emoji,
|
:enable_wide_emoji,
|
||||||
:enable_wide_emoji_reaction,
|
:enable_wide_emoji_reaction,
|
||||||
:kmyblue_searchability,
|
:kmyblue_searchability,
|
||||||
|
:searchability,
|
||||||
:kmyblue_markdown,
|
:kmyblue_markdown,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -81,16 +81,15 @@ class PostStatusService < BaseService
|
||||||
def searchability
|
def searchability
|
||||||
case @options[:searchability]&.to_sym
|
case @options[:searchability]&.to_sym
|
||||||
when :public
|
when :public
|
||||||
case @visibility&.to_sym when :public, :public_unlisted then :public when :unlisted then :unlisted when :private then :private else :direct end
|
case @visibility&.to_sym when :public, :public_unlisted then :public when :unlisted, :private then :private else :direct end
|
||||||
when :unlisted
|
|
||||||
case @visibility&.to_sym when :public, :public_unlisted, :unlisted then :unlisted when :private then :private else :direct end
|
|
||||||
when :private
|
when :private
|
||||||
# direct message also can be searched by receiver
|
case @visibility&.to_sym when :public, :public_unlisted, :unlisted, :private then :private else :direct end
|
||||||
:private
|
when :direct
|
||||||
|
:direct
|
||||||
when nil
|
when nil
|
||||||
@account.user&.setting_default_searchability || @account.searchability
|
@account.user&.setting_default_searchability || @account.searchability
|
||||||
else
|
else
|
||||||
:direct
|
:limited
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue