mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 20:41:27 +00:00
Merge pull request #588 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
2129155ac0
2 changed files with 52 additions and 22 deletions
|
@ -33,6 +33,7 @@ class UpdateCommand extends Command
|
||||||
'0.1.7',
|
'0.1.7',
|
||||||
'0.1.8',
|
'0.1.8',
|
||||||
'0.1.9',
|
'0.1.9',
|
||||||
|
'0.2.1',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $version;
|
protected $version;
|
||||||
|
@ -76,10 +77,15 @@ class UpdateCommand extends Command
|
||||||
case '0.1.8':
|
case '0.1.8':
|
||||||
$this->info('You are running an older version that doesn\'t require any updates!');
|
$this->info('You are running an older version that doesn\'t require any updates!');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '0.1.9':
|
case '0.1.9':
|
||||||
$this->update019();
|
$this->update019();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case '0.2.1':
|
||||||
|
$this->update021();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
# code...
|
# code...
|
||||||
break;
|
break;
|
||||||
|
@ -127,6 +133,34 @@ class UpdateCommand extends Command
|
||||||
$bar->finish();
|
$bar->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function update021()
|
||||||
|
{
|
||||||
|
$this->buildVersionFile();
|
||||||
|
$v = $this->getVersionFile();
|
||||||
|
if($v['updated'] == true) {
|
||||||
|
$this->info('Already up to date!');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusCount = Status::count();
|
||||||
|
$this->info('Running updates ...');
|
||||||
|
$bar = $this->output->createProgressBar($statusCount);
|
||||||
|
Status::has('media')->chunk(200, function($statuses) use ($bar) {
|
||||||
|
|
||||||
|
foreach($statuses as $status) {
|
||||||
|
if($status->firstMedia()) {
|
||||||
|
$media = $status->firstMedia();
|
||||||
|
if(in_array($media->mime, ['image/jpeg', 'image/png'])) {
|
||||||
|
ImageThumbnail::dispatch($media);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$bar->advance();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$this->updateVersionFile('0.2.1', true);
|
||||||
|
$bar->finish();
|
||||||
|
}
|
||||||
|
|
||||||
protected function buildVersionFile()
|
protected function buildVersionFile()
|
||||||
{
|
{
|
||||||
$path = storage_path('app/version.json');
|
$path = storage_path('app/version.json');
|
||||||
|
|
|
@ -20,7 +20,7 @@ use App\Jobs\AvatarPipeline\CreateAvatar;
|
||||||
use App\Jobs\RemoteFollowPipeline\RemoteFollowImportRecent;
|
use App\Jobs\RemoteFollowPipeline\RemoteFollowImportRecent;
|
||||||
use App\Jobs\ImageOptimizePipeline\{ImageOptimize,ImageThumbnail};
|
use App\Jobs\ImageOptimizePipeline\{ImageOptimize,ImageThumbnail};
|
||||||
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||||
use HttpSignatures\{GuzzleHttpSignatures, KeyStore, Context, Verifier};
|
use App\Util\HttpSignatures\{GuzzleHttpSignatures, KeyStore, Context, Verifier};
|
||||||
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
|
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
|
||||||
|
|
||||||
class Helpers {
|
class Helpers {
|
||||||
|
@ -309,31 +309,27 @@ class Helpers {
|
||||||
{
|
{
|
||||||
$profile = $senderProfile;
|
$profile = $senderProfile;
|
||||||
$keyId = $profile->keyId();
|
$keyId = $profile->keyId();
|
||||||
$privateKey = openssl_pkey_get_private($profile->private_key);
|
|
||||||
|
|
||||||
|
$date = new \DateTime('UTC');
|
||||||
$date = date('D, d M Y h:i:s').' GMT';
|
$date = $date->format('D, d M Y H:i:s \G\M\T');
|
||||||
$host = parse_url($url, PHP_URL_HOST);
|
$host = parse_url($url, PHP_URL_HOST);
|
||||||
|
$path = parse_url($url, PHP_URL_PATH);
|
||||||
$headers = [
|
$headers = [
|
||||||
'(request-target)' => 'post '.parse_url($url, PHP_URL_PATH),
|
'date' => $date,
|
||||||
'Date' => $date,
|
'host' => $host,
|
||||||
'Host' => $host,
|
'content-type' => 'application/activity+json',
|
||||||
'Content-Type' => 'application/activity+json',
|
|
||||||
];
|
];
|
||||||
if($body) {
|
|
||||||
$payload = is_string($body) ? $body : json_encode($body);
|
$context = new Context([
|
||||||
$digest = base64_encode(hash('sha256', $payload, true));
|
'keys' => [$profile->keyId() => $profile->private_key],
|
||||||
$headers['Digest'] = 'SHA-256=' . $digest;
|
'algorithm' => 'rsa-sha256',
|
||||||
}
|
'headers' => ['(request-target)', 'date', 'host', 'content-type'],
|
||||||
$stringToSign = self::_headersToSigningString($headers);
|
]);
|
||||||
$signedHeaders = implode(' ', array_map('strtolower', array_keys($headers)));
|
|
||||||
openssl_sign($stringToSign, $signature, $privateKey, OPENSSL_ALGO_SHA256);
|
$handlerStack = GuzzleHttpSignatures::defaultHandlerFromContext($context);
|
||||||
openssl_free_key($privateKey);
|
$client = new Client(['handler' => $handlerStack]);
|
||||||
$signature = base64_encode($signature);
|
|
||||||
$signatureHeader = 'keyId="'.$keyId.'",headers="'.$signedHeaders.'",algorithm="rsa-sha256",signature="'.$signature.'"';
|
$response = $client->request('POST', $url, ['headers' => $headers, 'json' => $body]);
|
||||||
unset($headers['(request-target)']);
|
|
||||||
$headers['Signature'] = $signatureHeader;
|
|
||||||
Zttp::withHeaders($headers)->post($url, $body);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue