1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Compare commits

...

4 commits

17 changed files with 18 additions and 128 deletions

View file

@ -15,8 +15,7 @@ module ContextHelper
emoji: { 'toot' => 'http://joinmastodon.org/ns#', 'Emoji' => 'toot:Emoji' }, emoji: { 'toot' => 'http://joinmastodon.org/ns#', 'Emoji' => 'toot:Emoji' },
featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' }, 'featuredTags' => { '@id' => 'toot:featuredTags', '@type' => '@id' } }, featured: { 'toot' => 'http://joinmastodon.org/ns#', 'featured' => { '@id' => 'toot:featured', '@type' => '@id' }, 'featuredTags' => { '@id' => 'toot:featuredTags', '@type' => '@id' } },
property_value: { 'schema' => 'http://schema.org#', 'PropertyValue' => 'schema:PropertyValue', 'value' => 'schema:value' }, property_value: { 'schema' => 'http://schema.org#', 'PropertyValue' => 'schema:PropertyValue', 'value' => 'schema:value' },
atom_uri: { 'ostatus' => 'http://ostatus.org#', 'atomUri' => 'ostatus:atomUri' }, conversation: { 'ostatus' => 'http://ostatus.org#', 'conversation' => 'ostatus:conversation' },
conversation: { 'ostatus' => 'http://ostatus.org#', 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri', 'conversation' => 'ostatus:conversation' },
focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } }, focal_point: { 'toot' => 'http://joinmastodon.org/ns#', 'focalPoint' => { '@container' => '@list', '@id' => 'toot:focalPoint' } },
blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' }, blurhash: { 'toot' => 'http://joinmastodon.org/ns#', 'blurhash' => 'toot:blurhash' },
discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' }, discoverable: { 'toot' => 'http://joinmastodon.org/ns#', 'discoverable' => 'toot:discoverable' },

View file

@ -60,7 +60,7 @@ export interface BaseNotificationGroupJSON {
interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON { interface NotificationGroupWithStatusJSON extends BaseNotificationGroupJSON {
type: NotificationWithStatusType; type: NotificationWithStatusType;
status: ApiStatusJSON; status_id: string;
} }
interface NotificationWithStatusJSON extends BaseNotificationJSON { interface NotificationWithStatusJSON extends BaseNotificationJSON {

View file

@ -49,22 +49,15 @@ export const FilteredNotificationsBanner: React.FC = () => {
<span> <span>
<FormattedMessage <FormattedMessage
id='filtered_notifications_banner.pending_requests' id='filtered_notifications_banner.pending_requests'
defaultMessage='Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know' defaultMessage='From {count, plural, =0 {no one} one {one person} other {# people}} you may know'
values={{ count: policy.summary.pending_requests_count }} values={{ count: policy.summary.pending_requests_count }}
/> />
</span> </span>
</div> </div>
<div className='filtered-notifications-banner__badge'> <div className='filtered-notifications-banner__badge'>
<div className='filtered-notifications-banner__badge__badge'>
{toCappedNumber(policy.summary.pending_notifications_count)} {toCappedNumber(policy.summary.pending_notifications_count)}
</div> </div>
<FormattedMessage
id='filtered_notifications_banner.mentions'
defaultMessage='{count, plural, one {mention} other {mentions}}'
values={{ count: policy.summary.pending_notifications_count }}
/>
</div>
</Link> </Link>
); );
}; };

View file

@ -300,8 +300,7 @@
"filter_modal.select_filter.subtitle": "Use an existing category or create a new one", "filter_modal.select_filter.subtitle": "Use an existing category or create a new one",
"filter_modal.select_filter.title": "Filter this post", "filter_modal.select_filter.title": "Filter this post",
"filter_modal.title.status": "Filter a post", "filter_modal.title.status": "Filter a post",
"filtered_notifications_banner.mentions": "{count, plural, one {mention} other {mentions}}", "filtered_notifications_banner.pending_requests": "From {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.pending_requests": "Notifications from {count, plural, =0 {no one} one {one person} other {# people}} you may know",
"filtered_notifications_banner.title": "Filtered notifications", "filtered_notifications_banner.title": "Filtered notifications",
"firehose.all": "All", "firehose.all": "All",
"firehose.local": "This server", "firehose.local": "This server",

View file

@ -124,9 +124,9 @@ export function createNotificationGroupFromJSON(
case 'mention': case 'mention':
case 'poll': case 'poll':
case 'update': { case 'update': {
const { status, ...groupWithoutStatus } = group; const { status_id: statusId, ...groupWithoutStatus } = group;
return { return {
statusId: status.id, statusId,
sampleAccountIds, sampleAccountIds,
...groupWithoutStatus, ...groupWithoutStatus,
}; };

View file

@ -10170,20 +10170,6 @@ noscript {
} }
} }
&__badge {
display: flex;
align-items: center;
border-radius: 999px;
background: var(--background-border-color);
color: $darker-text-color;
padding: 4px;
padding-inline-end: 8px;
gap: 6px;
font-weight: 500;
font-size: 11px;
line-height: 16px;
word-break: keep-all;
&__badge { &__badge {
background: $ui-button-background-color; background: $ui-button-background-color;
color: $white; color: $white;
@ -10191,7 +10177,6 @@ noscript {
padding: 2px 8px; padding: 2px 8px;
} }
} }
}
.notification-request { .notification-request {
display: flex; display: flex;

View file

@ -103,7 +103,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def find_existing_status def find_existing_status
status = status_from_uri(object_uri) status = status_from_uri(object_uri)
status ||= Status.find_by(uri: @object['atomUri']) if @object['atomUri'].present?
status if status&.account_id == @account.id status if status&.account_id == @account.id
end end
@ -363,7 +362,6 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
@replied_to_status = nil @replied_to_status = nil
else else
@replied_to_status = status_from_uri(in_reply_to_uri) @replied_to_status = status_from_uri(in_reply_to_uri)
@replied_to_status ||= status_from_uri(@object['inReplyToAtomUri']) if @object['inReplyToAtomUri'].present?
@replied_to_status @replied_to_status
end end
end end

View file

@ -33,8 +33,6 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
end end
@status = Status.find_by(uri: object_uri, account: @account) @status = Status.find_by(uri: object_uri, account: @account)
@status ||= Status.find_by(uri: @object['atomUri'], account: @account) if @object.is_a?(Hash) && @object['atomUri'].present?
return if @status.nil? return if @status.nil?
forwarder.forward! if forwarder.forwardable? forwarder.forward! if forwarder.forwardable?

View file

@ -73,7 +73,6 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
return if object_uri.nil? return if object_uri.nil?
status = Status.find_by(uri: object_uri, account: @account) status = Status.find_by(uri: object_uri, account: @account)
status ||= Status.find_by(uri: @object['atomUri'], account: @account) if @object.is_a?(Hash) && @object['atomUri'].present?
if status.nil? if status.nil?
delete_later!(object_uri) delete_later!(object_uri)

View file

@ -179,8 +179,6 @@ class ActivityPub::TagManager
else else
StatusFinder.new(uri).status StatusFinder.new(uri).status
end end
elsif OStatus::TagManager.instance.local_id?(uri)
klass.find_by(id: OStatus::TagManager.instance.unique_tag_to_local_id(uri, klass.to_s))
else else
klass.find_by(uri: uri.split('#').first) klass.find_by(uri: uri.split('#').first)
end end

View file

@ -59,15 +59,4 @@ class OStatus::TagManager
def local_id?(id) def local_id?(id)
id.start_with?("tag:#{Rails.configuration.x.local_domain}") || ActivityPub::TagManager.instance.local_uri?(id) id.start_with?("tag:#{Rails.configuration.x.local_domain}") || ActivityPub::TagManager.instance.local_uri?(id)
end end
def uri_for(target)
return target.uri if target.respond_to?(:local?) && !target.local?
case target.object_type
when :person
account_url(target)
when :note, :comment, :activity
target.uri || unique_tag(target.created_at, target.id, 'Status')
end
end
end end

View file

@ -2,9 +2,7 @@
class ActivityPub::DeleteSerializer < ActivityPub::Serializer class ActivityPub::DeleteSerializer < ActivityPub::Serializer
class TombstoneSerializer < ActivityPub::Serializer class TombstoneSerializer < ActivityPub::Serializer
context_extensions :atom_uri attributes :id, :type
attributes :id, :type, :atom_uri
def id def id
ActivityPub::TagManager.instance.uri_for(object) ActivityPub::TagManager.instance.uri_for(object)
@ -13,10 +11,6 @@ class ActivityPub::DeleteSerializer < ActivityPub::Serializer
def type def type
'Tombstone' 'Tombstone'
end end
def atom_uri
OStatus::TagManager.instance.uri_for(object)
end
end end
attributes :id, :type, :actor, :to attributes :id, :type, :actor, :to

View file

@ -3,12 +3,11 @@
class ActivityPub::NoteSerializer < ActivityPub::Serializer class ActivityPub::NoteSerializer < ActivityPub::Serializer
include FormattingHelper include FormattingHelper
context_extensions :atom_uri, :conversation, :sensitive, :voters_count context_extensions :conversation, :sensitive, :voters_count
attributes :id, :type, :summary, attributes :id, :type, :summary,
:in_reply_to, :published, :url, :in_reply_to, :published, :url,
:attributed_to, :to, :cc, :sensitive, :attributed_to, :to, :cc, :sensitive,
:atom_uri, :in_reply_to_atom_uri,
:conversation :conversation
attribute :content attribute :content
@ -116,18 +115,6 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis object.active_mentions.to_a.sort_by(&:id) + object.tags + object.emojis
end end
def atom_uri
return unless object.local?
OStatus::TagManager.instance.uri_for(object)
end
def in_reply_to_atom_uri
return unless object.reply? && !object.thread.nil?
OStatus::TagManager.instance.uri_for(object.thread)
end
def conversation def conversation
return if object.conversation.nil? return if object.conversation.nil?

View file

@ -27,11 +27,10 @@ RSpec.describe ActivityPub::Activity::Undo do
type: 'Announce', type: 'Announce',
actor: ActivityPub::TagManager.instance.uri_for(sender), actor: ActivityPub::TagManager.instance.uri_for(sender),
object: ActivityPub::TagManager.instance.uri_for(status), object: ActivityPub::TagManager.instance.uri_for(status),
atomUri: 'barbar',
} }
end end
context 'when not atomUri' do context 'when embedded object' do
before do before do
Fabricate(:status, reblog: status, account: sender, uri: 'bar') Fabricate(:status, reblog: status, account: sender, uri: 'bar')
end end
@ -42,17 +41,6 @@ RSpec.describe ActivityPub::Activity::Undo do
end end
end end
context 'with atomUri' do
before do
Fabricate(:status, reblog: status, account: sender, uri: 'barbar')
end
it 'deletes the reblog by atomUri' do
subject.perform
expect(sender.reblogged?(status)).to be false
end
end
context 'with only object uri' do context 'with only object uri' do
let(:object_json) { 'bar' } let(:object_json) { 'bar' }

View file

@ -170,11 +170,6 @@ RSpec.describe ActivityPub::TagManager do
expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status expect(subject.uri_to_resource(subject.uri_for(status), Status)).to eq status
end end
it 'returns the local status for OStatus tag: URI' do
status = Fabricate(:status)
expect(subject.uri_to_resource(OStatus::TagManager.instance.uri_for(status), Status)).to eq status
end
it 'returns the remote status by matching URI without fragment part' do it 'returns the remote status by matching URI without fragment part' do
status = Fabricate(:status, uri: 'https://example.com/123') status = Fabricate(:status, uri: 'https://example.com/123')
expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status expect(subject.uri_to_resource('https://example.com/123#456', Status)).to eq status

View file

@ -36,35 +36,4 @@ describe OStatus::TagManager do
expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false expect(described_class.instance.local_id?('tag:foreign.tld;objectId=12:objectType=Status')).to be false
end end
end end
describe '#uri_for' do
subject { described_class.instance.uri_for(target) }
context 'with comment object' do
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: true) }
it 'returns the unique tag for status' do
expect(target.object_type).to eq :comment
expect(subject).to eq target.uri
end
end
context 'with note object' do
let(:target) { Fabricate(:status, created_at: '2000-01-01T00:00:00Z', reply: false, thread: nil) }
it 'returns the unique tag for status' do
expect(target.object_type).to eq :note
expect(subject).to eq target.uri
end
end
context 'when person object' do
let(:target) { Fabricate(:account, username: 'alice') }
it 'returns the URL for account' do
expect(target.object_type).to eq :person
expect(subject).to eq 'https://cb6e6126.ngrok.io/users/alice'
end
end
end
end end

View file

@ -77,7 +77,6 @@ RSpec.describe RemoveStatusService, :inline_jobs do
'object' => { 'object' => {
'type' => 'Tombstone', 'type' => 'Tombstone',
'id' => ActivityPub::TagManager.instance.uri_for(status), 'id' => ActivityPub::TagManager.instance.uri_for(status),
'atomUri' => OStatus::TagManager.instance.uri_for(status),
} }
) )
end end