mirror of
https://github.com/friendica/friendica
synced 2026-04-19 18:27:21 +02:00
Merge pull request #15632 from annando/at-proto-cleanup
Last constant removed in atproto / removed deprecated constants
This commit is contained in:
commit
dd238ae260
7 changed files with 48 additions and 33 deletions
|
|
@ -50,8 +50,6 @@ class BBCode
|
|||
public const BACKLINK = 8;
|
||||
public const ACTIVITYPUB = 9;
|
||||
public const ATPROTOCOL = 10;
|
||||
/** @deprecated use @see ATPROTOCOL instead */
|
||||
public const BLUESKY = 10; // @deprecated
|
||||
|
||||
public const SHARED_ANCHOR = '<hr class="shared-anchor">';
|
||||
public const TOP_ANCHOR = '<br class="top-anchor">';
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ class Protocol
|
|||
public const SUPPORT_PRIVATE = [self::DFRN, self::DIASPORA, self::MAIL, self::ACTIVITYPUB, self::PUMPIO];
|
||||
|
||||
// Supported through a connector
|
||||
/** @deprecated use @see ATPROTO instead */
|
||||
public const BLUESKY = 'bsky'; // @deprecated name for the AT Protocol
|
||||
public const ATPROTO = 'bsky'; // AT Protocol, short name "atproto" (Formerly known as Bluesky)
|
||||
public const DIASPORA2 = 'dspc'; // Diaspora connector
|
||||
public const DISCOURSE = 'dscs'; // Discourse
|
||||
|
|
|
|||
|
|
@ -3602,12 +3602,7 @@ class Contact
|
|||
public static function getProfileLink(array $contact): string
|
||||
{
|
||||
if ($contact['network'] === Protocol::ATPROTO) {
|
||||
$web = DI::atProtocol()->getWebForUser(DI::userSession()->getLocalUserId());
|
||||
$frontends = DI::config()->get('atprotocol', 'frontends');
|
||||
if ($web && is_array($frontends) && isset($frontends[$web])) {
|
||||
return str_replace('{did}', $contact['url'], $frontends[$web][1]);
|
||||
}
|
||||
return $contact['alias'];
|
||||
return DI::atpActor()->getProfileLink($contact['url'], DI::userSession()->getLocalUserId()) ?: $contact['alias'];
|
||||
}
|
||||
if (!empty($contact['alias']) && Network::isValidHttpUrl($contact['alias']) && (($contact['network'] ?? '') != Protocol::DFRN)) {
|
||||
return $contact['alias'];
|
||||
|
|
|
|||
|
|
@ -3667,19 +3667,7 @@ class Item
|
|||
public static function getPlink(array $item)
|
||||
{
|
||||
if ($item['network'] === Protocol::ATPROTO) {
|
||||
$web = DI::atProtocol()->getWebForUser(DI::userSession()->getLocalUserId());
|
||||
$plink = $item['plink'];
|
||||
$frontends = DI::config()->get('atprotocol', 'frontends');
|
||||
if ($web && is_array($frontends) && isset($frontends[$web])) {
|
||||
$parts = explode('/', $item['uri']);
|
||||
if (count($parts) === 5) {
|
||||
$did = $parts[2];
|
||||
$collection = $parts[3];
|
||||
$rkeyparts = explode(':', $parts[4]);
|
||||
$rkey = $rkeyparts[0];
|
||||
$plink = str_replace(['{did}', '{collection}', '{rkey}'], [$did, $collection, $rkey], $frontends[$web][2]);
|
||||
}
|
||||
}
|
||||
$plink = DI::atProtocol()->getPostLink($item['uri'], DI::userSession()->getLocalUserId()) ?: $item['plink'];
|
||||
} elseif (!empty($item['plink']) && Network::isValidHttpUrl($item['plink'])) {
|
||||
$plink = $item['plink'];
|
||||
} elseif (!empty($item['uri']) && Network::isValidHttpUrl($item['uri']) && !DI::baseUrl()->isLocalUrl($item['uri'])) {
|
||||
|
|
|
|||
|
|
@ -35,12 +35,6 @@ final class ATProtocol
|
|||
public const STATUS_PDS_FAIL = 12;
|
||||
public const STATUS_TOKEN_FAIL = 13;
|
||||
|
||||
/**
|
||||
* Path to the web interface with the user profile and posts.
|
||||
* This string can then be replaced when displaying the post and profile url.
|
||||
*/
|
||||
public const WEB = 'https://bsky.app';
|
||||
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
|
||||
|
|
@ -594,4 +588,28 @@ final class ATProtocol
|
|||
$this->pConfig->set($uid, 'bluesky', 'status-message', '');
|
||||
return $data->accessJwt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the profile link for a given DID and user id
|
||||
*
|
||||
* @param string $did The contact DID
|
||||
* @param integer $uid User id to get the web for (0 for global)
|
||||
* @return string Profile link
|
||||
*/
|
||||
public function getPostLink(string $did, int $uid = 0): string
|
||||
{
|
||||
$web = $this->getWebForUser($uid);
|
||||
$frontends = $this->config->get('atprotocol', 'frontends');
|
||||
if ($web && is_array($frontends) && isset($frontends[$web])) {
|
||||
$parts = explode('/', $did);
|
||||
if (count($parts) === 5) {
|
||||
$did = $parts[2];
|
||||
$collection = $parts[3];
|
||||
$rkeyparts = explode(':', $parts[4]);
|
||||
$rkey = $rkeyparts[0];
|
||||
return str_replace(['{did}', '{collection}', '{rkey}'], [$did, $collection, $rkey], $frontends[$web][2]);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
namespace Friendica\Protocol\ATProtocol;
|
||||
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Config\Capability\IManageConfigValues;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\GServer;
|
||||
|
|
@ -29,10 +30,14 @@ class Actor
|
|||
/** @var ATProtocol */
|
||||
private $atprotocol;
|
||||
|
||||
public function __construct(LoggerInterface $logger, ATProtocol $atprotocol)
|
||||
/** @var \Friendica\Core\Config\Capability\IManageConfigValues */
|
||||
private $config;
|
||||
|
||||
public function __construct(LoggerInterface $logger, ATProtocol $atprotocol, IManageConfigValues $config)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
$this->atprotocol = $atprotocol;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,8 +230,20 @@ class Actor
|
|||
return Contact::getById($cid);
|
||||
}
|
||||
|
||||
public function getProfileLink(string $did): string
|
||||
/**
|
||||
* Get the profile link for a given DID and user id
|
||||
*
|
||||
* @param string $did The contact DID
|
||||
* @param integer $uid User id to get the web for (0 for global)
|
||||
* @return string Profile link
|
||||
*/
|
||||
public function getProfileLink(string $did, int $uid = 0): string
|
||||
{
|
||||
return ATProtocol::WEB . '/profile/' . $did;
|
||||
$web = $this->atprotocol->getWebForUser($uid);
|
||||
$frontends = $this->config->get('atprotocol', 'frontends');
|
||||
if ($web && is_array($frontends) && isset($frontends[$web])) {
|
||||
return str_replace('{did}', $did, $frontends[$web][1]);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,10 +355,11 @@ class Processor
|
|||
'owner-name' => $contact['name'],
|
||||
'owner-link' => $contact['url'],
|
||||
'owner-avatar' => $contact['avatar'],
|
||||
'plink' => $contact['alias'] . '/post/' . $data->commit->rkey,
|
||||
'source' => json_encode($data),
|
||||
];
|
||||
|
||||
$item['plink'] = $this->atprotocol->getPostLink($item['uri']);
|
||||
|
||||
if ((time() - strtotime($item['created'])) > 600) {
|
||||
$item['received'] = $item['created'];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue