Compare commits
1 commit
activitypu
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
195130b220 |
7 changed files with 93 additions and 141 deletions
|
@ -1,7 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "faraday"
|
||||
require "uri"
|
||||
|
||||
class Api::V1::JsonLdController < Api::BaseController
|
||||
include ActionController::Live
|
||||
|
@ -10,40 +9,6 @@ class Api::V1::JsonLdController < Api::BaseController
|
|||
render json: { error: e.to_s }, status: 422
|
||||
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
|
||||
url = params[:url]
|
||||
|
||||
|
@ -52,12 +17,13 @@ class Api::V1::JsonLdController < Api::BaseController
|
|||
Thread.new {
|
||||
begin
|
||||
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
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
- 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 }/
|
||||
|
||||
= 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:type', 'website'
|
||||
= opengraph 'og:title', 'ActivityPub Academy'
|
||||
= opengraph 'og:title', @instance_presenter.title
|
||||
= 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:width', thumbnail ? thumbnail.meta['width'] : '500'
|
||||
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '573'
|
||||
= 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'] : '1200'
|
||||
= opengraph 'og:image:height', thumbnail ? thumbnail.meta['height'] : '630'
|
||||
= opengraph 'twitter:card', 'summary_large_image'
|
||||
|
|
|
@ -28,13 +28,17 @@ class Scheduler::OldAccountCleanupScheduler
|
|||
.where("domain IS NULL")
|
||||
# id -99 is the instance actor
|
||||
.where("id <> -99")
|
||||
# only delete accounts whose username contains underscores (those are auto-generated)
|
||||
.where("username LIKE '%\\_%'")
|
||||
# don't delete admin
|
||||
.where("username <> 'admin'")
|
||||
# don't delete crepels
|
||||
.where("username <> 'crepels'")
|
||||
# don't delete alice
|
||||
.where("username <> 'alice'")
|
||||
.where("created_at < ?", 1.day.ago)
|
||||
.order(created_at: :asc)
|
||||
.limit(MAX_DELETIONS_PER_JOB)
|
||||
.each do |account|
|
||||
AccountDeletionWorker.perform_async(account.id, { 'reserve_username' => false })
|
||||
AccountDeletionWorker.perform_async(account.id, { :reserve_username => false })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
21
dist/nginx.conf
vendored
21
dist/nginx.conf
vendored
|
@ -114,27 +114,6 @@ server {
|
|||
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 {
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
|
|
@ -152,7 +152,7 @@
|
|||
"eslint-plugin-promise": "~6.1.1",
|
||||
"eslint-plugin-react": "~7.32.2",
|
||||
"jest": "^29.4.1",
|
||||
"jest-environment-jsdom": "^29.4.1",
|
||||
"jest-environment-jsdom": "^29.6.2",
|
||||
"postcss-scss": "^4.0.6",
|
||||
"prettier": "^2.8.3",
|
||||
"raf": "^3.4.1",
|
||||
|
|
|
@ -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
|
116
yarn.lock
116
yarn.lock
|
@ -1294,15 +1294,15 @@
|
|||
slash "^3.0.0"
|
||||
strip-ansi "^6.0.0"
|
||||
|
||||
"@jest/environment@^29.4.1":
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.4.1.tgz#52d232a85cdc995b407a940c89c86568f5a88ffe"
|
||||
integrity sha512-pJ14dHGSQke7Q3mkL/UZR9ZtTOxqskZaC91NzamEH4dlKRt42W+maRBXiw/LWkdJe+P0f/zDR37+SPMplMRlPg==
|
||||
"@jest/environment@^29.4.1", "@jest/environment@^29.6.2":
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-29.6.2.tgz#794c0f769d85e7553439d107d3f43186dc6874a9"
|
||||
integrity sha512-AEcW43C7huGd/vogTddNNTDRpO6vQ2zaQNrttvWV18ArBx9Z56h7BIsXkNFJVOO4/kblWEQz30ckw0+L3izc+Q==
|
||||
dependencies:
|
||||
"@jest/fake-timers" "^29.4.1"
|
||||
"@jest/types" "^29.4.1"
|
||||
"@jest/fake-timers" "^29.6.2"
|
||||
"@jest/types" "^29.6.1"
|
||||
"@types/node" "*"
|
||||
jest-mock "^29.4.1"
|
||||
jest-mock "^29.6.2"
|
||||
|
||||
"@jest/expect-utils@^29.4.1":
|
||||
version "29.4.1"
|
||||
|
@ -1319,17 +1319,17 @@
|
|||
expect "^29.4.1"
|
||||
jest-snapshot "^29.4.1"
|
||||
|
||||
"@jest/fake-timers@^29.4.1":
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.4.1.tgz#7b673131e8ea2a2045858f08241cace5d518b42b"
|
||||
integrity sha512-/1joI6rfHFmmm39JxNfmNAO3Nwm6Y0VoL5fJDy7H1AtWrD1CgRtqJbN9Ld6rhAkGO76qqp4cwhhxJ9o9kYjQMw==
|
||||
"@jest/fake-timers@^29.4.1", "@jest/fake-timers@^29.6.2":
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-29.6.2.tgz#fe9d43c5e4b1b901168fe6f46f861b3e652a2df4"
|
||||
integrity sha512-euZDmIlWjm1Z0lJ1D0f7a0/y5Kh/koLFMUBE5SUYWrmy8oNhJpbTBDAP6CxKnadcMLDoDf4waRYCe35cH6G6PA==
|
||||
dependencies:
|
||||
"@jest/types" "^29.4.1"
|
||||
"@jest/types" "^29.6.1"
|
||||
"@sinonjs/fake-timers" "^10.0.2"
|
||||
"@types/node" "*"
|
||||
jest-message-util "^29.4.1"
|
||||
jest-mock "^29.4.1"
|
||||
jest-util "^29.4.1"
|
||||
jest-message-util "^29.6.2"
|
||||
jest-mock "^29.6.2"
|
||||
jest-util "^29.6.2"
|
||||
|
||||
"@jest/globals@^29.4.1":
|
||||
version "29.4.1"
|
||||
|
@ -1378,6 +1378,13 @@
|
|||
dependencies:
|
||||
"@sinclair/typebox" "^0.25.16"
|
||||
|
||||
"@jest/schemas@^29.6.0":
|
||||
version "29.6.0"
|
||||
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.6.0.tgz#0f4cb2c8e3dca80c135507ba5635a4fd755b0040"
|
||||
integrity sha512-rxLjXyJBTL4LQeJW3aKo0M/+GkCOXsO+8i9Iu7eDb6KwtP65ayoDsitrdPBtujxQ88k4wI2FNYfa6TOGwSn6cQ==
|
||||
dependencies:
|
||||
"@sinclair/typebox" "^0.27.8"
|
||||
|
||||
"@jest/source-map@^29.2.0":
|
||||
version "29.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-29.2.0.tgz#ab3420c46d42508dcc3dc1c6deee0b613c235744"
|
||||
|
@ -1449,12 +1456,12 @@
|
|||
"@types/yargs" "^16.0.0"
|
||||
chalk "^4.0.0"
|
||||
|
||||
"@jest/types@^29.4.1":
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.4.1.tgz#f9f83d0916f50696661da72766132729dcb82ecb"
|
||||
integrity sha512-zbrAXDUOnpJ+FMST2rV7QZOgec8rskg2zv8g2ajeqitp4tvZiyqTCYXANrKsM+ryj5o+LI+ZN2EgU9drrkiwSA==
|
||||
"@jest/types@^29.4.1", "@jest/types@^29.6.1":
|
||||
version "29.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.6.1.tgz#ae79080278acff0a6af5eb49d063385aaa897bf2"
|
||||
integrity sha512-tPKQNMPuXgvdOn2/Lg9HNfUvjYVGolt04Hp03f5hAk878uwOLikN+JzeLY0HcVgKgFl9Hs3EIqpu3WX27XNhnw==
|
||||
dependencies:
|
||||
"@jest/schemas" "^29.4.0"
|
||||
"@jest/schemas" "^29.6.0"
|
||||
"@types/istanbul-lib-coverage" "^2.0.0"
|
||||
"@types/istanbul-reports" "^3.0.0"
|
||||
"@types/node" "*"
|
||||
|
@ -1627,6 +1634,11 @@
|
|||
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.25.21.tgz#763b05a4b472c93a8db29b2c3e359d55b29ce272"
|
||||
integrity sha512-gFukHN4t8K4+wVC+ECqeqwzBDeFeTzBXroBTqE6vcWrQGbEUpHO7LYdG0f4xnvYq4VOEwITSlHlp0JBAIFMS/g==
|
||||
|
||||
"@sinclair/typebox@^0.27.8":
|
||||
version "0.27.8"
|
||||
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.27.8.tgz#6667fac16c436b5434a387a34dedb013198f6e6e"
|
||||
integrity sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==
|
||||
|
||||
"@sinonjs/commons@^2.0.0":
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-2.0.0.tgz#fd4ca5b063554307e8327b4564bd56d3b73924a3"
|
||||
|
@ -6567,18 +6579,18 @@ jest-each@^29.4.1:
|
|||
jest-util "^29.4.1"
|
||||
pretty-format "^29.4.1"
|
||||
|
||||
jest-environment-jsdom@^29.4.1:
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.4.1.tgz#34d491244ddd6fe3d666da603b576bd0ae6aef78"
|
||||
integrity sha512-+KfYmRTl5CBHQst9hIz77TiiriHYvuWoLjMT855gx2AMxhHxpk1vtKvag1DQfyWCPVTWV/AG7SIqVh5WI1O/uw==
|
||||
jest-environment-jsdom@^29.6.2:
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-29.6.2.tgz#4fc68836a7774a771819a2f980cb47af3b1629da"
|
||||
integrity sha512-7oa/+266AAEgkzae8i1awNEfTfjwawWKLpiw2XesZmaoVVj9u9t8JOYx18cG29rbPNtkUlZ8V4b5Jb36y/VxoQ==
|
||||
dependencies:
|
||||
"@jest/environment" "^29.4.1"
|
||||
"@jest/fake-timers" "^29.4.1"
|
||||
"@jest/types" "^29.4.1"
|
||||
"@jest/environment" "^29.6.2"
|
||||
"@jest/fake-timers" "^29.6.2"
|
||||
"@jest/types" "^29.6.1"
|
||||
"@types/jsdom" "^20.0.0"
|
||||
"@types/node" "*"
|
||||
jest-mock "^29.4.1"
|
||||
jest-util "^29.4.1"
|
||||
jest-mock "^29.6.2"
|
||||
jest-util "^29.6.2"
|
||||
jsdom "^20.0.0"
|
||||
|
||||
jest-environment-node@^29.4.1:
|
||||
|
@ -6655,14 +6667,29 @@ jest-message-util@^29.4.1:
|
|||
slash "^3.0.0"
|
||||
stack-utils "^2.0.3"
|
||||
|
||||
jest-mock@^29.4.1:
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.4.1.tgz#a218a2abf45c99c501d4665207748a6b9e29afbd"
|
||||
integrity sha512-MwA4hQ7zBOcgVCVnsM8TzaFLVUD/pFWTfbkY953Y81L5ret3GFRZtmPmRFAjKQSdCKoJvvqOu6Bvfpqlwwb0dQ==
|
||||
jest-message-util@^29.6.2:
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.6.2.tgz#af7adc2209c552f3f5ae31e77cf0a261f23dc2bb"
|
||||
integrity sha512-vnIGYEjoPSuRqV8W9t+Wow95SDp6KPX2Uf7EoeG9G99J2OVh7OSwpS4B6J0NfpEIpfkBNHlBZpA2rblEuEFhZQ==
|
||||
dependencies:
|
||||
"@jest/types" "^29.4.1"
|
||||
"@babel/code-frame" "^7.12.13"
|
||||
"@jest/types" "^29.6.1"
|
||||
"@types/stack-utils" "^2.0.0"
|
||||
chalk "^4.0.0"
|
||||
graceful-fs "^4.2.9"
|
||||
micromatch "^4.0.4"
|
||||
pretty-format "^29.6.2"
|
||||
slash "^3.0.0"
|
||||
stack-utils "^2.0.3"
|
||||
|
||||
jest-mock@^29.4.1, jest-mock@^29.6.2:
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-29.6.2.tgz#ef9c9b4d38c34a2ad61010a021866dad41ce5e00"
|
||||
integrity sha512-hoSv3lb3byzdKfwqCuT6uTscan471GUECqgNYykg6ob0yiAw3zYc7OrPnI9Qv8Wwoa4lC7AZ9hyS4AiIx5U2zg==
|
||||
dependencies:
|
||||
"@jest/types" "^29.6.1"
|
||||
"@types/node" "*"
|
||||
jest-util "^29.4.1"
|
||||
jest-util "^29.6.2"
|
||||
|
||||
jest-pnp-resolver@^1.2.2:
|
||||
version "1.2.2"
|
||||
|
@ -6783,12 +6810,12 @@ jest-snapshot@^29.4.1:
|
|||
pretty-format "^29.4.1"
|
||||
semver "^7.3.5"
|
||||
|
||||
jest-util@^29.4.1:
|
||||
version "29.4.1"
|
||||
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.4.1.tgz#2eeed98ff4563b441b5a656ed1a786e3abc3e4c4"
|
||||
integrity sha512-bQy9FPGxVutgpN4VRc0hk6w7Hx/m6L53QxpDreTZgJd9gfx/AV2MjyPde9tGyZRINAUrSv57p2inGBu2dRLmkQ==
|
||||
jest-util@^29.4.1, jest-util@^29.6.2:
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.6.2.tgz#8a052df8fff2eebe446769fd88814521a517664d"
|
||||
integrity sha512-3eX1qb6L88lJNCFlEADKOkjpXJQyZRiavX1INZ4tRnrBVr2COd3RgcTLyUiEXMNBlDU/cgYq6taUS0fExrWW4w==
|
||||
dependencies:
|
||||
"@jest/types" "^29.4.1"
|
||||
"@jest/types" "^29.6.1"
|
||||
"@types/node" "*"
|
||||
chalk "^4.0.0"
|
||||
ci-info "^3.2.0"
|
||||
|
@ -8798,6 +8825,15 @@ pretty-format@^29.4.1:
|
|||
ansi-styles "^5.0.0"
|
||||
react-is "^18.0.0"
|
||||
|
||||
pretty-format@^29.6.2:
|
||||
version "29.6.2"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.6.2.tgz#3d5829261a8a4d89d8b9769064b29c50ed486a47"
|
||||
integrity sha512-1q0oC8eRveTg5nnBEWMXAU2qpv65Gnuf2eCQzSjxpWFkPaPARwqZZDGuNE0zPAZfTCHzIk3A8dIjwlQKKLphyg==
|
||||
dependencies:
|
||||
"@jest/schemas" "^29.6.0"
|
||||
ansi-styles "^5.0.0"
|
||||
react-is "^18.0.0"
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
|
|
Loading…
Add table
Reference in a new issue