Merge pull request #6365 from pixelfed/staging

Staging
pull/6374/head
dansup 10 months ago committed by GitHub
commit c68fb2e771
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,9 +1,18 @@
# Folders
.git/
storage/app/public/
mysql-9-data/
# Laravel
## local storage of media excluided from image
!storage/app/public/m/
storage/app/public/m/*
!bootstrap/cache/
bootstrap/cache/*
tests/
# Docker
mariadb-11-data/
redis-data/
tests/
# Packages
node_modules/
vendor/
.ddev/

@ -25,6 +25,7 @@ RUN install-php-extensions \
bcmath \
curl \
gd \
imagick \
intl \
mbstring \
xml \

@ -68,56 +68,68 @@ class UserAccountDelete extends Command
$profile = Profile::withTrashed()->find($user->profile_id);
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new DeleteActor());
$fractal = new Fractal\Manager;
$fractal->setSerializer(new ArraySerializer);
$resource = new Fractal\Resource\Item($profile, new DeleteActor);
$activity = $fractal->createData($resource)->toArray();
$audience = Instance::whereNotNull(['shared_inbox', 'nodeinfo_last_fetched'])
->where('nodeinfo_last_fetched', '>', now()->subDays(14))
->distinct()
->pluck('shared_inbox');
$payload = json_encode($activity);
$client = new Client([
'timeout' => 5,
'connect_timeout' => 2,
]);
$version = config('pixelfed.version');
$appUrl = config('app.url');
$userAgent = "(Pixelfed/{$version}; +{$appUrl})";
$requests = function ($audience) use ($client, $activity, $profile, $payload, $userAgent) {
foreach ($audience as $url) {
$headers = HttpSignature::sign($profile, $url, $activity, [
'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'User-Agent' => $userAgent,
]);
yield function () use ($client, $url, $headers, $payload) {
return $client->postAsync($url, [
'curl' => [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HEADER => true,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => false,
],
]);
$totalSent = 0;
$bar = $this->output->createProgressBar();
$bar->start();
Instance::whereNotNull('shared_inbox')
->whereNotNull('nodeinfo_last_fetched')
->where('nodeinfo_last_fetched', '>', now()->subDays(14))
->select(['shared_inbox'])
->distinct()
->chunk(500, function ($instances) use ($client, $activity, $profile, $payload, $userAgent, &$totalSent, $bar) {
$audience = $instances->pluck('shared_inbox')->unique();
$requests = function ($audience) use ($client, $activity, $profile, $payload, $userAgent) {
foreach ($audience as $url) {
$headers = HttpSignature::sign($profile, $url, $activity, [
'Content-Type' => 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"',
'User-Agent' => $userAgent,
]);
yield function () use ($client, $url, $headers, $payload) {
return $client->postAsync($url, [
'curl' => [
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HEADER => true,
],
]);
};
}
};
}
};
$pool = new Pool($client, $requests($audience), [
'concurrency' => 50,
'fulfilled' => function ($response, $index) {
},
'rejected' => function ($reason, $index) {
},
]);
$promise = $pool->promise();
$pool = new Pool($client, $requests($audience), [
'concurrency' => 100,
'fulfilled' => function ($response, $index) use (&$totalSent, $bar) {
$totalSent++;
$bar->advance();
},
'rejected' => function ($reason, $index) use ($bar) {
$bar->advance();
},
]);
$promise = $pool->promise();
$promise->wait();
});
$promise->wait();
$bar->finish();
$this->newLine();
$this->info("Successfully sent Delete activity to {$totalSent} instances.");
}
}

@ -1,18 +1,18 @@
services:
## MariaDB and Redis (optional)
db:
image: mariadb:11
image: mysql:9
container_name: pixelfed-db
restart: unless-stopped
env_file:
- .env
environment:
MARIADB_DATABASE: ${DB_DATABASE}
MARIADB_USER: ${DB_USERNAME}
MARIADB_PASSWORD: ${DB_PASSWORD}
MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- ./mariadb-11-data:/var/lib/mysql
- ./mysql-9-data:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
@ -88,10 +88,13 @@ services:
- .env
environment:
# Laravel Auto-run Configuration
AUTORUN_ENABLED: "false"
AUTORUN_LARAVEL_MIGRATION: "false"
AUTORUN_LARAVEL_MIGRATION_ISOLATION: "false"
AUTORUN_LARAVEL_STORAGE_LINK: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "true"
AUTORUN_LARAVEL_ROUTE_CACHE: "true"
AUTORUN_LARAVEL_VIEW_CACHE: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "false"
AUTORUN_LARAVEL_ROUTE_CACHE: "false"
AUTORUN_LARAVEL_VIEW_CACHE: "false"
AUTORUN_LARAVEL_CONFIG_CACHE: "true"
PHP_POST_MAX_SIZE: "500M"
PHP_UPLOAD_MAX_FILE_SIZE: "500M"
@ -122,10 +125,13 @@ services:
- .env
environment:
# Laravel Auto-run Configuration
AUTORUN_ENABLED: "false"
AUTORUN_LARAVEL_MIGRATION: "false"
AUTORUN_LARAVEL_MIGRATION_ISOLATION: "false"
AUTORUN_LARAVEL_STORAGE_LINK: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "true"
AUTORUN_LARAVEL_ROUTE_CACHE: "true"
AUTORUN_LARAVEL_VIEW_CACHE: "true"
AUTORUN_LARAVEL_EVENT_CACHE: "false"
AUTORUN_LARAVEL_ROUTE_CACHE: "false"
AUTORUN_LARAVEL_VIEW_CACHE: "false"
AUTORUN_LARAVEL_CONFIG_CACHE: "true"
PHP_POST_MAX_SIZE: "500M"
PHP_UPLOAD_MAX_FILE_SIZE: "500M"

Loading…
Cancel
Save