Compare commits
1 commit
activitypu
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
509e341927 |
10 changed files with 26 additions and 117 deletions
2
Gemfile
2
Gemfile
|
@ -118,7 +118,7 @@ group :production, :test do
|
||||||
end
|
end
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'capybara', '~> 3.38'
|
gem 'capybara', '~> 3.39'
|
||||||
gem 'climate_control', '~> 0.2'
|
gem 'climate_control', '~> 0.2'
|
||||||
gem 'faker', '~> 3.1'
|
gem 'faker', '~> 3.1'
|
||||||
gem 'json-schema', '~> 3.0'
|
gem 'json-schema', '~> 3.0'
|
||||||
|
|
|
@ -151,7 +151,7 @@ GEM
|
||||||
sshkit (~> 1.3)
|
sshkit (~> 1.3)
|
||||||
capistrano-yarn (2.0.2)
|
capistrano-yarn (2.0.2)
|
||||||
capistrano (~> 3.0)
|
capistrano (~> 3.0)
|
||||||
capybara (3.38.0)
|
capybara (3.39.2)
|
||||||
addressable
|
addressable
|
||||||
matrix
|
matrix
|
||||||
mini_mime (>= 0.1.3)
|
mini_mime (>= 0.1.3)
|
||||||
|
@ -496,7 +496,7 @@ GEM
|
||||||
pundit (2.3.0)
|
pundit (2.3.0)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
raabro (1.4.0)
|
raabro (1.4.0)
|
||||||
racc (1.6.2)
|
racc (1.7.1)
|
||||||
rack (2.2.7)
|
rack (2.2.7)
|
||||||
rack-attack (6.6.1)
|
rack-attack (6.6.1)
|
||||||
rack (>= 1.0, < 3)
|
rack (>= 1.0, < 3)
|
||||||
|
@ -560,7 +560,7 @@ GEM
|
||||||
redis (>= 4)
|
redis (>= 4)
|
||||||
redlock (1.3.2)
|
redlock (1.3.2)
|
||||||
redis (>= 3.0.0, < 6.0)
|
redis (>= 3.0.0, < 6.0)
|
||||||
regexp_parser (2.6.2)
|
regexp_parser (2.8.1)
|
||||||
request_store (1.5.1)
|
request_store (1.5.1)
|
||||||
rack (>= 1.4)
|
rack (>= 1.4)
|
||||||
responders (3.0.1)
|
responders (3.0.1)
|
||||||
|
@ -777,7 +777,7 @@ DEPENDENCIES
|
||||||
capistrano-rails (~> 1.6)
|
capistrano-rails (~> 1.6)
|
||||||
capistrano-rbenv (~> 2.2)
|
capistrano-rbenv (~> 2.2)
|
||||||
capistrano-yarn (~> 2.0)
|
capistrano-yarn (~> 2.0)
|
||||||
capybara (~> 3.38)
|
capybara (~> 3.39)
|
||||||
charlock_holmes (~> 0.7.7)
|
charlock_holmes (~> 0.7.7)
|
||||||
chewy (~> 7.2)
|
chewy (~> 7.2)
|
||||||
climate_control (~> 0.2)
|
climate_control (~> 0.2)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "faraday"
|
require "faraday"
|
||||||
require "uri"
|
|
||||||
|
|
||||||
class Api::V1::JsonLdController < Api::BaseController
|
class Api::V1::JsonLdController < Api::BaseController
|
||||||
include ActionController::Live
|
include ActionController::Live
|
||||||
|
@ -10,40 +9,6 @@ class Api::V1::JsonLdController < Api::BaseController
|
||||||
render json: { error: e.to_s }, status: 422
|
render json: { error: e.to_s }, status: 422
|
||||||
end
|
end
|
||||||
|
|
||||||
before_action :require_user!
|
|
||||||
|
|
||||||
REQUEST_TARGET = '(request-target)'
|
|
||||||
|
|
||||||
def signature(headers)
|
|
||||||
account = Account.representative
|
|
||||||
|
|
||||||
key_id = ActivityPub::TagManager.instance.key_uri_for(account)
|
|
||||||
algorithm = 'rsa-sha256'
|
|
||||||
signed_string = headers.map { |key, value| "#{key.downcase}: #{value}" }.join("\n")
|
|
||||||
signature = Base64.strict_encode64(account.keypair.sign(OpenSSL::Digest.new('SHA256'), signed_string))
|
|
||||||
|
|
||||||
"keyId=\"#{key_id}\",algorithm=\"#{algorithm}\",headers=\"#{headers.keys.join(' ').downcase}\",signature=\"#{signature}\""
|
|
||||||
end
|
|
||||||
|
|
||||||
def signed_headers(url_string)
|
|
||||||
if url_string.include?(".well-known")
|
|
||||||
return {'Accept': 'application/jrd+json'}
|
|
||||||
end
|
|
||||||
|
|
||||||
url = URI.parse(url_string)
|
|
||||||
tmp_headers = {
|
|
||||||
'Date': Time.now.utc.httpdate,
|
|
||||||
'Host': url.host,
|
|
||||||
'Accept': 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
|
|
||||||
}
|
|
||||||
tmp_headers[REQUEST_TARGET] = "get #{url_string.delete_prefix("#{url.scheme}://#{url.host}")}"
|
|
||||||
additional_headers = {
|
|
||||||
'Signature': signature(tmp_headers),
|
|
||||||
'User-Agent': Mastodon::Version.user_agent,
|
|
||||||
}
|
|
||||||
tmp_headers.merge(additional_headers).except(REQUEST_TARGET)
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
def show
|
||||||
url = params[:url]
|
url = params[:url]
|
||||||
|
|
||||||
|
@ -52,12 +17,13 @@ class Api::V1::JsonLdController < Api::BaseController
|
||||||
Thread.new {
|
Thread.new {
|
||||||
begin
|
begin
|
||||||
conn = Faraday::Connection.new
|
conn = Faraday::Connection.new
|
||||||
|
conn.options.timeout = 5
|
||||||
|
|
||||||
api_response = conn.get(url, nil, signed_headers(url))
|
api_response = conn.get(url, nil, {'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'})
|
||||||
|
|
||||||
max_redirects = 5
|
max_redirects = 5
|
||||||
while api_response.status == 301 || api_response.status == 302 and max_redirects > 0 do
|
while api_response.status == 301 || api_response.status == 302 and max_redirects > 0 do
|
||||||
api_response = conn.get(api_response.headers['Location'], nil, signed_headers(api_response.headers['Location']))
|
api_response = conn.get(api_response.headers['Location'], nil, {'Accept' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'})
|
||||||
max_redirects -= 1
|
max_redirects -= 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
- thumbnail = @instance_presenter.thumbnail
|
- thumbnail = @instance_presenter.thumbnail
|
||||||
- description = 'Learn ActivityPub interactively, by seeing protocol interactions visualized in real time'
|
- description ||= @instance_presenter.description.presence || strip_tags(t('about.about_mastodon_html'))
|
||||||
|
|
||||||
%meta{ name: 'description', content: description }/
|
%meta{ name: 'description', content: description }/
|
||||||
|
|
||||||
= opengraph 'og:site_name', 'ActivityPub Academy - A learning resource for ActivityPub'
|
= opengraph 'og:site_name', t('about.hosted_on', domain: site_hostname)
|
||||||
= opengraph 'og:url', url_for(only_path: false)
|
= opengraph 'og:url', url_for(only_path: false)
|
||||||
= opengraph 'og:type', 'website'
|
= opengraph 'og:type', 'website'
|
||||||
= opengraph 'og:title', 'ActivityPub Academy'
|
= opengraph 'og:title', @instance_presenter.title
|
||||||
= opengraph 'og:description', description
|
= opengraph 'og:description', description
|
||||||
= opengraph 'og:image', full_asset_url(thumbnail&.file&.url(:'@1x') || asset_pack_path('media/images/academy-mascot.webp', protocol: :request))
|
= opengraph 'og:image', full_asset_url(thumbnail&.file&.url(:'@1x') || asset_pack_path('media/images/preview.png', protocol: :request))
|
||||||
= opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '500'
|
= opengraph 'og:image:width', thumbnail ? thumbnail.meta['width'] : '1200'
|
||||||
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '573'
|
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630'
|
||||||
= opengraph 'twitter:card', 'summary_large_image'
|
= opengraph 'twitter:card', 'summary_large_image'
|
||||||
|
|
|
@ -28,13 +28,15 @@ class Scheduler::OldAccountCleanupScheduler
|
||||||
.where("domain IS NULL")
|
.where("domain IS NULL")
|
||||||
# id -99 is the instance actor
|
# id -99 is the instance actor
|
||||||
.where("id <> -99")
|
.where("id <> -99")
|
||||||
# only delete accounts whose username contains underscores (those are auto-generated)
|
# don't delete admin
|
||||||
.where("username LIKE '%\\_%'")
|
.where("username <> 'admin'")
|
||||||
|
# don't delete crepels
|
||||||
|
.where("username <> 'crepels'")
|
||||||
.where("created_at < ?", 1.day.ago)
|
.where("created_at < ?", 1.day.ago)
|
||||||
.order(created_at: :asc)
|
.order(created_at: :asc)
|
||||||
.limit(MAX_DELETIONS_PER_JOB)
|
.limit(MAX_DELETIONS_PER_JOB)
|
||||||
.each do |account|
|
.each do |account|
|
||||||
AccountDeletionWorker.perform_async(account.id, { 'reserve_username' => false })
|
AccountDeletionWorker.perform_async(account.id, { :reserve_username => false })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
21
dist/nginx.conf
vendored
21
dist/nginx.conf
vendored
|
@ -114,27 +114,6 @@ server {
|
||||||
tcp_nodelay on;
|
tcp_nodelay on;
|
||||||
}
|
}
|
||||||
|
|
||||||
location ^~ /api/v1/json_ld {
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto https;
|
|
||||||
proxy_set_header Proxy "";
|
|
||||||
proxy_pass_header Server;
|
|
||||||
|
|
||||||
proxy_pass http://backend;
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection '';
|
|
||||||
|
|
||||||
proxy_cache off;
|
|
||||||
proxy_buffering off;
|
|
||||||
chunked_transfer_encoding off;
|
|
||||||
|
|
||||||
tcp_nodelay on;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ^~ /api/v1/activity_log {
|
location ^~ /api/v1/activity_log {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
"name": "@mastodon/mastodon",
|
"name": "@mastodon/mastodon",
|
||||||
"license": "AGPL-3.0-or-later",
|
"license": "AGPL-3.0-or-later",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
"@github/webauthn-json": "^0.5.7",
|
"@github/webauthn-json": "^0.5.7",
|
||||||
"@rails/ujs": "^6.1.7",
|
"@rails/ujs": "^6.1.7",
|
||||||
"abortcontroller-polyfill": "^1.7.5",
|
"abortcontroller-polyfill": "^1.7.5",
|
||||||
"activitypub-visualization": "^1.3.7",
|
"activitypub-visualization": "^1.3.3",
|
||||||
"array-includes": "^3.1.6",
|
"array-includes": "^3.1.6",
|
||||||
"arrow-key-navigation": "^1.2.0",
|
"arrow-key-navigation": "^1.2.0",
|
||||||
"autoprefixer": "^9.8.8",
|
"autoprefixer": "^9.8.8",
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -1,33 +0,0 @@
|
||||||
require 'json'
|
|
||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
RSpec.describe Scheduler::OldAccountCleanupScheduler do
|
|
||||||
subject { described_class.new }
|
|
||||||
let!(:generated_user) { Fabricate(:account, username: 'containing_underscore', created_at: 25.hours.ago) }
|
|
||||||
let!(:alice) { Fabricate(:account, username: 'alice', created_at: 25.hours.ago) }
|
|
||||||
let!(:generated_user_other_instance) { Fabricate(:account, username: 'containing_underscore', domain: 'example.com', created_at: 25.hours.ago) }
|
|
||||||
let!(:instance_actor) { Fabricate(:account, id: 99, created_at: 25.hours.ago) }
|
|
||||||
|
|
||||||
describe '#perform' do
|
|
||||||
it 'removes auto-generated user-accounts that are older than one day' do
|
|
||||||
expect { subject.perform }.to change { Account.exists?(generated_user.id) }.from(true).to(false)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not remove auto-generated user-accounts that are younger than one day' do
|
|
||||||
generated_user.update!(created_at: 23.hours.ago)
|
|
||||||
expect { subject.perform }.not_to change { Account.exists?(generated_user.id) }.from(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not remove accounts with underscores from other instances' do
|
|
||||||
expect { subject.perform }.not_to change { Account.exists?(generated_user_other_instance.id) }.from(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not remove accounts without underscores' do
|
|
||||||
expect { subject.perform }.not_to change { Account.exists?(alice.id) }.from(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'does not remove instance actor' do
|
|
||||||
expect { subject.perform }.not_to change { Account.exists?(instance_actor.id) }.from(true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
15
yarn.lock
15
yarn.lock
|
@ -2190,12 +2190,10 @@ acorn@^8.8.0:
|
||||||
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
|
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.8.2.tgz#1b2f25db02af965399b9776b0c2c391276d37c4a"
|
||||||
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
|
integrity sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==
|
||||||
|
|
||||||
activitypub-visualization@^1.3.7:
|
activitypub-visualization@^1.3.3:
|
||||||
version "1.3.7"
|
version "1.3.3"
|
||||||
resolved "https://registry.yarnpkg.com/activitypub-visualization/-/activitypub-visualization-1.3.7.tgz#55e8e6dbc9b4cecff46c45a776219c47865d15d8"
|
resolved "https://registry.yarnpkg.com/activitypub-visualization/-/activitypub-visualization-1.3.3.tgz#e293640b62dff45b1d9b2348ce9a401b1f2d4c90"
|
||||||
integrity sha512-Cta1l2rogf273NkHUsNjPMrfUcUzCV5Hk1xg94ThW0hYuLGI4GXWGij9PRIjHn6aDM407NHV+T3494+I9s1fMA==
|
integrity sha512-Sn2sos361y2voyfs+5kPTTG2yK6zcFvScgLQAE34OpOyOs0BtdNsJtRppp32JOPHulScTvEqiFEmgaOTIcL9WA==
|
||||||
dependencies:
|
|
||||||
dompurify "^3.0.5"
|
|
||||||
|
|
||||||
agent-base@6:
|
agent-base@6:
|
||||||
version "6.0.2"
|
version "6.0.2"
|
||||||
|
@ -4197,11 +4195,6 @@ domexception@^4.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
webidl-conversions "^7.0.0"
|
webidl-conversions "^7.0.0"
|
||||||
|
|
||||||
dompurify@^3.0.5:
|
|
||||||
version "3.0.5"
|
|
||||||
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-3.0.5.tgz#eb3d9cfa10037b6e73f32c586682c4b2ab01fbed"
|
|
||||||
integrity sha512-F9e6wPGtY+8KNMRAVfxeCOHU0/NPWMSENNq4pQctuXRqqdEPW7q3CrLbR5Nse044WwacyjHGOMlvNsBe1y6z9A==
|
|
||||||
|
|
||||||
domutils@^1.7.0:
|
domutils@^1.7.0:
|
||||||
version "1.7.0"
|
version "1.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
|
resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a"
|
||||||
|
|
Loading…
Add table
Reference in a new issue