Merge pull request #3448 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes up to b320c9e4c9
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -27,7 +27,7 @@ gem 'addressable', '~> 2.8'
|
||||
gem 'bootsnap', require: false
|
||||
gem 'browser'
|
||||
gem 'charlock_holmes', '~> 0.7.7'
|
||||
gem 'chewy', '~> 7.3'
|
||||
gem 'chewy'
|
||||
gem 'devise'
|
||||
gem 'devise-two-factor'
|
||||
|
||||
|
||||
24
Gemfile.lock
24
Gemfile.lock
@@ -159,9 +159,9 @@ GEM
|
||||
cbor (0.5.10.1)
|
||||
cgi (0.5.1)
|
||||
charlock_holmes (0.7.9)
|
||||
chewy (7.6.0)
|
||||
activesupport (>= 5.2)
|
||||
elasticsearch (>= 7.14.0, < 8)
|
||||
chewy (8.0.1)
|
||||
activesupport (>= 7.2)
|
||||
elasticsearch (>= 8.14, < 9.0)
|
||||
elasticsearch-dsl
|
||||
childprocess (5.1.0)
|
||||
logger (~> 1.5)
|
||||
@@ -214,16 +214,16 @@ GEM
|
||||
dotenv (3.2.0)
|
||||
drb (2.2.3)
|
||||
dry-cli (1.4.1)
|
||||
elasticsearch (7.17.11)
|
||||
elasticsearch-api (= 7.17.11)
|
||||
elasticsearch-transport (= 7.17.11)
|
||||
elasticsearch-api (7.17.11)
|
||||
elastic-transport (8.4.1)
|
||||
faraday (< 3)
|
||||
multi_json
|
||||
elasticsearch (8.19.3)
|
||||
elastic-transport (~> 8.3)
|
||||
elasticsearch-api (= 8.19.3)
|
||||
ostruct
|
||||
elasticsearch-api (8.19.3)
|
||||
multi_json
|
||||
elasticsearch-dsl (0.1.10)
|
||||
elasticsearch-transport (7.17.11)
|
||||
base64
|
||||
faraday (>= 1, < 3)
|
||||
multi_json
|
||||
email_validator (2.2.4)
|
||||
activemodel
|
||||
erb (6.0.2)
|
||||
@@ -959,7 +959,7 @@ DEPENDENCIES
|
||||
capybara (~> 3.39)
|
||||
capybara-playwright-driver
|
||||
charlock_holmes (~> 0.7.7)
|
||||
chewy (~> 7.3)
|
||||
chewy
|
||||
climate_control
|
||||
cocoon (~> 1.2)
|
||||
color_diff (~> 0.1)
|
||||
|
||||
@@ -76,6 +76,7 @@ Mastodon is a **free, open-source social network server** based on [ActivityPub]
|
||||
- **PostgreSQL** 14+
|
||||
- **Redis** 7.0+
|
||||
- **Node.js** 20+
|
||||
- **FFmpeg** 5.1+
|
||||
|
||||
This repository includes deployment configurations for **Docker and docker-compose**, as well as for other environments like Heroku and Scalingo. For Helm charts, reference the [mastodon/chart repository](https://github.com/mastodon/chart). A [**standalone** installation guide](https://docs.joinmastodon.org/admin/install/) is available in the main documentation.
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class Dimension extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='dimension'>
|
||||
<h4>{label}</h4>
|
||||
<h2>{label}</h2>
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,7 @@ export default class ImpactReport extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='dimension'>
|
||||
<h4><FormattedMessage id='admin.impact_report.title' defaultMessage='Impact summary' /></h4>
|
||||
<FormattedMessage id='admin.impact_report.title' defaultMessage='Impact summary' tagName="h2" />
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
|
||||
@@ -145,7 +145,7 @@ export default class Retention extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='retention'>
|
||||
<h4>{title}</h4>
|
||||
<h2>{title}</h2>
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -66,7 +66,7 @@ export default class Trends extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='trends trends--compact'>
|
||||
<h4><FormattedMessage id='trends.trending_now' defaultMessage='Trending now' /></h4>
|
||||
<FormattedMessage id='trends.trending_now' defaultMessage='Trending now' tagName='h2' />
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -267,7 +267,7 @@ $content-width: 840px;
|
||||
}
|
||||
}
|
||||
|
||||
h2 small {
|
||||
h1 small {
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
@@ -281,22 +281,16 @@ $content-width: 840px;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
:where(h1),
|
||||
.heading-large {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 24px;
|
||||
line-height: 36px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h3 {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
:where(h2):not(.heading-medium),
|
||||
.heading-small {
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
@@ -306,6 +300,14 @@ $content-width: 840px;
|
||||
border-top: 1px solid var(--color-border-primary);
|
||||
}
|
||||
|
||||
.heading-medium {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 16px;
|
||||
color: var(--color-text-primary);
|
||||
|
||||
@@ -1424,6 +1424,9 @@ body > [data-popper-placement] {
|
||||
.autosuggest-textarea > .autosuggest-textarea__textarea:lang(#{$lang}) {
|
||||
writing-mode: vertical-lr;
|
||||
min-height: 209px; // writable
|
||||
max-height: 209px; // suppress autosizing by react-textarea-autosize
|
||||
overflow-x: auto;
|
||||
scrollbar-color: unset;
|
||||
}
|
||||
|
||||
.detailed-status > .status__content > .status__content__text:lang(#{$lang}) {
|
||||
|
||||
@@ -1258,31 +1258,44 @@ code {
|
||||
}
|
||||
|
||||
.progress-tracker {
|
||||
--circle-size: 30px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: 30px;
|
||||
|
||||
li {
|
||||
flex: 0 0 auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.separator {
|
||||
height: 2px;
|
||||
background: var(--color-border-primary);
|
||||
flex: 1 1 auto;
|
||||
--connector-color: var(--color-border-primary);
|
||||
--connector-thickness: 2px;
|
||||
|
||||
&.completed {
|
||||
background: var(--color-text-brand);
|
||||
--connector-color: var(--color-bg-brand-base);
|
||||
}
|
||||
|
||||
&:not(:last-child) {
|
||||
flex-grow: 1;
|
||||
|
||||
// Connector line between circles
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
inset-inline: var(--circle-size) 0;
|
||||
background-color: var(--connector-color);
|
||||
height: 2px;
|
||||
top: calc((var(--circle-size) - var(--connector-thickness)) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.circle {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: var(--circle-size);
|
||||
height: var(--circle-size);
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--color-border-primary);
|
||||
flex: 0 0 auto;
|
||||
@@ -1303,8 +1316,9 @@ code {
|
||||
padding-top: 10px;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
// Center-align the label with the circle
|
||||
transform: translateX(-33.3333%);
|
||||
}
|
||||
|
||||
li:first-child .label {
|
||||
@@ -1321,15 +1335,15 @@ code {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.active .circle {
|
||||
border-color: var(--color-text-brand);
|
||||
[aria-current='step'] .circle {
|
||||
border-color: var(--color-bg-brand-base);
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-text-brand);
|
||||
background: var(--color-bg-brand-base);
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
@@ -1338,8 +1352,9 @@ code {
|
||||
}
|
||||
|
||||
.completed .circle {
|
||||
border-color: var(--color-text-brand);
|
||||
background: var(--color-text-brand);
|
||||
color: var(--color-text-on-brand-base);
|
||||
background: var(--color-bg-brand-base);
|
||||
border-color: var(--color-bg-brand-base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class Dimension extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='dimension'>
|
||||
<h4>{label}</h4>
|
||||
<h2>{label}</h2>
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,7 @@ export default class ImpactReport extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='dimension'>
|
||||
<h4><FormattedMessage id='admin.impact_report.title' defaultMessage='Impact summary' /></h4>
|
||||
<FormattedMessage id='admin.impact_report.title' defaultMessage='Impact summary' tagName="h2" />
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
|
||||
@@ -145,7 +145,7 @@ export default class Retention extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='retention'>
|
||||
<h4>{title}</h4>
|
||||
<h2>{title}</h2>
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -66,7 +66,7 @@ export default class Trends extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className='trends trends--compact'>
|
||||
<h4><FormattedMessage id='trends.trending_now' defaultMessage='Trending now' /></h4>
|
||||
<FormattedMessage id='trends.trending_now' defaultMessage='Trending now' tagName='h2' />
|
||||
|
||||
{content}
|
||||
</div>
|
||||
|
||||
@@ -268,7 +268,7 @@ $content-width: 840px;
|
||||
}
|
||||
}
|
||||
|
||||
h2 small {
|
||||
h1 small {
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
@@ -282,22 +282,16 @@ $content-width: 840px;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
:where(h1),
|
||||
.heading-large {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 24px;
|
||||
line-height: 36px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h3 {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
:where(h2):not(.heading-medium),
|
||||
.heading-small {
|
||||
text-transform: uppercase;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
@@ -307,6 +301,14 @@ $content-width: 840px;
|
||||
border-top: 1px solid var(--color-border-primary);
|
||||
}
|
||||
|
||||
.heading-medium {
|
||||
color: var(--color-text-primary);
|
||||
font-size: 20px;
|
||||
line-height: 28px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 16px;
|
||||
color: var(--color-text-primary);
|
||||
|
||||
@@ -1366,6 +1366,9 @@ body > [data-popper-placement] {
|
||||
.autosuggest-textarea > .autosuggest-textarea__textarea:lang(#{$lang}) {
|
||||
writing-mode: vertical-lr;
|
||||
min-height: 209px; // writable
|
||||
max-height: 209px; // suppress autosizing by react-textarea-autosize
|
||||
overflow-x: auto;
|
||||
scrollbar-color: unset;
|
||||
}
|
||||
|
||||
.detailed-status > .status__content > .status__content__text:lang(#{$lang}) {
|
||||
|
||||
@@ -1257,31 +1257,44 @@ code {
|
||||
}
|
||||
|
||||
.progress-tracker {
|
||||
--circle-size: 30px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: 30px;
|
||||
|
||||
li {
|
||||
flex: 0 0 auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.separator {
|
||||
height: 2px;
|
||||
background: var(--color-border-primary);
|
||||
flex: 1 1 auto;
|
||||
--connector-color: var(--color-border-primary);
|
||||
--connector-thickness: 2px;
|
||||
|
||||
&.completed {
|
||||
background: var(--color-text-brand);
|
||||
--connector-color: var(--color-bg-brand-base);
|
||||
}
|
||||
|
||||
&:not(:last-child) {
|
||||
flex-grow: 1;
|
||||
|
||||
// Connector line between circles
|
||||
&::after {
|
||||
content: '';
|
||||
display: block;
|
||||
position: absolute;
|
||||
inset-inline: var(--circle-size) 0;
|
||||
background-color: var(--connector-color);
|
||||
height: 2px;
|
||||
top: calc((var(--circle-size) - var(--connector-thickness)) / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.circle {
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
width: var(--circle-size);
|
||||
height: var(--circle-size);
|
||||
border-radius: 50%;
|
||||
border: 2px solid var(--color-border-primary);
|
||||
flex: 0 0 auto;
|
||||
@@ -1302,8 +1315,9 @@ code {
|
||||
padding-top: 10px;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
|
||||
// Center-align the label with the circle
|
||||
transform: translateX(-33.3333%);
|
||||
}
|
||||
|
||||
li:first-child .label {
|
||||
@@ -1320,15 +1334,15 @@ code {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
.active .circle {
|
||||
border-color: var(--color-text-brand);
|
||||
[aria-current='step'] .circle {
|
||||
border-color: var(--color-bg-brand-base);
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-text-brand);
|
||||
background: var(--color-bg-brand-base);
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
@@ -1337,8 +1351,9 @@ code {
|
||||
}
|
||||
|
||||
.completed .circle {
|
||||
border-color: var(--color-text-brand);
|
||||
background: var(--color-text-brand);
|
||||
color: var(--color-text-on-brand-base);
|
||||
background: var(--color-bg-brand-base);
|
||||
border-color: var(--color-bg-brand-base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,12 @@ class ActivityPub::Activity
|
||||
@follow_from_object ||= ::Follow.find_by(target_account: @account, uri: object_uri) unless object_uri.nil?
|
||||
end
|
||||
|
||||
def feature_request_from_object
|
||||
return @collection_item if instance_variable_defined?(:@collection_item)
|
||||
|
||||
@collection_item = CollectionItem.local.find_by(activity_uri: value_or_id(@object), account_id: @account.id)
|
||||
end
|
||||
|
||||
def fetch_remote_original_status
|
||||
if object_uri.start_with?('http')
|
||||
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
|
||||
|
||||
@@ -5,6 +5,7 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity
|
||||
return accept_follow_for_relay if relay_follow?
|
||||
return accept_follow!(follow_request_from_object) unless follow_request_from_object.nil?
|
||||
return accept_quote!(quote_request_from_object) unless quote_request_from_object.nil?
|
||||
return accept_feature_request! if Mastodon::Feature.collections_federation_enabled? && feature_request_from_object.present?
|
||||
|
||||
case @object['type']
|
||||
when 'Follow'
|
||||
@@ -44,6 +45,17 @@ class ActivityPub::Activity::Accept < ActivityPub::Activity
|
||||
accept_quote!(quote)
|
||||
end
|
||||
|
||||
def accept_feature_request!
|
||||
approval_uri = value_or_id(first_of_value(@json['result']))
|
||||
return if approval_uri.nil? || unsupported_uri_scheme?(approval_uri) || non_matching_uri_hosts?(approval_uri, @account.uri)
|
||||
|
||||
collection_item = feature_request_from_object
|
||||
collection_item.update!(approval_uri:, state: :accepted)
|
||||
|
||||
activity_json = ActiveModelSerializers::SerializableResource.new(collection_item, serializer: ActivityPub::AddFeaturedItemSerializer, adapter: ActivityPub::Adapter).to_json
|
||||
ActivityPub::AccountRawDistributionWorker.perform_async(activity_json, collection_item.collection.account_id)
|
||||
end
|
||||
|
||||
def accept_quote!(quote)
|
||||
approval_uri = value_or_id(first_of_value(@json['result']))
|
||||
return if unsupported_uri_scheme?(approval_uri) || quote.quoted_account != @account || !quote.status.local? || !quote.pending?
|
||||
|
||||
@@ -6,6 +6,7 @@ class ActivityPub::Activity::Reject < ActivityPub::Activity
|
||||
return follow_request_from_object.reject! unless follow_request_from_object.nil?
|
||||
return UnfollowService.new.call(follow_from_object.account, @account) unless follow_from_object.nil?
|
||||
return reject_quote!(quote_request_from_object) unless quote_request_from_object.nil?
|
||||
return reject_feature_request! unless feature_request_from_object.nil?
|
||||
|
||||
case @object['type']
|
||||
when 'Follow'
|
||||
@@ -46,6 +47,13 @@ class ActivityPub::Activity::Reject < ActivityPub::Activity
|
||||
quote.reject!
|
||||
end
|
||||
|
||||
def reject_feature_request!
|
||||
collection_item = feature_request_from_object
|
||||
return unless collection_item.account == @account && collection_item.local?
|
||||
|
||||
collection_item.destroy!
|
||||
end
|
||||
|
||||
def relay
|
||||
@relay ||= Relay.find_by(follow_activity_id: object_uri) unless object_uri.nil?
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim
|
||||
value: version,
|
||||
human_value: version,
|
||||
}
|
||||
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
|
||||
rescue Faraday::ConnectionFailed, Elastic::Transport::Transport::Error
|
||||
nil
|
||||
end
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ class Admin::Metrics::Dimension::SpaceUsageDimension < Admin::Metrics::Dimension
|
||||
unit: 'bytes',
|
||||
human_value: number_to_human_size(value),
|
||||
}
|
||||
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
|
||||
rescue Faraday::ConnectionFailed, Elastic::Transport::Transport::Error
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
|
||||
return true unless Chewy.enabled?
|
||||
|
||||
running_version.present? && compatible_version? && cluster_health['status'] == 'green' && indexes_match? && specifications_match? && preset_matches?
|
||||
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error, HTTPClient::KeepAliveDisconnected
|
||||
rescue Faraday::ConnectionFailed, Elastic::Transport::Transport::Error, HTTPClient::KeepAliveDisconnected
|
||||
false
|
||||
end
|
||||
|
||||
@@ -54,7 +54,7 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
|
||||
else
|
||||
Admin::SystemCheck::Message.new(:elasticsearch_preset, nil, 'https://docs.joinmastodon.org/admin/elasticsearch/#scaling')
|
||||
end
|
||||
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error, HTTPClient::KeepAliveDisconnected
|
||||
rescue Faraday::ConnectionFailed, Elastic::Transport::Transport::Error, HTTPClient::KeepAliveDisconnected
|
||||
Admin::SystemCheck::Message.new(:elasticsearch_running_check)
|
||||
end
|
||||
|
||||
@@ -67,7 +67,7 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
|
||||
def running_version
|
||||
@running_version ||= begin
|
||||
Chewy.client.info['version']['number']
|
||||
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
|
||||
rescue Faraday::ConnectionFailed, Elastic::Transport::Transport::Error
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class CollectionItem < ApplicationRecord
|
||||
|
||||
validates :position, numericality: { only_integer: true, greater_than: 0 }
|
||||
validates :activity_uri, presence: true, if: :local_item_with_remote_account?
|
||||
validates :approval_uri, presence: true, unless: -> { local? || account&.local? }
|
||||
validates :approval_uri, presence: true, unless: -> { local? || account&.local? || !accepted? }
|
||||
validates :account, presence: true, if: :accepted?
|
||||
validates :object_uri, presence: true, if: -> { account.nil? }
|
||||
validates :uri, presence: true, if: :remote_item_with_remote_account?
|
||||
|
||||
@@ -21,9 +21,9 @@ class ActivityPub::ProcessFeaturedItemService
|
||||
else
|
||||
@collection_item = collection.collection_items.create!(
|
||||
uri: item_json['id'],
|
||||
object_uri: item_json['featuredObject'],
|
||||
approval_uri: item_json['featureAuthorization']
|
||||
object_uri: item_json['featuredObject']
|
||||
)
|
||||
@approval_uri = item_json['featureAuthorization']
|
||||
|
||||
verify_authorization!
|
||||
end
|
||||
@@ -35,8 +35,8 @@ class ActivityPub::ProcessFeaturedItemService
|
||||
private
|
||||
|
||||
def verify_authorization!
|
||||
ActivityPub::VerifyFeaturedItemService.new.call(@collection_item)
|
||||
ActivityPub::VerifyFeaturedItemService.new.call(@collection_item, @approval_uri)
|
||||
rescue Mastodon::RecursionLimitExceededError, Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
|
||||
ActivityPub::VerifyFeaturedItemWorker.perform_in(rand(30..600).seconds, @collection_item.id)
|
||||
ActivityPub::VerifyFeaturedItemWorker.perform_in(rand(30..600).seconds, @collection_item.id, @approval_uri)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,23 +3,23 @@
|
||||
class ActivityPub::VerifyFeaturedItemService
|
||||
include JsonLdHelper
|
||||
|
||||
def call(collection_item)
|
||||
def call(collection_item, approval_uri)
|
||||
@collection_item = collection_item
|
||||
@authorization = fetch_resource(@collection_item.approval_uri, true, raise_on_error: :temporary)
|
||||
@authorization = fetch_resource(approval_uri, true, raise_on_error: :temporary)
|
||||
|
||||
if @authorization.nil?
|
||||
@collection_item.update!(state: :rejected)
|
||||
return
|
||||
end
|
||||
|
||||
return if non_matching_uri_hosts?(@collection_item.approval_uri, @authorization['interactionTarget'])
|
||||
return if non_matching_uri_hosts?(approval_uri, @authorization['interactionTarget'])
|
||||
return unless matching_type? && matching_collection_uri?
|
||||
|
||||
account = Account.where(uri: @collection_item.object_uri).first
|
||||
account ||= ActivityPub::FetchRemoteAccountService.new.call(@collection_item.object_uri)
|
||||
return if account.blank?
|
||||
|
||||
@collection_item.update!(account:, state: :accepted)
|
||||
@collection_item.update!(account:, approval_uri:, state: :accepted)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -86,14 +86,14 @@ class FetchOEmbedService
|
||||
end
|
||||
|
||||
validate(parse_for_format(body)) if body.present?
|
||||
rescue Oj::ParseError, Ox::ParseError
|
||||
rescue JSON::ParserError, Ox::ParseError
|
||||
nil
|
||||
end
|
||||
|
||||
def parse_for_format(body)
|
||||
case @format
|
||||
when :json
|
||||
Oj.load(body, mode: :strict)&.with_indifferent_access
|
||||
JSON.parse(body)&.with_indifferent_access
|
||||
when :xml
|
||||
Ox.load(body, mode: :hash_no_attrs)&.with_indifferent_access&.dig(:oembed)
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.fasp.debug.callbacks.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.fasp.debug.callbacks.title')
|
||||
%h1= t('admin.fasp.debug.callbacks.title')
|
||||
= render 'admin/fasp/shared/links'
|
||||
|
||||
- unless @callbacks.empty?
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
= simple_form_for [:admin, @provider] do |f|
|
||||
= render 'shared/error_messages', object: @provider
|
||||
|
||||
%h4= t('admin.fasp.providers.select_capabilities')
|
||||
%h2= t('admin.fasp.providers.select_capabilities')
|
||||
|
||||
.fields_group
|
||||
= f.fields_for :capabilities do |cf|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.fasp.providers.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.fasp.providers.title')
|
||||
%h1= t('admin.fasp.providers.title')
|
||||
= render 'admin/fasp/shared/links'
|
||||
|
||||
- unless @providers.empty?
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
%span.hint= t('simple_form.hints.user_role.permissions_as_keys')
|
||||
|
||||
- (form.object.everyone? ? UserRole::Flags::CATEGORIES.slice(:invites) : UserRole::Flags::CATEGORIES).each do |category, permissions|
|
||||
%h4= t(category, scope: 'admin.roles.categories')
|
||||
%h2= t(category, scope: 'admin.roles.categories')
|
||||
|
||||
= form.input :permissions_as_keys,
|
||||
as: :check_boxes,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h4= t('admin.rules.translations')
|
||||
%h2= t('admin.rules.translations')
|
||||
|
||||
%p.hint= t('admin.rules.translations_explanation')
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.about.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_about_path do |f|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.appearance.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_appearance_path do |f|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.branding.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_branding_path do |f|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.content_retention.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_content_retention_path do |f|
|
||||
@@ -18,7 +18,7 @@
|
||||
input_html: { pattern: '[0-9]+' },
|
||||
wrapper: :with_block_label
|
||||
|
||||
%h4= t('admin.settings.content_retention.danger_zone')
|
||||
%h2= t('admin.settings.content_retention.danger_zone')
|
||||
|
||||
.fields-group
|
||||
= f.input :content_cache_retention_period,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.discovery.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_discovery_path do |f|
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
%p.lead= t('admin.settings.discovery.preamble')
|
||||
|
||||
%h4= t('admin.settings.discovery.trends')
|
||||
%h2= t('admin.settings.discovery.trends')
|
||||
|
||||
.fields-group
|
||||
= f.input :trends,
|
||||
@@ -26,7 +26,7 @@
|
||||
.fields-group
|
||||
= f.input :trending_status_cw, as: :boolean, wrapper: :with_label, label: t('admin.settings.trending_status_cw.title'), hint: t('admin.settings.trending_status_cw.desc_html'), glitch_only: true
|
||||
|
||||
%h4= t('admin.settings.discovery.public_timelines')
|
||||
%h2= t('admin.settings.discovery.public_timelines')
|
||||
|
||||
.fields-row
|
||||
.fields-row__column.fields-row__column-6.fields-group
|
||||
@@ -58,7 +58,7 @@
|
||||
label_method: ->(mode) { I18n.t("admin.settings.feed_access.modes.#{mode}") },
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t('admin.settings.discovery.privacy')
|
||||
%h2= t('admin.settings.discovery.privacy')
|
||||
|
||||
.fields-group
|
||||
= f.input :noindex,
|
||||
@@ -74,7 +74,7 @@
|
||||
label: t('admin.settings.allow_referrer_origin.title'),
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t('admin.settings.discovery.publish_statistics')
|
||||
%h2= t('admin.settings.discovery.publish_statistics')
|
||||
|
||||
.fields-group
|
||||
= f.input :activity_api_enabled,
|
||||
@@ -88,7 +88,7 @@
|
||||
wrapper: :with_label,
|
||||
recommended: :recommended
|
||||
|
||||
%h4= t('admin.settings.security.federation_authentication')
|
||||
%h2= t('admin.settings.security.federation_authentication')
|
||||
|
||||
.fields-group
|
||||
= f.input :authorized_fetch,
|
||||
@@ -100,20 +100,20 @@
|
||||
warning_hint: discovery_warning_hint_text,
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t('admin.settings.discovery.follow_recommendations')
|
||||
%h2= t('admin.settings.discovery.follow_recommendations')
|
||||
|
||||
.fields-group
|
||||
= f.input :bootstrap_timeline_accounts,
|
||||
wrapper: :with_block_label
|
||||
|
||||
%h4= t('admin.settings.discovery.profile_directory')
|
||||
%h2= t('admin.settings.discovery.profile_directory')
|
||||
|
||||
.fields-group
|
||||
= f.input :profile_directory,
|
||||
as: :boolean,
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t('admin.settings.discovery.wrapstodon')
|
||||
%h2= t('admin.settings.discovery.wrapstodon')
|
||||
|
||||
.fields-group
|
||||
= f.input :wrapstodon,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.settings.registrations.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.settings.title')
|
||||
%h1= t('admin.settings.title')
|
||||
= render partial: 'admin/settings/shared/links'
|
||||
|
||||
= simple_form_for @admin_settings, url: admin_settings_registrations_path do |f|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.terms_of_service.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.terms_of_service.title')
|
||||
%h1= t('admin.terms_of_service.title')
|
||||
= render partial: 'admin/terms_of_service/links'
|
||||
|
||||
= simple_form_for @terms_of_service, url: admin_terms_of_service_draft_path, method: :put do |form|
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.terms_of_service.history')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.terms_of_service.title')
|
||||
%h1= t('admin.terms_of_service.title')
|
||||
= render partial: 'admin/terms_of_service/links'
|
||||
|
||||
- if @terms_of_service.empty?
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('admin.terms_of_service.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('admin.terms_of_service.title')
|
||||
%h1= t('admin.terms_of_service.title')
|
||||
= render partial: 'links'
|
||||
|
||||
- if @terms_of_service.present?
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('admin.terms_of_service.changelog')
|
||||
%h2.heading-medium= t('admin.terms_of_service.changelog')
|
||||
|
||||
.prose
|
||||
= markdown(@terms_of_service.changelog)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
- content_for :heading do
|
||||
.content__heading__row
|
||||
%h2
|
||||
%h1
|
||||
%small
|
||||
= material_symbol 'inbox'
|
||||
= t('admin.webhooks.webhook')
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
= t('auth.status.redirecting_to', acct: user.account.moved_to_account.pretty_acct)
|
||||
= link_to t('migrations.cancel'), settings_migration_path
|
||||
|
||||
%h3= t('auth.status.account_status')
|
||||
%h2.heading-medium= t('auth.status.account_status')
|
||||
|
||||
%p.hint
|
||||
- if user.account.suspended?
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
- else
|
||||
= render partial: 'status', locals: { user: @user, strikes: @strikes }
|
||||
|
||||
%h3= t('auth.security')
|
||||
%h2.heading-medium= t('auth.security')
|
||||
|
||||
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'auth_edit', novalidate: false }) do |f|
|
||||
= render 'shared/error_messages', object: resource
|
||||
@@ -57,15 +57,15 @@
|
||||
- unless current_account.suspended? || self_destruct?
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('auth.migrate_account')
|
||||
%h2.heading-medium= t('auth.migrate_account')
|
||||
%p.muted-hint= t('auth.migrate_account_html', path: settings_migration_path)
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('migrations.incoming_migrations')
|
||||
%h2.heading-medium= t('migrations.incoming_migrations')
|
||||
%p.muted-hint= t('migrations.incoming_migrations_html', path: settings_aliases_path)
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h3= t('auth.delete_account')
|
||||
%h2.heading-medium= t('auth.delete_account')
|
||||
%p.muted-hint= t('auth.delete_account_html', path: settings_delete_path)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
- if devise_mapping.omniauthable? && resource_class.omniauth_providers.any?
|
||||
.simple_form.alternative-login
|
||||
%h4= omniauth_only? ? t('auth.log_in_with') : t('auth.or_log_in_with')
|
||||
%h2= omniauth_only? ? t('auth.log_in_with') : t('auth.or_log_in_with')
|
||||
|
||||
.actions
|
||||
- resource_class.omniauth_providers.each do |provider|
|
||||
|
||||
@@ -1,26 +1,35 @@
|
||||
- progress_index = { rules: 0, details: 1, confirm: 2, confirmed: 3, completed: 4 }[stage.to_sym]
|
||||
|
||||
%ol.progress-tracker
|
||||
%li{ class: progress_index.positive? ? 'completed' : 'active' }
|
||||
%ol.progress-tracker{ role: 'list', 'aria-label': t('auth.progress.list') }
|
||||
%li{
|
||||
class: progress_index.positive? ? 'completed' : nil,
|
||||
'aria-current': progress_index.zero? ? 'step' : nil
|
||||
}
|
||||
.circle
|
||||
- if progress_index.positive?
|
||||
= check_icon
|
||||
.label= t('auth.progress.rules')
|
||||
%li.separator{ class: progress_index.positive? ? 'completed' : nil }
|
||||
%li{ class: [progress_index > 1 && 'completed', progress_index == 1 && 'active'] }
|
||||
%li{
|
||||
class: progress_index > 1 && 'completed',
|
||||
'aria-current': progress_index == 1 ? 'step' : nil
|
||||
}
|
||||
.circle
|
||||
- if progress_index > 1
|
||||
= check_icon
|
||||
.label= t('auth.progress.details')
|
||||
%li.separator{ class: progress_index > 1 ? 'completed' : nil }
|
||||
%li{ class: [progress_index > 2 && 'completed', progress_index == 2 && 'active'] }
|
||||
%li{
|
||||
class: progress_index > 2 && 'completed',
|
||||
'aria-current': progress_index == 2 ? 'step' : nil
|
||||
}
|
||||
.circle
|
||||
- if progress_index > 2
|
||||
= check_icon
|
||||
.label= t('auth.progress.confirm')
|
||||
- if approved_registrations?
|
||||
%li.separator{ class: progress_index > 2 ? 'completed' : nil }
|
||||
%li{ class: [progress_index > 3 && 'completed', progress_index == 3 && 'active'] }
|
||||
%li{
|
||||
class: progress_index > 3 && 'completed',
|
||||
'aria-current': progress_index == 3 ? 'step' : nil
|
||||
}
|
||||
.circle
|
||||
- if progress_index > 3
|
||||
= check_icon
|
||||
|
||||
@@ -36,13 +36,13 @@
|
||||
%hr.spacer/
|
||||
|
||||
- unless f.object.statuses.empty?
|
||||
%h4= t('filters.edit.statuses')
|
||||
%h2= t('filters.edit.statuses')
|
||||
|
||||
%p.muted-hint= t('filters.edit.statuses_hint_html', path: filter_statuses_path(f.object))
|
||||
|
||||
%hr.spacer/
|
||||
|
||||
%h4= t('filters.edit.keywords')
|
||||
%h2= t('filters.edit.keywords')
|
||||
|
||||
.table-wrapper
|
||||
%table.table.keywords-table
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
= yield :heading
|
||||
- else
|
||||
.content__heading__row
|
||||
%h2= yield :page_title
|
||||
%h1= yield :page_title
|
||||
|
||||
- if content_for?(:heading_actions)
|
||||
.content__heading__actions
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('settings.featured_tags')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('settings.profile')
|
||||
%h1= t('settings.profile')
|
||||
= render partial: 'settings/shared/profile_navigation'
|
||||
|
||||
= simple_form_for @featured_tag, url: settings_featured_tags_path do |f|
|
||||
@@ -23,7 +23,7 @@
|
||||
- @featured_tags.each do |featured_tag|
|
||||
.directory__tag
|
||||
%div
|
||||
%h4
|
||||
%h2
|
||||
= material_symbol 'tag'
|
||||
= featured_tag.display_name
|
||||
%small
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
= t('appearance.localization.glitch_guide_link_text')
|
||||
|
||||
= f.simple_fields_for :settings, current_user.settings do |ff|
|
||||
%h4= t 'appearance.animations_and_accessibility'
|
||||
%h2= t 'appearance.animations_and_accessibility'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.use_pending_items',
|
||||
@@ -77,12 +77,12 @@
|
||||
= ff.input :'web.use_system_font', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_system_font_ui')
|
||||
= ff.input :'web.use_system_scrollbars', wrapper: :with_label, hint: I18n.t('simple_form.hints.defaults.setting_system_scrollbars_ui'), label: I18n.t('simple_form.labels.defaults.setting_system_scrollbars_ui')
|
||||
|
||||
%h4= t 'appearance.discovery'
|
||||
%h2= t 'appearance.discovery'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.trends', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_trends')
|
||||
|
||||
%h4= t 'appearance.boosting_preferences'
|
||||
%h2= t 'appearance.boosting_preferences'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.reblog_modal',
|
||||
@@ -96,7 +96,7 @@
|
||||
wrapper: :with_label
|
||||
.flash-message.hidden-on-touch-devices= t('appearance.boosting_preferences_info_html', icon: material_symbol('repeat'))
|
||||
|
||||
%h4= t 'appearance.sensitive_content'
|
||||
%h2= t 'appearance.sensitive_content'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.display_media',
|
||||
@@ -119,7 +119,7 @@
|
||||
.fields-group
|
||||
= ff.input :'web.expand_content_warnings', wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_expand_spoilers')
|
||||
|
||||
%h4= t 'appearance.advanced_settings'
|
||||
%h2= t 'appearance.advanced_settings'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'web.advanced_layout',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
= simple_form_for current_user, url: settings_preferences_notifications_path, html: { id: :edit_notification } do |f|
|
||||
= render 'shared/error_messages', object: current_user
|
||||
|
||||
%h4= t 'notifications.email_events'
|
||||
%h2= t 'notifications.email_events'
|
||||
|
||||
%p.hint= t 'notifications.email_events_hint'
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
= ff.input :always_send_emails, wrapper: :with_label, label: I18n.t('simple_form.labels.defaults.setting_always_send_emails'), hint: I18n.t('simple_form.hints.defaults.setting_always_send_emails')
|
||||
|
||||
- if current_user.can?(:manage_reports, :manage_appeals, :manage_users, :manage_taxonomies) || (SoftwareUpdate.check_enabled? && current_user.can?(:view_devops))
|
||||
%h4= t 'notifications.administration_emails'
|
||||
%h2= t 'notifications.administration_emails'
|
||||
|
||||
.fields-group
|
||||
= ff.input :'notification_emails.report', wrapper: :with_label, label: I18n.t('simple_form.labels.notification_emails.report') if current_user.can?(:manage_reports)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
recommended: true,
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t 'preferences.public_timelines'
|
||||
%h2= t 'preferences.public_timelines'
|
||||
|
||||
.fields-group
|
||||
= f.input :chosen_languages,
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
= t('privacy.title')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('privacy.title')
|
||||
%h1= t('privacy.title')
|
||||
|
||||
= simple_form_for @account, url: settings_privacy_path do |f|
|
||||
= render 'shared/error_messages', object: @account
|
||||
|
||||
%p.lead= t('privacy.hint_html')
|
||||
|
||||
%h4= t('privacy.reach')
|
||||
%h2= t('privacy.reach')
|
||||
|
||||
%p.lead= t('privacy.reach_hint_html')
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
.fields-group
|
||||
= f.input :unlocked, as: :boolean, wrapper: :with_label
|
||||
|
||||
%h4= t('privacy.search')
|
||||
%h2= t('privacy.search')
|
||||
|
||||
%p.lead= t('privacy.search_hint_html')
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
.fields-group
|
||||
= ff.input :indexable, wrapper: :with_label
|
||||
|
||||
%h4= t('privacy.privacy')
|
||||
%h2= t('privacy.privacy')
|
||||
|
||||
%p.lead= t('privacy.privacy_hint_html')
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
= t('settings.edit_profile')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('settings.profile')
|
||||
%h1= t('settings.profile')
|
||||
= render partial: 'settings/shared/profile_navigation'
|
||||
|
||||
= simple_form_for @account, url: settings_profile_path, html: { id: :edit_profile } do |f|
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
%p.lead= t('edit_profile.hint_html')
|
||||
|
||||
%h4= t('edit_profile.basic_information')
|
||||
%h2= t('edit_profile.basic_information')
|
||||
|
||||
.fields-row
|
||||
.fields-row__column.fields-row__column-6
|
||||
@@ -62,7 +62,7 @@
|
||||
= material_symbol 'delete'
|
||||
= t('generic.delete')
|
||||
|
||||
%h4= t('edit_profile.other')
|
||||
%h2= t('edit_profile.other')
|
||||
|
||||
.fields-group
|
||||
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
= t('verification.verification')
|
||||
|
||||
- content_for :heading do
|
||||
%h2= t('settings.profile')
|
||||
%h1= t('settings.profile')
|
||||
= render partial: 'settings/shared/profile_navigation'
|
||||
|
||||
.simple_form.form-section
|
||||
%h3= t('verification.website_verification')
|
||||
%h2.heading-medium= t('verification.website_verification')
|
||||
|
||||
%p.lead= t('verification.hint_html')
|
||||
|
||||
%h4= t('verification.here_is_how')
|
||||
%h3.heading-small= t('verification.here_is_how')
|
||||
|
||||
%p.lead= t('verification.instructions_html')
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
%p.lead= t('verification.extra_instructions_html')
|
||||
|
||||
- if @verified_links.any?
|
||||
%h4= t('verification.verified_links')
|
||||
%h3.heading-small= t('verification.verified_links')
|
||||
|
||||
%ul.lead
|
||||
- @verified_links.each do |field|
|
||||
@@ -34,7 +34,7 @@
|
||||
= simple_form_for @account, url: settings_verification_path, html: { class: 'form-section' } do |f|
|
||||
= render 'shared/error_messages', object: @account
|
||||
|
||||
%h3= t('author_attribution.title')
|
||||
%h2.heading-medium= t('author_attribution.title')
|
||||
|
||||
%p.lead= t('author_attribution.hint_html')
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
= logo_as_symbol(:icon)
|
||||
= t('author_attribution.more_from_html', name: author_attribution_name(@account))
|
||||
|
||||
%h4= t('verification.here_is_how')
|
||||
%h3.heading-small= t('verification.here_is_how')
|
||||
|
||||
%p.lead= t('author_attribution.instructions')
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
.flash-message= t('statuses_cleanup.explanation')
|
||||
|
||||
%h4= t('statuses_cleanup.exceptions')
|
||||
%h2= t('statuses_cleanup.exceptions')
|
||||
|
||||
.fields-row
|
||||
.fields-row__column.fields-row__column-6.fields-group
|
||||
@@ -68,7 +68,7 @@
|
||||
label: t('statuses_cleanup.keep_media'),
|
||||
wrapper: :with_label
|
||||
|
||||
%h4= t('statuses_cleanup.interaction_exceptions')
|
||||
%h2= t('statuses_cleanup.interaction_exceptions')
|
||||
|
||||
.fields-row
|
||||
.fields-row__column.fields-row__column-6.fields-group
|
||||
|
||||
@@ -7,10 +7,10 @@ class ActivityPub::VerifyFeaturedItemWorker
|
||||
|
||||
sidekiq_options queue: 'pull', retry: 5
|
||||
|
||||
def perform(collection_item_id)
|
||||
def perform(collection_item_id, approval_uri)
|
||||
collection_item = CollectionItem.find(collection_item_id)
|
||||
|
||||
ActivityPub::VerifyFeaturedItemService.new.call(collection_item)
|
||||
ActivityPub::VerifyFeaturedItemService.new.call(collection_item, approval_uri)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# Do nothing
|
||||
nil
|
||||
|
||||
@@ -1279,6 +1279,7 @@ en-GB:
|
||||
progress:
|
||||
confirm: Confirm email
|
||||
details: Your details
|
||||
list: Sign up progress
|
||||
review: Our review
|
||||
rules: Accept rules
|
||||
providers:
|
||||
|
||||
@@ -1279,6 +1279,7 @@ en:
|
||||
progress:
|
||||
confirm: Confirm email
|
||||
details: Your details
|
||||
list: Sign up progress
|
||||
review: Our review
|
||||
rules: Accept rules
|
||||
providers:
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
module Elasticsearch
|
||||
module ClientExtensions
|
||||
def verify_elasticsearch
|
||||
def initialize(arguments = {}, &block)
|
||||
super
|
||||
|
||||
@verified = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -140,13 +140,13 @@ module Mastodon::CLI
|
||||
Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
stats[domain] = Oj.load(res.to_s)
|
||||
stats[domain] = JSON.parse(res.to_s)
|
||||
end
|
||||
|
||||
Request.new(:get, "https://#{domain}/api/v1/instance/peers").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
Oj.load(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer|
|
||||
JSON.parse(res.to_s).reject { |peer| stats.key?(peer) }.each do |peer|
|
||||
pool.post(peer, &work_unit)
|
||||
end
|
||||
end
|
||||
@@ -154,7 +154,7 @@ module Mastodon::CLI
|
||||
Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res|
|
||||
next unless res.code == 200
|
||||
|
||||
stats[domain]['activity'] = Oj.load(res.to_s)
|
||||
stats[domain]['activity'] = JSON.parse(res.to_s)
|
||||
end
|
||||
rescue
|
||||
failed.increment
|
||||
|
||||
@@ -115,7 +115,7 @@ module Mastodon::CLI
|
||||
progress.finish
|
||||
|
||||
say("Indexed #{added} records, de-indexed #{removed}", :green, true)
|
||||
rescue Elasticsearch::Transport::Transport::ServerError => e
|
||||
rescue Elastic::Transport::Transport::ServerError => e
|
||||
fail_with_message <<~ERROR
|
||||
There was an issue connecting to the search server. Make sure the
|
||||
server is configured and running correctly, and that the environment
|
||||
|
||||
@@ -51,10 +51,7 @@ module Paperclip
|
||||
@output_options['maxrate'] = bitrate + 192_000
|
||||
@output_options['bufsize'] = bitrate * 5
|
||||
|
||||
if high_vfr?(metadata)
|
||||
# TODO: change to `fps_mode` in the future, as `vsync` is being deprecated
|
||||
@output_options['vsync'] = 'vfr'
|
||||
end
|
||||
@output_options['fps_mode'] = 'vfr' if high_vfr?(metadata)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace :emojis do
|
||||
emojis_light = '👽⚾🐔☁️💨🕊️👀🍥👻🐐❕❔⛸️🌩️🔊🔇📃🌧️🐏🍚🍙🐓🐑💀☠️🌨️🔉🔈💬💭🏐🏳️⚪⬜◽◻️▫️🪽🪿'
|
||||
emojis_dark = '🎱🐜⚫🖤⬛◼️◾◼️✒️▪️💣🎳📷📸♣️🕶️✴️🔌💂♀️📽️🍳🦍💂🔪🕳️🕹️🕋🖊️🖋️💂♂️🎤🎓🎥🎼♠️🎩🦃📼📹🎮🐃🏴🐞🕺📱📲🚲🪮🐦⬛'
|
||||
|
||||
map = Oj.load(File.read(src))
|
||||
map = JSON.parse(File.read(src))
|
||||
|
||||
emojis_light.each_grapheme_cluster do |emoji|
|
||||
gen_border map[emoji], 'black'
|
||||
@@ -193,7 +193,7 @@ namespace :emojis do
|
||||
require 'vips'
|
||||
|
||||
src = Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_data.json')
|
||||
sheet = Oj.load(File.read(src))
|
||||
sheet = JSON.load_file(src)
|
||||
|
||||
max = 0
|
||||
sheet['emojis'].each_value do |row|
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace :repo do
|
||||
|
||||
while url.present?
|
||||
response = HTTP.get(url)
|
||||
contributors = Oj.load(response.body)
|
||||
contributors = JSON.parse(response.body)
|
||||
|
||||
contributors.each do |c|
|
||||
file << "* [#{c['login']}](#{c['html_url']})\n" if c['login']
|
||||
@@ -68,7 +68,7 @@ namespace :repo do
|
||||
end
|
||||
end
|
||||
|
||||
pull_request = Oj.load(response.to_s)
|
||||
pull_request = JSON.parse(response.to_s)
|
||||
pull_request['user']['login']
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ module ViteRuby::ManifestIntegrityExtension
|
||||
end
|
||||
|
||||
def load_name_lookup_cache
|
||||
Oj.load(config.build_output_dir.join('.vite/manifest-lookup.json').read)
|
||||
JSON.load_file(config.build_output_dir.join('.vite/manifest-lookup.json'))
|
||||
end
|
||||
|
||||
# Upstream's `virtual` type is a hack, re-implement it with efficient exact name lookup
|
||||
|
||||
@@ -11,6 +11,5 @@ Fabricator(:unverified_remote_collection_item, from: :collection_item) do
|
||||
account nil
|
||||
state :pending
|
||||
object_uri { Fabricate.build(:remote_account).uri }
|
||||
approval_uri { sequence(:uri) { |i| "https://example.com/authorizations/#{i}" } }
|
||||
uri { sequence(:uri) { |i| "https://example.com/collection_items/#{i}" } }
|
||||
end
|
||||
|
||||
@@ -171,5 +171,71 @@ RSpec.describe ActivityPub::Activity::Accept do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a FeatureRequest', feature: :collections_federation do
|
||||
let(:collection) { Fabricate(:collection, account: recipient) }
|
||||
let(:collection_item) { Fabricate(:collection_item, collection:, account: sender, state: :pending) }
|
||||
let(:object) { collection_item.activity_uri }
|
||||
let(:approval_uri) { 'https://example.com/stamps/1' }
|
||||
let(:json) do
|
||||
{
|
||||
'id' => 'https://example.com/accepts/1',
|
||||
'type' => 'Accept',
|
||||
'actor' => sender.uri,
|
||||
'to' => ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
'object' => object,
|
||||
'result' => approval_uri,
|
||||
}
|
||||
end
|
||||
|
||||
context 'when activity is valid' do
|
||||
it 'accepts the collection item, stores the authorization uri and federates an `Add` activity' do
|
||||
subject.perform
|
||||
|
||||
expect(collection_item.reload).to be_accepted
|
||||
expect(collection_item.approval_uri).to eq 'https://example.com/stamps/1'
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to have_enqueued_sidekiq_job
|
||||
end
|
||||
end
|
||||
|
||||
context 'when activity is invalid' do
|
||||
shared_examples 'ignoring activity' do
|
||||
it 'does not accept the item and does not send out an activity' do
|
||||
subject.perform
|
||||
|
||||
expect(collection_item.reload).to_not be_accepted
|
||||
expect(collection_item.approval_uri).to be_nil
|
||||
expect(ActivityPub::AccountRawDistributionWorker)
|
||||
.to_not have_enqueued_sidekiq_job
|
||||
end
|
||||
end
|
||||
|
||||
context 'when matching collection item cannot be found' do
|
||||
let(:object) { 'https://localhost/feature_requests/1' }
|
||||
|
||||
it_behaves_like 'ignoring activity'
|
||||
end
|
||||
|
||||
context 'when the sender is not the featured account' do
|
||||
let(:other_account) { Fabricate(:remote_account) }
|
||||
let(:collection_item) { Fabricate(:collection_item, collection:, account: other_account, state: :pending) }
|
||||
|
||||
it_behaves_like 'ignoring activity'
|
||||
end
|
||||
|
||||
context "when approval_uri does not match the sender's uri" do
|
||||
let(:approval_uri) { 'https://other.localhost/authorizations/1' }
|
||||
|
||||
it_behaves_like 'ignoring activity'
|
||||
end
|
||||
|
||||
context 'when approval_uri is missing' do
|
||||
let(:approval_uri) { nil }
|
||||
|
||||
it_behaves_like 'ignoring activity'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
context 'when sender is followed by a local account' do
|
||||
before do
|
||||
Fabricate(:account).follow!(sender)
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: JSON.generate(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: unknown_object_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
subject.perform
|
||||
end
|
||||
|
||||
@@ -120,7 +120,7 @@ RSpec.describe ActivityPub::Activity::Announce do
|
||||
let(:object_json) { 'https://example.com/actor/hello-world' }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: JSON.generate(unknown_object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/actor/hello-world').to_return(body: unknown_object_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'when the relay is enabled' do
|
||||
|
||||
@@ -1078,8 +1078,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -1104,7 +1104,11 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: object_json[:id],
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'creates a status with a verified quote' do
|
||||
@@ -1134,8 +1138,8 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
)
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -1160,7 +1164,11 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: object_json[:id],
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'creates a status without the verified quote' do
|
||||
@@ -1267,7 +1275,7 @@ RSpec.describe ActivityPub::Activity::Create do
|
||||
before do
|
||||
stub_request(:get, object_json[:id])
|
||||
.with(headers: { Authorization: "Bearer #{token}" })
|
||||
.to_return(body: JSON.generate(object_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
.to_return(body: object_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
|
||||
subject.perform
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do
|
||||
expect { subject.perform }
|
||||
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
outgoing_json = Oj.load(body)
|
||||
outgoing_json = JSON.parse(body)
|
||||
outgoing_json['type'] == 'Reject' && %w(type id actor object instrument).all? { |key| json[key] == outgoing_json['object'][key] }
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
@@ -78,7 +78,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do
|
||||
expect { subject.perform }
|
||||
.to enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
outgoing_json = Oj.load(body)
|
||||
outgoing_json = JSON.parse(body)
|
||||
outgoing_json['type'] == 'Reject' && json['instrument']['id'] == outgoing_json['object']['instrument'] && %w(type id actor object).all? { |key| json[key] == outgoing_json['object'][key] }
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
@@ -86,7 +86,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do
|
||||
|
||||
context 'when trying to quote a quotable local status' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/unknown-status').to_return(status: 200, body: JSON.generate(status_json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/unknown-status').to_return(status: 200, body: status_json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
quoted_post.update(quote_approval_policy: InteractionPolicy::POLICY_FLAGS[:public] << 16)
|
||||
end
|
||||
|
||||
@@ -95,7 +95,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do
|
||||
.to change { quoted_post.reload.quotes.accepted.count }.by(1)
|
||||
.and enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
outgoing_json = Oj.load(body)
|
||||
outgoing_json = JSON.parse(body)
|
||||
outgoing_json['type'] == 'Accept' && %w(type id actor object instrument).all? { |key| json[key] == outgoing_json['object'][key] }
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
@@ -113,7 +113,7 @@ RSpec.describe ActivityPub::Activity::QuoteRequest do
|
||||
.to change { quoted_post.reload.quotes.accepted.count }.by(1)
|
||||
.and enqueue_sidekiq_job(ActivityPub::DeliveryWorker)
|
||||
.with(satisfying do |body|
|
||||
outgoing_json = Oj.load(body)
|
||||
outgoing_json = JSON.parse(body)
|
||||
outgoing_json['type'] == 'Accept' && json['instrument']['id'] == outgoing_json['object']['instrument'] && %w(type id actor object).all? { |key| json[key] == outgoing_json['object'][key] }
|
||||
end, recipient.id, sender.inbox_url)
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ActivityPub::Activity::Reject do
|
||||
let(:sender) { Fabricate(:account) }
|
||||
let(:sender) { Fabricate(:remote_account) }
|
||||
let(:recipient) { Fabricate(:account) }
|
||||
|
||||
let(:json) do
|
||||
@@ -129,12 +129,12 @@ RSpec.describe ActivityPub::Activity::Reject do
|
||||
context 'with a QuoteRequest' do
|
||||
let(:status) { Fabricate(:status, account: recipient) }
|
||||
let(:quoted_status) { Fabricate(:status, account: sender) }
|
||||
let(:quote) { Fabricate(:quote, status: status, quoted_status: quoted_status, activity_uri: 'https://abc-123/456') }
|
||||
let!(:quote) { Fabricate(:quote, status: status, quoted_status: quoted_status) }
|
||||
let(:approval_uri) { "https://#{sender.domain}/approvals/1" }
|
||||
|
||||
let(:object_json) do
|
||||
{
|
||||
id: 'https://abc-123/456',
|
||||
id: quote.activity_uri,
|
||||
type: 'QuoteRequest',
|
||||
actor: ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
object: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
@@ -147,5 +147,23 @@ RSpec.describe ActivityPub::Activity::Reject do
|
||||
.to change { quote.reload.rejected? }.from(false).to(true)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a FeatureRequest' do
|
||||
let(:collection) { Fabricate(:collection, account: recipient) }
|
||||
let!(:collection_item) { Fabricate(:collection_item, collection:, account: sender, state: :pending) }
|
||||
let(:json) do
|
||||
{
|
||||
'id' => 'https://example.com/accepts/1',
|
||||
'type' => 'Accept',
|
||||
'actor' => sender.uri,
|
||||
'to' => ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
'object' => collection_item.activity_uri,
|
||||
}
|
||||
end
|
||||
|
||||
it 'deletes the collection item' do
|
||||
expect { subject.perform }.to change(collection.collection_items, :count).by(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -89,7 +89,7 @@ RSpec.describe ActivityPub::Activity do
|
||||
before do
|
||||
sender.update(uri: ActivityPub::TagManager.instance.uri_for(sender))
|
||||
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate(approval_payload))
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: approval_payload.to_json)
|
||||
end
|
||||
|
||||
context 'when getting them in order' do
|
||||
|
||||
@@ -12,7 +12,7 @@ RSpec.describe ActivityPub::Dereferencer do
|
||||
let(:uri) { nil }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/foo').to_return(body: JSON.generate(object), headers: { 'Content-Type' => 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/foo').to_return(body: object.to_json, headers: { 'Content-Type' => 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'with a URI' do
|
||||
|
||||
@@ -54,8 +54,8 @@ RSpec.describe ActivityPub::Forwarder do
|
||||
|
||||
it 'correctly forwards to expected remote followers' do
|
||||
expect { subject.forward! }
|
||||
.to enqueue_sidekiq_job(ActivityPub::LowPriorityDeliveryWorker).with(JSON.generate(payload), anything, eve.preferred_inbox_url)
|
||||
.and enqueue_sidekiq_job(ActivityPub::LowPriorityDeliveryWorker).with(JSON.generate(payload), anything, mallory.preferred_inbox_url)
|
||||
.to enqueue_sidekiq_job(ActivityPub::LowPriorityDeliveryWorker).with(payload.to_json, anything, eve.preferred_inbox_url)
|
||||
.and enqueue_sidekiq_job(ActivityPub::LowPriorityDeliveryWorker).with(payload.to_json, anything, mallory.preferred_inbox_url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -131,7 +131,7 @@ RSpec.describe Admin::SystemCheck::ElasticsearchCheck do
|
||||
|
||||
def stub_elasticsearch_error
|
||||
client = instance_double(Elasticsearch::Client)
|
||||
allow(client).to receive(:info).and_raise(Elasticsearch::Transport::Transport::Error)
|
||||
allow(client).to receive(:info).and_raise(Elastic::Transport::Transport::Error)
|
||||
allow(Chewy).to receive(:client).and_return(client)
|
||||
end
|
||||
end
|
||||
|
||||
14
spec/lib/elasticsearch/client_extensions_spec.rb
Normal file
14
spec/lib/elasticsearch/client_extensions_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Elasticsearch::ClientExtensions do
|
||||
describe '#initialize' do
|
||||
it 'marks the connection as verified on initialization' do
|
||||
client = Elasticsearch::Client.new
|
||||
|
||||
expect(client.instance_variable_get(:@verified))
|
||||
.to be(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -87,7 +87,7 @@ RSpec.describe Mastodon::CLI::Domains do
|
||||
end
|
||||
|
||||
def json_summary
|
||||
JSON.generate('host.example': { activity: {} })
|
||||
{ 'host.example': { activity: {} } }.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -36,7 +36,7 @@ RSpec.describe Mastodon::CLI::Search do
|
||||
context 'when server communication raises an error' do
|
||||
let(:options) { { reset_chewy: true } }
|
||||
|
||||
before { allow(Chewy::Stash::Specification).to receive(:reset!).and_raise(Elasticsearch::Transport::Transport::Errors::InternalServerError) }
|
||||
before { allow(Chewy::Stash::Specification).to receive(:reset!).and_raise(Elastic::Transport::Transport::Errors::InternalServerError) }
|
||||
|
||||
it 'Exits with error message' do
|
||||
expect { subject }
|
||||
|
||||
@@ -3,27 +3,34 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Webhooks::PayloadRenderer do
|
||||
subject(:renderer) { described_class.new(json) }
|
||||
subject(:renderer) { described_class.new(payload.to_json) }
|
||||
|
||||
let(:event) { Webhooks::EventPresenter.new(type, object) }
|
||||
let(:payload) { ActiveModelSerializers::SerializableResource.new(event, serializer: REST::Admin::WebhookEventSerializer, scope: nil, scope_name: :current_user).as_json }
|
||||
let(:json) { JSON.generate(payload) }
|
||||
|
||||
describe '#render' do
|
||||
subject { renderer.render(template) }
|
||||
|
||||
context 'when event is account.approved' do
|
||||
let(:type) { 'account.approved' }
|
||||
let(:object) { Fabricate(:account, display_name: 'Foo"') }
|
||||
let(:object) { Fabricate(:account, display_name: 'Foo"', username: 'foofoobarbar') }
|
||||
|
||||
it 'renders event-related variables into template' do
|
||||
expect(renderer.render('foo={{event}}')).to eq 'foo=account.approved'
|
||||
context 'with event-related variables' do
|
||||
let(:template) { 'foo={{event}}' }
|
||||
|
||||
it { is_expected.to eq('foo=account.approved') }
|
||||
end
|
||||
|
||||
it 'renders event-specific variables into template' do
|
||||
expect(renderer.render('foo={{object.username}}')).to eq "foo=#{object.username}"
|
||||
context 'with event-specific variables' do
|
||||
let(:template) { 'foo={{object.username}}' }
|
||||
|
||||
it { is_expected.to eq('foo=foofoobarbar') }
|
||||
end
|
||||
|
||||
it 'escapes values for use in JSON' do
|
||||
expect(renderer.render('foo={{object.account.display_name}}')).to eq 'foo=Foo\\"'
|
||||
context 'with values needing JSON escape' do
|
||||
let(:template) { 'foo={{object.account.display_name}}' }
|
||||
|
||||
it { is_expected.to eq('foo=Foo\\"') }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account::Avatar do
|
||||
describe 'static avatars', :attachment_processing do
|
||||
describe 'with a square GIF' do
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account::Header do
|
||||
describe 'base64-encoded files', :attachment_processing do
|
||||
let(:base64_attachment) { "data:image/jpeg;base64,#{Base64.encode64(attachment_fixture('attachment.jpg').read)}" }
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Account::Search do
|
||||
describe '.search_for' do
|
||||
before do
|
||||
|
||||
@@ -91,7 +91,7 @@ RSpec.describe 'Donation campaigns' do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, "#{api_url}?platform=web&seed=#{seed}&locale=en").to_return(body: JSON.generate(campaign_json), status: 200)
|
||||
stub_request(:get, "#{api_url}?platform=web&seed=#{seed}&locale=en").to_return(body: campaign_json.to_json, status: 200)
|
||||
end
|
||||
|
||||
it 'returns the expected campaign' do
|
||||
@@ -109,7 +109,7 @@ RSpec.describe 'Donation campaigns' do
|
||||
expect(Rails.cache.read("donation_campaign_request:#{seed}:en", raw: true))
|
||||
.to eq 'campaign-1:en'
|
||||
|
||||
expect(Oj.load(Rails.cache.read('donation_campaign:campaign-1:en', raw: true)))
|
||||
expect(JSON.parse(Rails.cache.read('donation_campaign:campaign-1:en', raw: true)))
|
||||
.to match(campaign_json)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,11 +75,11 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
|
||||
shared_examples 'sets pinned posts' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/account/pinned/known').to_return(status: 200, body: JSON.generate(status_json_pinned_known), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-inlined').to_return(status: 200, body: JSON.generate(status_json_pinned_unknown_inlined), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/pinned/known').to_return(status: 200, body: status_json_pinned_known.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-inlined').to_return(status: 200, body: status_json_pinned_unknown_inlined.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-unreachable').to_return(status: 404)
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: JSON.generate(status_json_pinned_unknown_reachable), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/collections/featured').to_return(status: 200, body: JSON.generate(featured_with_null), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: status_json_pinned_unknown_reachable.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, 'https://example.com/account/collections/featured').to_return(status: 200, body: featured_with_null.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
|
||||
subject
|
||||
end
|
||||
@@ -101,7 +101,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
let(:collection_or_uri) { actor.featured_collection_url }
|
||||
|
||||
before do
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets pinned posts'
|
||||
@@ -122,7 +122,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
|
||||
context 'when the endpoint is a Collection' do
|
||||
before do
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets pinned posts'
|
||||
@@ -139,7 +139,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets pinned posts'
|
||||
@@ -148,11 +148,12 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
let(:items) { 'https://example.com/account/pinned/unknown-reachable' }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: JSON.generate(status_json_pinned_unknown_reachable), headers: { 'Content-Type': 'application/activity+json' })
|
||||
subject
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: status_json_pinned_unknown_reachable.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'sets expected posts as pinned posts' do
|
||||
subject
|
||||
|
||||
expect(actor.pinned_statuses.pluck(:uri)).to contain_exactly(
|
||||
'https://example.com/account/pinned/unknown-reachable'
|
||||
)
|
||||
@@ -175,7 +176,7 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, actor.featured_collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets pinned posts'
|
||||
@@ -184,11 +185,12 @@ RSpec.describe ActivityPub::FetchFeaturedCollectionService do
|
||||
let(:items) { 'https://example.com/account/pinned/unknown-reachable' }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: JSON.generate(status_json_pinned_unknown_reachable), headers: { 'Content-Type': 'application/activity+json' })
|
||||
subject
|
||||
stub_request(:get, 'https://example.com/account/pinned/unknown-reachable').to_return(status: 200, body: status_json_pinned_unknown_reachable.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'sets expected posts as pinned posts' do
|
||||
subject
|
||||
|
||||
expect(actor.pinned_statuses.pluck(:uri)).to contain_exactly(
|
||||
'https://example.com/account/pinned/unknown-reachable'
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService do
|
||||
describe '#call' do
|
||||
context 'when the endpoint is a Collection' do
|
||||
before do
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets featured tags'
|
||||
@@ -46,7 +46,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService do
|
||||
|
||||
context 'when the account already has featured tags' do
|
||||
before do
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
|
||||
actor.featured_tags.create!(name: 'FoO')
|
||||
actor.featured_tags.create!(name: 'baz')
|
||||
@@ -67,7 +67,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets featured tags'
|
||||
@@ -88,7 +88,7 @@ RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_url).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'sets featured tags'
|
||||
|
||||
@@ -38,8 +38,8 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
before do
|
||||
actor[:inbox] = nil
|
||||
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and returns nil' do
|
||||
@@ -54,8 +54,8 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
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/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and sets attributes' do
|
||||
@@ -75,9 +75,9 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@iscool.af', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||
end
|
||||
|
||||
it 'fetches resource and looks up webfinger and follows redirection and sets attributes' do
|
||||
@@ -98,8 +98,8 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/bob', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and does not create account' do
|
||||
@@ -114,9 +114,9 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@iscool.af', links: [{ rel: 'self', href: 'https://example.com/bob', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||
end
|
||||
|
||||
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
|
||||
@@ -130,7 +130,7 @@ RSpec.describe ActivityPub::FetchRemoteAccountService do
|
||||
|
||||
context 'with wrong id' do
|
||||
it 'does not create account' do
|
||||
expect(subject.call('https://fake.address/@foo', prefetched_body: JSON.generate(actor))).to be_nil
|
||||
expect(subject.call('https://fake.address/@foo', prefetched_body: actor.to_json)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,8 +38,8 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
before do
|
||||
actor[:inbox] = nil
|
||||
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and returns nil' do
|
||||
@@ -54,8 +54,8 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
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/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and sets values' do
|
||||
@@ -75,9 +75,9 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@iscool.af', links: [{ rel: 'self', href: 'https://example.com/alice', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||
end
|
||||
|
||||
it 'fetches resource and looks up webfinger and follows redirect and sets values' do
|
||||
@@ -98,8 +98,8 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@example.com', links: [{ rel: 'self', href: 'https://example.com/bob', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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 'fetches resource and looks up webfinger and does not create account' do
|
||||
@@ -114,9 +114,9 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
let!(:webfinger) { { subject: 'acct:alice@iscool.af', links: [{ rel: 'self', href: 'https://example.com/bob', type: 'application/activity+json' }] } }
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: JSON.generate(webfinger), headers: { 'Content-Type': 'application/jrd+json' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://iscool.af/.well-known/webfinger?resource=acct:alice@iscool.af').to_return(body: webfinger.to_json, headers: { 'Content-Type': 'application/jrd+json' })
|
||||
end
|
||||
|
||||
it 'fetches resource and looks up webfinger and follows redirect and does not create account' do
|
||||
@@ -130,7 +130,7 @@ RSpec.describe ActivityPub::FetchRemoteActorService do
|
||||
|
||||
context 'with wrong id' do
|
||||
it 'does not create account' do
|
||||
expect(subject.call('https://fake.address/@foo', prefetched_body: JSON.generate(actor))).to be_nil
|
||||
expect(subject.call('https://fake.address/@foo', prefetched_body: actor.to_json)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,8 +50,8 @@ RSpec.describe ActivityPub::FetchRemoteKeyService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
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' })
|
||||
stub_request(:get, 'https://example.com/alice').to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
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
|
||||
|
||||
describe '#call' do
|
||||
@@ -59,7 +59,7 @@ RSpec.describe ActivityPub::FetchRemoteKeyService do
|
||||
|
||||
context 'when the key is a sub-object from the actor' do
|
||||
before do
|
||||
stub_request(:get, public_key_id).to_return(body: JSON.generate(actor), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, public_key_id).to_return(body: actor.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'returns the expected account' do
|
||||
@@ -71,7 +71,7 @@ RSpec.describe ActivityPub::FetchRemoteKeyService do
|
||||
let(:public_key_id) { 'https://example.com/alice-public-key.json' }
|
||||
|
||||
before do
|
||||
stub_request(:get, public_key_id).to_return(body: JSON.generate(key_json.merge({ '@context': ['https://w3id.org/security/v1'] })), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, public_key_id).to_return(body: key_json.merge({ '@context': ['https://w3id.org/security/v1'] }).to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'returns the expected account' do
|
||||
@@ -84,7 +84,7 @@ RSpec.describe ActivityPub::FetchRemoteKeyService do
|
||||
let(:actor_public_key) { 'https://example.com/alice-public-key.json' }
|
||||
|
||||
before do
|
||||
stub_request(:get, public_key_id).to_return(body: JSON.generate(key_json.merge({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] })), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, public_key_id).to_return(body: key_json.merge({ '@context': ['https://www.w3.org/ns/activitystreams', 'https://w3id.org/security/v1'] }).to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'returns the nil' do
|
||||
|
||||
@@ -11,7 +11,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
|
||||
let(:follower) { Fabricate(:account, username: 'alice') }
|
||||
let(:follow) { nil }
|
||||
let(:response) { { body: JSON.generate(object), headers: { 'content-type': 'application/activity+json' } } }
|
||||
let(:response) { { body: object.to_json, headers: { 'content-type': 'application/activity+json' } } }
|
||||
let(:existing_status) { nil }
|
||||
|
||||
let(:note) do
|
||||
@@ -369,7 +369,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
end
|
||||
|
||||
it 'creates statuses but not more than limit allows' do
|
||||
expect { subject.call(object[:id], prefetched_body: JSON.generate(object)) }
|
||||
expect { subject.call(object[:id], prefetched_body: object.to_json) }
|
||||
.to change { sender.statuses.count }.by_at_least(2)
|
||||
.and change { sender.statuses.count }.by_at_most(3)
|
||||
end
|
||||
@@ -419,7 +419,7 @@ RSpec.describe ActivityPub::FetchRemoteStatusService do
|
||||
end
|
||||
|
||||
it 'creates statuses but not more than limit allows' do
|
||||
expect { subject.call(object[:id], prefetched_body: JSON.generate(object)) }
|
||||
expect { subject.call(object[:id], prefetched_body: object.to_json) }
|
||||
.to change { sender.statuses.count }.by_at_least(2)
|
||||
.and change { sender.statuses.count }.by_at_most(3)
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ RSpec.describe ActivityPub::FetchRepliesService do
|
||||
|
||||
context 'when passing the URL to the collection' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'spawns workers for up to 5 replies on the same server' do
|
||||
@@ -93,7 +93,7 @@ RSpec.describe ActivityPub::FetchRepliesService do
|
||||
|
||||
context 'when passing the URL to the collection' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'spawns workers for up to 5 replies on the same server' do
|
||||
@@ -132,7 +132,7 @@ RSpec.describe ActivityPub::FetchRepliesService do
|
||||
|
||||
context 'when passing the URL to the collection' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'spawns workers for up to 5 replies on the same server' do
|
||||
|
||||
@@ -21,7 +21,7 @@ RSpec.describe ActivityPub::ProcessCollectionService do
|
||||
}
|
||||
end
|
||||
|
||||
let(:json) { JSON.generate(payload) }
|
||||
let(:json) { payload.to_json }
|
||||
|
||||
describe '#call' do
|
||||
context 'when actor is suspended' do
|
||||
|
||||
@@ -52,7 +52,7 @@ RSpec.describe ActivityPub::ProcessFeaturedItemService do
|
||||
|
||||
new_item = collection.collection_items.last
|
||||
expect(new_item.object_uri).to eq 'https://example.com/actor/1'
|
||||
expect(new_item.approval_uri).to eq 'https://example.com/auth/1'
|
||||
expect(new_item.approval_uri).to be_nil
|
||||
end
|
||||
|
||||
context 'when an item exists for a local featured account' do
|
||||
@@ -93,7 +93,7 @@ RSpec.describe ActivityPub::ProcessFeaturedItemService do
|
||||
|
||||
new_item = collection.collection_items.last
|
||||
expect(new_item.object_uri).to eq 'https://example.com/actor/1'
|
||||
expect(new_item.approval_uri).to eq 'https://example.com/auth/1'
|
||||
expect(new_item.approval_uri).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
],
|
||||
}
|
||||
end
|
||||
let(:json) { Oj.load(JSON.generate(payload)) }
|
||||
let(:json) { JSON.parse(payload.to_json) }
|
||||
|
||||
let(:alice) { Fabricate(:account) }
|
||||
let(:bob) { Fabricate(:account) }
|
||||
@@ -544,8 +544,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -570,7 +570,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the approval URI and verifies the quote' do
|
||||
@@ -609,8 +613,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -635,7 +639,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the approval URI and verifies the quote' do
|
||||
@@ -818,8 +826,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -844,7 +852,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the approval URI and verifies the quote' do
|
||||
@@ -883,8 +895,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -909,7 +921,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the approval URI but does not verify the quote' do
|
||||
@@ -1126,8 +1142,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -1152,7 +1168,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the URI and unverifies the quote' do
|
||||
@@ -1234,8 +1254,8 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, second_approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
let(:quote_authorization_json) do
|
||||
{
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
{
|
||||
@@ -1260,7 +1280,11 @@ RSpec.describe ActivityPub::ProcessStatusUpdateService do
|
||||
attributedTo: ActivityPub::TagManager.instance.uri_for(second_quoted_status.account),
|
||||
interactingObject: ActivityPub::TagManager.instance.uri_for(status),
|
||||
interactionTarget: ActivityPub::TagManager.instance.uri_for(second_quoted_status),
|
||||
}))
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, second_approval_uri).to_return(headers: { 'Content-Type': 'application/activity+json' }, body: quote_authorization_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the URI and unverifies the quote' do
|
||||
|
||||
@@ -55,7 +55,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
|
||||
context 'when the endpoint is a Collection of actor URIs' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -72,7 +72,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -93,7 +93,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -102,31 +102,31 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
context 'when the endpoint is a paginated Collection of actor URIs split across multiple pages' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/partial-followers')
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
type: 'Collection',
|
||||
id: 'https://example.com/partial-followers',
|
||||
first: 'https://example.com/partial-followers/1',
|
||||
}))
|
||||
}.to_json)
|
||||
|
||||
stub_request(:get, 'https://example.com/partial-followers/1')
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
type: 'CollectionPage',
|
||||
id: 'https://example.com/partial-followers/1',
|
||||
partOf: 'https://example.com/partial-followers',
|
||||
next: 'https://example.com/partial-followers/2',
|
||||
items: [alice, eve].map { |account| ActivityPub::TagManager.instance.uri_for(account) },
|
||||
}))
|
||||
}.to_json)
|
||||
|
||||
stub_request(:get, 'https://example.com/partial-followers/2')
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
type: 'CollectionPage',
|
||||
id: 'https://example.com/partial-followers/2',
|
||||
partOf: 'https://example.com/partial-followers',
|
||||
items: ActivityPub::TagManager.instance.uri_for(mallory),
|
||||
}))
|
||||
}.to_json)
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -135,22 +135,22 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
context 'when the endpoint is a paginated Collection of actor URIs split across, but one page errors out' do
|
||||
before do
|
||||
stub_request(:get, 'https://example.com/partial-followers')
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
type: 'Collection',
|
||||
id: 'https://example.com/partial-followers',
|
||||
first: 'https://example.com/partial-followers/1',
|
||||
}))
|
||||
}.to_json)
|
||||
|
||||
stub_request(:get, 'https://example.com/partial-followers/1')
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: JSON.generate({
|
||||
.to_return(status: 200, headers: { 'Content-Type': 'application/activity+json' }, body: {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
type: 'CollectionPage',
|
||||
id: 'https://example.com/partial-followers/1',
|
||||
partOf: 'https://example.com/partial-followers',
|
||||
next: 'https://example.com/partial-followers/2',
|
||||
items: [mallory].map { |account| ActivityPub::TagManager.instance.uri_for(account) },
|
||||
}))
|
||||
}.to_json)
|
||||
|
||||
stub_request(:get, 'https://example.com/partial-followers/2')
|
||||
.to_return(status: 404)
|
||||
@@ -185,7 +185,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
|
||||
before do
|
||||
stub_const('ActivityPub::SynchronizeFollowersService::MAX_COLLECTION_PAGES', 1)
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'confirms pending follow request but does not remove extra followers' do
|
||||
@@ -213,7 +213,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
|
||||
context 'when the endpoint is a Collection of actor URIs' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -230,7 +230,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -251,7 +251,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it_behaves_like 'synchronizes followers'
|
||||
@@ -263,7 +263,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
|
||||
context 'when the endpoint is a Collection of actor URIs' do
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'does not remove followers' do
|
||||
@@ -286,7 +286,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'does not remove followers' do
|
||||
@@ -313,7 +313,7 @@ RSpec.describe ActivityPub::SynchronizeFollowersService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: JSON.generate(payload), headers: { 'Content-Type': 'application/activity+json' })
|
||||
stub_request(:get, collection_uri).to_return(status: 200, body: payload.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
it 'does not remove followers' do
|
||||
|
||||
@@ -12,14 +12,14 @@ RSpec.describe ActivityPub::VerifyFeaturedItemService do
|
||||
account: nil,
|
||||
state: :pending,
|
||||
uri: 'https://other.example.com/items/1',
|
||||
object_uri: 'https://example.com/actor/1',
|
||||
approval_uri: verification_json['id'])
|
||||
object_uri: 'https://example.com/actor/1')
|
||||
end
|
||||
let(:approval_uri) { 'https://example.com/auth/1' }
|
||||
let(:verification_json) do
|
||||
{
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'type' => 'FeatureAuthorization',
|
||||
'id' => 'https://example.com/auth/1',
|
||||
'id' => approval_uri,
|
||||
'interactionTarget' => 'https://example.com/actor/1',
|
||||
'interactingObject' => collection.uri,
|
||||
}
|
||||
@@ -41,12 +41,13 @@ RSpec.describe ActivityPub::VerifyFeaturedItemService do
|
||||
before { featured_account }
|
||||
|
||||
it 'verifies and creates the item' do
|
||||
subject.call(collection_item)
|
||||
subject.call(collection_item, approval_uri)
|
||||
|
||||
expect(verification_request).to have_been_requested
|
||||
|
||||
expect(collection_item.account_id).to eq featured_account.id
|
||||
expect(collection_item).to be_accepted
|
||||
expect(collection_item.approval_uri).to eq approval_uri
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,13 +60,14 @@ RSpec.describe ActivityPub::VerifyFeaturedItemService do
|
||||
end
|
||||
|
||||
it 'fetches the actor and creates the item' do
|
||||
subject.call(collection_item)
|
||||
subject.call(collection_item, approval_uri)
|
||||
|
||||
expect(stubbed_service).to have_received(:call)
|
||||
expect(verification_request).to have_been_requested
|
||||
|
||||
expect(collection_item.account_id).to eq featured_account.id
|
||||
expect(collection_item).to be_accepted
|
||||
expect(collection_item.approval_uri).to eq approval_uri
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -77,7 +79,7 @@ RSpec.describe ActivityPub::VerifyFeaturedItemService do
|
||||
end
|
||||
|
||||
it 'creates item without attached account and in proper state' do
|
||||
subject.call(collection_item)
|
||||
subject.call(collection_item, approval_uri)
|
||||
|
||||
expect(collection_item.account_id).to be_nil
|
||||
expect(collection_item).to be_rejected
|
||||
|
||||
@@ -76,7 +76,7 @@ RSpec.describe ActivityPub::VerifyQuoteService do
|
||||
|
||||
before do
|
||||
stub_request(:get, approval_uri)
|
||||
.to_return(status: 200, body: JSON.generate(json), headers: { 'Content-Type': 'application/activity+json' })
|
||||
.to_return(status: 200, body: json.to_json, headers: { 'Content-Type': 'application/activity+json' })
|
||||
end
|
||||
|
||||
context 'with a valid activity for already-fetched posts' do
|
||||
@@ -179,7 +179,7 @@ RSpec.describe ActivityPub::VerifyQuoteService do
|
||||
|
||||
context 'with a valid activity for already-fetched posts, with a pre-fetched approval' do
|
||||
it 'updates the status without fetching the activity' do
|
||||
expect { subject.call(quote, prefetched_approval: JSON.generate(json)) }
|
||||
expect { subject.call(quote, prefetched_approval: json.to_json) }
|
||||
.to change(quote, :state).to('accepted')
|
||||
|
||||
expect(a_request(:get, approval_uri))
|
||||
|
||||
@@ -19,17 +19,15 @@ RSpec.describe FetchRemoteStatusService do
|
||||
context 'when protocol is :activitypub' do
|
||||
subject { described_class.new.call(note[:id], prefetched_body: prefetched_body) }
|
||||
|
||||
let(:prefetched_body) { JSON.generate(note) }
|
||||
|
||||
before do
|
||||
subject
|
||||
end
|
||||
let(:prefetched_body) { note.to_json }
|
||||
|
||||
it 'creates status' do
|
||||
status = account.statuses.first
|
||||
expect { subject }
|
||||
.to change(Status, :count).by(1)
|
||||
|
||||
expect(status).to_not be_nil
|
||||
expect(status.text).to eq 'Lorem ipsum'
|
||||
expect(account.statuses.first)
|
||||
.to be_present
|
||||
.and have_attributes(text: 'Lorem ipsum')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -150,7 +150,7 @@ RSpec.describe ResolveAccountService do
|
||||
end
|
||||
|
||||
context 'with webfinger response subject missing a host value' do
|
||||
let(:body) { JSON.generate({ subject: 'user@' }) }
|
||||
let(:body) { { subject: 'user@' }.to_json }
|
||||
let(:url) { 'https://host.example/.well-known/webfinger?resource=acct:user@host.example' }
|
||||
|
||||
before do
|
||||
|
||||
@@ -92,7 +92,7 @@ RSpec.describe SoftwareUpdateCheckService do
|
||||
end
|
||||
|
||||
before do
|
||||
stub_request(:get, full_update_check_url).to_return(body: JSON.generate(server_json))
|
||||
stub_request(:get, full_update_check_url).to_return(body: server_json.to_json)
|
||||
end
|
||||
|
||||
it 'updates the list of known updates' do
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user