Merge branch '2024.09-rc' into merge-2024.09-rc-into-develop

This commit is contained in:
Art4 2024-12-23 10:18:56 +00:00
commit 1b4d0d0bb0
34 changed files with 628 additions and 627 deletions

View file

@ -129,7 +129,17 @@ final class ATProtocol
}
$data = $this->get($pds . '/xrpc/' . $url, [HttpClientOptions::HEADERS => $headers]);
$this->pConfig->set($uid, 'bluesky', 'status', is_null($data) ? self::STATUS_API_FAIL : self::STATUS_SUCCESS);
if (empty($data) || (!empty($data->code) && ($data->code < 200 || $data->code >= 400))) {
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_API_FAIL);
if (!empty($data->message)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', $data->message);
} elseif (!empty($data->code)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', 'Error Code: ' . $data->code);
}
} elseif (!empty($data)) {
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_SUCCESS);
$this->pConfig->set($uid, 'bluesky', 'status-message', '');
}
return $data;
}
@ -156,6 +166,9 @@ final class ATProtocol
return null;
}
$data->code = $curlResult->getReturnCode();
} elseif (($curlResult->getReturnCode() < 200) || ($curlResult->getReturnCode() >= 400)) {
$this->logger->notice('Unexpected return code', ['url' => $url, 'code' => $curlResult->getReturnCode(), 'error' => $data ?: $curlResult->getBodyString()]);
$data->code = $curlResult->getReturnCode();
}
Item::incrementInbound(Protocol::BLUESKY);
@ -197,6 +210,7 @@ final class ATProtocol
} catch (\Exception $e) {
$this->logger->notice('Exception on post', ['exception' => $e]);
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_API_FAIL);
$this->pConfig->set($uid, 'bluesky', 'status-message', $e->getMessage());
return null;
}
@ -205,6 +219,11 @@ final class ATProtocol
$this->logger->notice('API Error', ['url' => $url, 'code' => $curlResult->getReturnCode(), 'error' => $data ?: $curlResult->getBodyString()]);
if (!$data) {
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_API_FAIL);
if (!empty($data->message)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', $data->message);
} elseif (!empty($data->code)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', 'Error Code: ' . $data->code);
}
return null;
}
$data->code = $curlResult->getReturnCode();
@ -212,8 +231,14 @@ final class ATProtocol
if (!empty($data->code) && ($data->code >= 200) && ($data->code < 400)) {
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_SUCCESS);
$this->pConfig->set($uid, 'bluesky', 'status-message', '');
} else {
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_API_FAIL);
if (!empty($data->message)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', $data->message);
} elseif (!empty($data->code)) {
$this->pConfig->set($uid, 'bluesky', 'status-message', 'Error Code: ' . $data->code);
}
}
return $data;
}
@ -501,10 +526,6 @@ final class ATProtocol
$data = $this->post($uid, '/xrpc/com.atproto.server.refreshSession', '', ['Authorization' => ['Bearer ' . $token]]);
if (empty($data) || empty($data->accessJwt)) {
$this->logger->debug('Refresh failed', ['return' => $data]);
$password = $this->pConfig->get($uid, 'bluesky', 'password');
if (!empty($password)) {
return $this->createUserToken($uid, $password);
}
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_TOKEN_FAIL);
return '';
}
@ -541,6 +562,7 @@ final class ATProtocol
$this->pConfig->set($uid, 'bluesky', 'refresh_token', $data->refreshJwt);
$this->pConfig->set($uid, 'bluesky', 'token_created', time());
$this->pConfig->set($uid, 'bluesky', 'status', self::STATUS_TOKEN_OK);
$this->pConfig->set($uid, 'bluesky', 'status-message', '');
return $data->accessJwt;
}
}

View file

@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
/**
* Copyright (C) 2010-2024, the Friendica project
* SPDX-FileCopyrightText: 2010-2024 the Friendica project

View file

@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
/**
* Copyright (C) 2010-2024, the Friendica project
* SPDX-FileCopyrightText: 2010-2024 the Friendica project

View file

@ -1,5 +1,5 @@
#!/usr/bin/env php
<?php
/**
* Copyright (C) 2010-2024, the Friendica project
* SPDX-FileCopyrightText: 2010-2024 the Friendica project
@ -178,7 +178,7 @@ class Processor
if ($id) {
$this->logger->info('Post inserted', ['id' => $id, 'guid' => $item['guid']]);
} elseif (Post::exists(['uid' => $uid, 'uri-id' => $item['uri-id']])) {
$this->logger->warning('Post was found', ['guid' => $item['guid'], 'uri' => $item['uri']]);
$this->logger->notice('Post was found', ['guid' => $item['guid'], 'uri' => $item['uri']]);
} else {
$this->logger->warning('Post was not inserted', ['guid' => $item['guid'], 'uri' => $item['uri']]);
}
@ -208,7 +208,7 @@ class Processor
if ($id) {
$this->logger->info('Repost inserted', ['id' => $id]);
} elseif (Post::exists(['uid' => $uid, 'uri-id' => $item['uri-id']])) {
$this->logger->warning('Repost was found', ['uri' => $item['uri']]);
$this->logger->notice('Repost was found', ['uri' => $item['uri']]);
} else {
$this->logger->warning('Repost was not inserted', ['uri' => $item['uri']]);
}
@ -237,7 +237,7 @@ class Processor
if ($id) {
$this->logger->info('Like inserted', ['id' => $id]);
} elseif (Post::exists(['uid' => $uid, 'uri-id' => $item['uri-id']])) {
$this->logger->warning('Like was found', ['uri' => $item['uri']]);
$this->logger->notice('Like was found', ['uri' => $item['uri']]);
} else {
$this->logger->warning('Like was not inserted', ['uri' => $item['uri']]);
}
@ -317,7 +317,7 @@ class Processor
if ($id) {
$this->logger->info('Fetched post inserted', ['id' => $id, 'guid' => $item['guid']]);
} elseif (Post::exists(['uid' => $uid, 'uri-id' => $item['uri-id']])) {
$this->logger->warning('Fetched post was found', ['guid' => $item['guid'], 'uri' => $item['uri']]);
$this->logger->notice('Fetched post was found', ['guid' => $item['guid'], 'uri' => $item['uri']]);
} else {
$this->logger->warning('Fetched post was not inserted', ['guid' => $item['guid'], 'uri' => $item['uri']]);
}

View file

@ -164,7 +164,7 @@ class Delivery
}
Logger::notice('Delivery failed', ['retcode' => $response->getReturnCode(), 'serverfailure' => $serverfail, 'drop' => $drop, 'runtime' => round($runtime, 3), 'uri-id' => $uri_id, 'uid' => $uid, 'item_id' => $item_id, 'cmd' => $cmd, 'inbox' => $inbox]);
Logger::notice('Delivery failed', ['retcode' => $response->getReturnCode() ?? 0, 'serverfailure' => $serverfail, 'drop' => $drop, 'runtime' => round($runtime, 3), 'uri-id' => $uri_id, 'uid' => $uid, 'item_id' => $item_id, 'cmd' => $cmd, 'inbox' => $inbox]);
}
if ($uri_id) {
if ($success) {