Merge commit 'db074fc3e2b671e28a44ae379e6df1fcbdbbce53' into glitch-soc/merge-upstream
This commit is contained in:
commit
842bac86f6
@ -149,6 +149,8 @@ function loaded() {
|
|||||||
document.querySelector('#user_settings_attributes_default_privacy'),
|
document.querySelector('#user_settings_attributes_default_privacy'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
truncateRuleHints();
|
||||||
|
|
||||||
const reactComponents = document.querySelectorAll('[data-component]');
|
const reactComponents = document.querySelectorAll('[data-component]');
|
||||||
|
|
||||||
if (reactComponents.length > 0) {
|
if (reactComponents.length > 0) {
|
||||||
@ -425,21 +427,61 @@ on('submit', '#registration_new_user,#new_user', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Truncate long rule hints
|
||||||
|
|
||||||
|
const MAX_RULE_HINT_LENGTH = 100;
|
||||||
|
|
||||||
|
function truncateRuleHints() {
|
||||||
|
const ruleListItems =
|
||||||
|
document.querySelectorAll<HTMLLIElement>('.rules-list li');
|
||||||
|
if (!ruleListItems.length) return;
|
||||||
|
|
||||||
|
ruleListItems.forEach((item) => {
|
||||||
|
toggleRuleHint(item, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleRuleHint(listItem: HTMLLIElement, isInitialSetup?: boolean) {
|
||||||
|
const hint = listItem.querySelector<HTMLSpanElement>(
|
||||||
|
'.rules-list__hint-text',
|
||||||
|
);
|
||||||
|
if (!hint) return;
|
||||||
|
|
||||||
|
const hintText = hint.innerHTML;
|
||||||
|
const hintToggleButton = listItem.querySelector('button');
|
||||||
|
|
||||||
|
if (hintText.length > MAX_RULE_HINT_LENGTH) {
|
||||||
|
// Store full hint in a data attribute, then truncate it with an '…'
|
||||||
|
hint.dataset.fullHint = hintText;
|
||||||
|
hint.innerHTML = `${hintText.slice(0, MAX_RULE_HINT_LENGTH - 1).trim()}…`;
|
||||||
|
|
||||||
|
if (hintToggleButton) {
|
||||||
|
// Reveal toggle button if needed
|
||||||
|
hintToggleButton.removeAttribute('hidden');
|
||||||
|
hintToggleButton.setAttribute('aria-expanded', 'false');
|
||||||
|
}
|
||||||
|
} else if (!isInitialSetup) {
|
||||||
|
const { fullHint } = hint.dataset;
|
||||||
|
if (fullHint) {
|
||||||
|
// Restore full hint from data attribute, then delete attribute
|
||||||
|
hint.innerHTML = fullHint;
|
||||||
|
delete hint.dataset.fullHint;
|
||||||
|
|
||||||
|
hintToggleButton?.setAttribute('aria-expanded', 'true');
|
||||||
|
hint.parentElement?.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
on('click', '.rules-list button', ({ target }) => {
|
on('click', '.rules-list button', ({ target }) => {
|
||||||
if (!(target instanceof HTMLElement)) {
|
if (!(target instanceof HTMLElement)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const button = target.closest('button');
|
const listItem = target.closest('li');
|
||||||
|
|
||||||
if (!button) {
|
if (listItem) {
|
||||||
return;
|
toggleRuleHint(listItem);
|
||||||
}
|
|
||||||
|
|
||||||
if (button.ariaExpanded === 'true') {
|
|
||||||
button.ariaExpanded = 'false';
|
|
||||||
} else {
|
|
||||||
button.ariaExpanded = 'true';
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -34,34 +34,6 @@ $fluid-breakpoint: $maximum-width + 20px;
|
|||||||
counter-increment: list-counter;
|
counter-increment: list-counter;
|
||||||
min-height: 4ch;
|
min-height: 4ch;
|
||||||
|
|
||||||
button {
|
|
||||||
background: transparent;
|
|
||||||
border: 0;
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
text-align: start;
|
|
||||||
font: inherit;
|
|
||||||
|
|
||||||
&:hover,
|
|
||||||
&:focus,
|
|
||||||
&:active {
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[aria-expanded='false'] .rules-list__hint {
|
|
||||||
white-space: nowrap;
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
|
|
||||||
@supports (-webkit-line-clamp: 2) {
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
white-space: normal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
content: counter(list-counter);
|
content: counter(list-counter);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -91,6 +63,48 @@ $fluid-breakpoint: $maximum-width + 20px;
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: var(--color-text-secondary);
|
color: var(--color-text-secondary);
|
||||||
|
|
||||||
|
// Giving this a focus outline as the hint
|
||||||
|
// will be focused when toggling the full hint
|
||||||
|
&:focus-visible {
|
||||||
|
outline: var(--outline-focus-default);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__toggle-button {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
vertical-align: -0.25em;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
color: var(--color-text-primary);
|
||||||
|
background: var(--color-bg-secondary);
|
||||||
|
|
||||||
|
&[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 1lh;
|
||||||
|
height: 1lh;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--color-bg-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:focus-visible {
|
||||||
|
outline: var(--outline-focus-default);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
// Increase clickable size
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: -12px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ol, ul {
|
ol, ul {
|
||||||
list-style: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockquote, q {
|
blockquote, q {
|
||||||
|
|||||||
@ -7,6 +7,7 @@ class BackupService < BaseService
|
|||||||
include ContextHelper
|
include ContextHelper
|
||||||
|
|
||||||
CHUNK_SIZE = 1.megabyte
|
CHUNK_SIZE = 1.megabyte
|
||||||
|
PLACEHOLDER = '!PLACEHOLDER!'
|
||||||
|
|
||||||
attr_reader :account, :backup
|
attr_reader :account, :backup
|
||||||
|
|
||||||
@ -22,9 +23,9 @@ class BackupService < BaseService
|
|||||||
def build_outbox_json!(file)
|
def build_outbox_json!(file)
|
||||||
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
|
skeleton = serialize(collection_presenter, ActivityPub::CollectionSerializer)
|
||||||
skeleton[:@context] = full_context
|
skeleton[:@context] = full_context
|
||||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = [PLACEHOLDER]
|
||||||
skeleton = JSON.generate(skeleton)
|
skeleton = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split(PLACEHOLDER.to_json)
|
||||||
|
|
||||||
file.write(prepend)
|
file.write(prepend)
|
||||||
|
|
||||||
@ -115,9 +116,9 @@ class BackupService < BaseService
|
|||||||
def dump_likes!(zipfile)
|
def dump_likes!(zipfile)
|
||||||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'likes.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'likes.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||||
skeleton.delete(:totalItems)
|
skeleton.delete(:totalItems)
|
||||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = [PLACEHOLDER]
|
||||||
skeleton = JSON.generate(skeleton)
|
skeleton = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split(PLACEHOLDER.to_json)
|
||||||
|
|
||||||
zipfile.get_output_stream('likes.json') do |io|
|
zipfile.get_output_stream('likes.json') do |io|
|
||||||
io.write(prepend)
|
io.write(prepend)
|
||||||
@ -139,9 +140,9 @@ class BackupService < BaseService
|
|||||||
def dump_bookmarks!(zipfile)
|
def dump_bookmarks!(zipfile)
|
||||||
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'bookmarks.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
skeleton = serialize(ActivityPub::CollectionPresenter.new(id: 'bookmarks.json', type: :ordered, size: 0, items: []), ActivityPub::CollectionSerializer)
|
||||||
skeleton.delete(:totalItems)
|
skeleton.delete(:totalItems)
|
||||||
skeleton[:orderedItems] = ['!PLACEHOLDER!']
|
skeleton[:orderedItems] = [PLACEHOLDER]
|
||||||
skeleton = JSON.generate(skeleton)
|
skeleton = JSON.generate(skeleton)
|
||||||
prepend, append = skeleton.split('"!PLACEHOLDER!"')
|
prepend, append = skeleton.split(PLACEHOLDER.to_json)
|
||||||
|
|
||||||
zipfile.get_output_stream('bookmarks.json') do |io|
|
zipfile.get_output_stream('bookmarks.json') do |io|
|
||||||
io.write(prepend)
|
io.write(prepend)
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
%h1.title= t('auth.rules.title')
|
%h1.title= t('auth.rules.title')
|
||||||
%p.lead= t('auth.rules.preamble', domain: site_hostname)
|
%p.lead= t('auth.rules.preamble', domain: site_hostname)
|
||||||
|
|
||||||
%ol.rules-list
|
%ol.rules-list{ role: 'list' }
|
||||||
= render collection: @rule_translations, partial: 'auth/rule_translations/rule_translation'
|
= render collection: @rule_translations, partial: 'auth/rule_translations/rule_translation'
|
||||||
|
|
||||||
.stacked-actions
|
.stacked-actions
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
%li
|
%li
|
||||||
%button{ type: 'button', aria: { expanded: 'false' } }
|
.rules-list__text= rule_translation.text
|
||||||
.rules-list__text= rule_translation.text
|
- if rule_translation.hint?
|
||||||
.rules-list__hint= rule_translation.hint
|
.rules-list__hint{ tabIndex: -1 }
|
||||||
|
%span.rules-list__hint-text= rule_translation.hint
|
||||||
|
%button.rules-list__toggle-button{ type: 'button', hidden: true, 'aria-expanded': 'false' }
|
||||||
|
= material_symbol('more_horiz')
|
||||||
|
%span.sr-only= t('auth.rules.read_more')
|
||||||
|
|||||||
@ -55,13 +55,10 @@ class Scheduler::SelfDestructScheduler
|
|||||||
end
|
end
|
||||||
|
|
||||||
def delete_account!(account)
|
def delete_account!(account)
|
||||||
payload = ActiveModelSerializers::SerializableResource.new(
|
json = ActivityPub::LinkedDataSignature
|
||||||
account,
|
.new(deletion_payload(account))
|
||||||
serializer: ActivityPub::DeleteActorSerializer,
|
.sign!(account)
|
||||||
adapter: ActivityPub::Adapter
|
.to_json
|
||||||
).as_json
|
|
||||||
|
|
||||||
json = JSON.generate(ActivityPub::LinkedDataSignature.new(payload).sign!(account))
|
|
||||||
|
|
||||||
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |inbox_url|
|
ActivityPub::DeliveryWorker.push_bulk(inboxes, limit: 1_000) do |inbox_url|
|
||||||
[json, account.id, inbox_url]
|
[json, account.id, inbox_url]
|
||||||
@ -70,4 +67,12 @@ class Scheduler::SelfDestructScheduler
|
|||||||
# Do not call `Account#suspend!` because we don't want to issue a deletion request
|
# Do not call `Account#suspend!` because we don't want to issue a deletion request
|
||||||
account.update!(suspended_at: Time.now.utc, suspension_origin: :local)
|
account.update!(suspended_at: Time.now.utc, suspension_origin: :local)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deletion_payload(account)
|
||||||
|
ActiveModelSerializers::SerializableResource.new(
|
||||||
|
account,
|
||||||
|
serializer: ActivityPub::DeleteActorSerializer,
|
||||||
|
adapter: ActivityPub::Adapter
|
||||||
|
).as_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1295,6 +1295,7 @@ en:
|
|||||||
invited_by: 'You can join %{domain} thanks to the invitation you have received from:'
|
invited_by: 'You can join %{domain} thanks to the invitation you have received from:'
|
||||||
preamble: These are set and enforced by the %{domain} moderators.
|
preamble: These are set and enforced by the %{domain} moderators.
|
||||||
preamble_invited: Before you proceed, please consider the ground rules set by the moderators of %{domain}.
|
preamble_invited: Before you proceed, please consider the ground rules set by the moderators of %{domain}.
|
||||||
|
read_more: Read more
|
||||||
title: Some ground rules.
|
title: Some ground rules.
|
||||||
title_invited: You've been invited.
|
title_invited: You've been invited.
|
||||||
security: Security
|
security: Security
|
||||||
|
|||||||
@ -3,45 +3,72 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Webfinger do
|
RSpec.describe Webfinger do
|
||||||
describe 'self link' do
|
describe '#initialize' do
|
||||||
|
subject { described_class.new(uri) }
|
||||||
|
|
||||||
|
context 'when called with local account' do
|
||||||
|
let(:uri) { 'acct:alice' }
|
||||||
|
|
||||||
|
it 'handles value and raises error' do
|
||||||
|
expect { subject }.to raise_error(ArgumentError, /for local account/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when called with remote account' do
|
||||||
|
let(:uri) { 'acct:alice@host.example' }
|
||||||
|
|
||||||
|
it 'handles value and sets attributes' do
|
||||||
|
expect { subject }.to_not raise_error
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#perform' do
|
||||||
subject { described_class.new('acct:alice@example.com').perform }
|
subject { described_class.new('acct:alice@example.com').perform }
|
||||||
|
|
||||||
context 'when self link is specified with type application/activity+json' do
|
context 'when self link is specified with type application/activity+json' do
|
||||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
|
end
|
||||||
|
|
||||||
it 'correctly parses the response' do
|
it 'correctly parses the response' do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
|
||||||
|
|
||||||
expect(subject.self_link_href).to eq 'https://example.com/alice'
|
expect(subject.self_link_href).to eq 'https://example.com/alice'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when self link is specified with type application/ld+json' do
|
context 'when self link is specified with type application/ld+json' do
|
||||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }] } }
|
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' }] } }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
|
end
|
||||||
|
|
||||||
it 'correctly parses the response' do
|
it 'correctly parses the response' do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
|
||||||
|
|
||||||
expect(subject.self_link_href).to eq 'https://example.com/alice'
|
expect(subject.self_link_href).to eq 'https://example.com/alice'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when self link is specified with incorrect type' do
|
context 'when self link is specified with incorrect type' do
|
||||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/json"' }] } }
|
let(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/json"' }] } }
|
||||||
|
|
||||||
|
before do
|
||||||
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
|
end
|
||||||
|
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
|
||||||
|
|
||||||
expect { subject }
|
expect { subject }
|
||||||
.to raise_error(Webfinger::Error)
|
.to raise_error(Webfinger::Error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when response body is not parsable' do
|
context 'when response body is not parsable' do
|
||||||
it 'raises an error' do
|
before do
|
||||||
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com')
|
stub_request(:get, 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com').to_return(body: 'XXX', headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
.to_return(body: 'XXX', headers: { 'Content-Type': 'application/jrd+json' })
|
end
|
||||||
|
|
||||||
|
it 'raises an error' do
|
||||||
expect { subject }
|
expect { subject }
|
||||||
.to raise_error(Webfinger::Error)
|
.to raise_error(Webfinger::Error)
|
||||||
end
|
end
|
||||||
@ -63,7 +90,7 @@ RSpec.describe Webfinger do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(body: host_meta, headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/host-meta').to_return(body: host_meta, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
stub_request(:get, 'https://example.com/.well-known/nonStandardWebfinger?resource=acct:alice@example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://example.com/.well-known/nonStandardWebfinger?resource=acct:alice@example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'uses host meta details' do
|
it 'uses host meta details' do
|
||||||
|
|||||||
@ -103,7 +103,7 @@ RSpec.describe ResolveAccountService do
|
|||||||
context 'with a legitimate webfinger redirection' do
|
context 'with a legitimate webfinger redirection' do
|
||||||
before do
|
before do
|
||||||
webfinger = { subject: 'acct:foo@ap.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
webfinger = { subject: 'acct:foo@ap.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||||
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns new remote account' do
|
it 'returns new remote account' do
|
||||||
@ -121,7 +121,7 @@ RSpec.describe ResolveAccountService do
|
|||||||
context 'with a misconfigured redirection' do
|
context 'with a misconfigured redirection' do
|
||||||
before do
|
before do
|
||||||
webfinger = { subject: 'acct:Foo@redirected.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
webfinger = { subject: 'acct:Foo@redirected.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||||
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns new remote account' do
|
it 'returns new remote account' do
|
||||||
@ -139,9 +139,9 @@ RSpec.describe ResolveAccountService do
|
|||||||
context 'with too many webfinger redirections' do
|
context 'with too many webfinger redirections' do
|
||||||
before do
|
before do
|
||||||
webfinger = { subject: 'acct:foo@evil.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
webfinger = { subject: 'acct:foo@evil.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||||
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://redirected.example.com/.well-known/webfinger?resource=acct:Foo@redirected.example.com').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
webfinger2 = { subject: 'acct:foo@ap.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
webfinger2 = { subject: 'acct:foo@ap.example.com', links: [{ rel: 'self', href: 'https://ap.example.com/users/foo', type: 'application/activity+json' }] }
|
||||||
stub_request(:get, 'https://evil.example.com/.well-known/webfinger?resource=acct:foo@evil.example.com').to_return(body: JSON.generate(webfinger2), headers: { 'Content-Type': 'application/jrd+json' })
|
stub_request(:get, 'https://evil.example.com/.well-known/webfinger?resource=acct:foo@evil.example.com').to_return(body: webfinger2.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not return a new remote account' do
|
it 'does not return a new remote account' do
|
||||||
|
|||||||
@ -44,12 +44,3 @@ def serialized_record_json(record, serializer, adapter: nil, options: {})
|
|||||||
).to_json
|
).to_json
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def expect_push_bulk_to_match(klass, matcher)
|
|
||||||
allow(Sidekiq::Client).to receive(:push_bulk)
|
|
||||||
yield
|
|
||||||
expect(Sidekiq::Client).to have_received(:push_bulk).with(hash_including({
|
|
||||||
'class' => klass,
|
|
||||||
'args' => matcher,
|
|
||||||
}))
|
|
||||||
end
|
|
||||||
|
|||||||
@ -16,9 +16,10 @@ RSpec.describe ActivityPub::DistributePollUpdateWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com']]) do
|
subject.perform(status.id)
|
||||||
subject.perform(status.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Update'), account.id, 'http://example.com')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -19,9 +19,10 @@ RSpec.describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
subject.perform(status.id)
|
||||||
subject.perform(status.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -31,9 +32,10 @@ RSpec.describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything]]) do
|
subject.perform(status.id)
|
||||||
subject.perform(status.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'http://example.com', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,9 +48,10 @@ RSpec.describe ActivityPub::DistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to mentioned accounts' do
|
it 'delivers to mentioned accounts' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything]]) do
|
subject.perform(status.id)
|
||||||
subject.perform(status.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Create'), status.account.id, 'https://foo.bar/inbox', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -67,9 +70,10 @@ RSpec.describe ActivityPub::DistributionWorker do
|
|||||||
object: ActivityPub::TagManager.instance.uri_for(status),
|
object: ActivityPub::TagManager.instance.uri_for(status),
|
||||||
}
|
}
|
||||||
|
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do
|
subject.perform(reblog.id)
|
||||||
subject.perform(reblog.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(expected_json), reblog.account.id, 'http://example.com', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,9 +90,10 @@ RSpec.describe ActivityPub::DistributionWorker do
|
|||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(expected_json), reblog.account.id, 'http://example.com', anything]]) do
|
subject.perform(reblog.id)
|
||||||
subject.perform(reblog.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(expected_json), reblog.account.id, 'http://example.com', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,16 +16,11 @@ RSpec.describe ActivityPub::MoveDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers and known blockers' do
|
it 'delivers to followers and known blockers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, expected_migration_deliveries) do
|
subject.perform(migration.id)
|
||||||
subject.perform(migration.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def expected_migration_deliveries
|
expect(ActivityPub::DeliveryWorker)
|
||||||
[
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Move'), migration.account.id, 'http://example.com')
|
||||||
[match_json_values(type: 'Move'), migration.account.id, 'http://example.com'],
|
.and have_enqueued_sidekiq_job(match_json_values(type: 'Move'), migration.account.id, 'http://example2.com')
|
||||||
[match_json_values(type: 'Move'), migration.account.id, 'http://example2.com'],
|
|
||||||
]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -14,9 +14,10 @@ RSpec.describe ActivityPub::UpdateDistributionWorker do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'delivers to followers' do
|
it 'delivers to followers' do
|
||||||
expect_push_bulk_to_match(ActivityPub::DeliveryWorker, [[match_json_values(type: 'Update'), account.id, 'http://example.com', anything]]) do
|
subject.perform(account.id)
|
||||||
subject.perform(account.id)
|
|
||||||
end
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Update'), account.id, 'http://example.com', anything)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -39,6 +39,8 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when sidekiq is operational' do
|
context 'when sidekiq is operational' do
|
||||||
|
let!(:other_account) { Fabricate :account, inbox_url: 'https://host.example/inbox', domain: 'host.example', protocol: :activitypub }
|
||||||
|
|
||||||
it 'suspends local non-suspended accounts' do
|
it 'suspends local non-suspended accounts' do
|
||||||
worker.perform
|
worker.perform
|
||||||
|
|
||||||
@ -51,6 +53,9 @@ RSpec.describe Scheduler::SelfDestructScheduler do
|
|||||||
|
|
||||||
worker.perform
|
worker.perform
|
||||||
|
|
||||||
|
expect(ActivityPub::DeliveryWorker)
|
||||||
|
.to have_enqueued_sidekiq_job(match_json_values(type: 'Delete', signature: be_present), account.id, other_account.inbox_url)
|
||||||
|
|
||||||
expect(account.reload.suspended_at).to be > 1.day.ago
|
expect(account.reload.suspended_at).to be > 1.day.ago
|
||||||
expect { deletion_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { deletion_request.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user