Bluesky: Handle problems when uploading pictures
This commit is contained in:
parent
4437f79380
commit
34f87b2cb8
1 changed files with 8 additions and 3 deletions
|
@ -888,10 +888,15 @@ function bluesky_upload_blob(int $uid, array $photo): ?stdClass
|
|||
$picture = Photo::resizeToFileSize($picture, BLUESKY_IMAGE_SIZE[$retrial]);
|
||||
$new_height = $picture->getHeight();
|
||||
$new_width = $picture->getWidth();
|
||||
$content = $picture->asString();
|
||||
$content = (string)$picture->asString();
|
||||
$new_size = strlen($content);
|
||||
|
||||
Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
if (($size != 0) && ($new_size == 0) && ($retrial == 0)) {
|
||||
Logger::warning('Size is empty after resize, uploading original file', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
$content = Photo::getImageForPhoto($photo);
|
||||
} else {
|
||||
Logger::info('Uploading', ['uid' => $uid, 'retrial' => $retrial, 'height' => $new_height, 'width' => $new_width, 'size' => $new_size, 'orig-height' => $height, 'orig-width' => $width, 'orig-size' => $size]);
|
||||
}
|
||||
|
||||
$data = DI::atProtocol()->post($uid, '/xrpc/com.atproto.repo.uploadBlob', $content, ['Content-type' => $photo['type'], 'Authorization' => ['Bearer ' . DI::atProtocol()->getUserToken($uid)]]);
|
||||
if (empty($data) || empty($data->blob)) {
|
||||
|
@ -955,7 +960,7 @@ function bluesky_complete_post(stdClass $post, int $uid, int $post_reason, int $
|
|||
}
|
||||
|
||||
if ($complete) {
|
||||
$uri = DI::atpProcessor()->fetchMissingPost(DI::atpProcessor()->getUri($post), $uid, $post_reason, $causer, 0, '', true);
|
||||
$uri = DI::atpProcessor()->fetchMissingPost(DI::atpProcessor()->getUri($post), $uid, $post_reason, $causer, 0, '', true, $protocol);
|
||||
$uri_id = DI::atpProcessor()->fetchUriId($uri, $uid);
|
||||
} else {
|
||||
$uri_id = DI::atpProcessor()->processPost($post, $uid, $post_reason, $causer, 0, $protocol);
|
||||
|
|
Loading…
Reference in a new issue