Merge pull request #9655 from MrPetovan/bug/fatal-errors
Fix several occasional fatal errors
This commit is contained in:
commit
e4228c6218
|
@ -299,7 +299,7 @@ function dfrn_request_post(App $a)
|
||||||
$network = $data["network"];
|
$network = $data["network"];
|
||||||
|
|
||||||
// Canonicalize email-style profile locator
|
// Canonicalize email-style profile locator
|
||||||
$url = Probe::webfingerDfrn($data['url'], $hcard);
|
$url = Probe::webfingerDfrn($data['url'] ?? $url, $hcard);
|
||||||
|
|
||||||
if (substr($url, 0, 5) === 'stat:') {
|
if (substr($url, 0, 5) === 'stat:') {
|
||||||
// Every time we detect the remote subscription we define this as OStatus.
|
// Every time we detect the remote subscription we define this as OStatus.
|
||||||
|
|
|
@ -31,10 +31,10 @@ class ItemURI
|
||||||
*
|
*
|
||||||
* @param array $fields Item-uri fields
|
* @param array $fields Item-uri fields
|
||||||
*
|
*
|
||||||
* @return integer item-uri id
|
* @return int|null item-uri id
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function insert($fields)
|
public static function insert(array $fields)
|
||||||
{
|
{
|
||||||
// If the URI gets too long we only take the first parts and hope for best
|
// If the URI gets too long we only take the first parts and hope for best
|
||||||
$uri = substr($fields['uri'], 0, 255);
|
$uri = substr($fields['uri'], 0, 255);
|
||||||
|
|
|
@ -258,7 +258,7 @@ class Probe
|
||||||
* @return string profile link
|
* @return string profile link
|
||||||
* @throws HTTPException\InternalServerErrorException
|
* @throws HTTPException\InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public static function webfingerDfrn($webbie, &$hcard_url)
|
public static function webfingerDfrn(string $webbie, string &$hcard_url)
|
||||||
{
|
{
|
||||||
$profile_link = '';
|
$profile_link = '';
|
||||||
|
|
||||||
|
|
|
@ -327,6 +327,10 @@ class Processor
|
||||||
$item['guid'] = $activity['diaspora:guid'] ?: $guid;
|
$item['guid'] = $activity['diaspora:guid'] ?: $guid;
|
||||||
|
|
||||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||||
|
if (empty($item['uri-id'])) {
|
||||||
|
Logger::warning('Unable to get a uri-id for an item uri', ['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$item = self::processContent($activity, $item);
|
$item = self::processContent($activity, $item);
|
||||||
if (empty($item)) {
|
if (empty($item)) {
|
||||||
|
@ -903,20 +907,15 @@ class Processor
|
||||||
if (!empty($cid)) {
|
if (!empty($cid)) {
|
||||||
self::switchContact($cid);
|
self::switchContact($cid);
|
||||||
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
DBA::update('contact', ['hub-verify' => $activity['id'], 'protocol' => Protocol::ACTIVITYPUB], ['id' => $cid]);
|
||||||
$contact = DBA::selectFirst('contact', [], ['id' => $cid, 'network' => Protocol::NATIVE_SUPPORT]);
|
|
||||||
} else {
|
|
||||||
$contact = [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
|
$item = ['author-id' => Contact::getIdForURL($activity['actor']),
|
||||||
'author-link' => $activity['actor']];
|
'author-link' => $activity['actor']];
|
||||||
|
|
||||||
$note = Strings::escapeTags(trim($activity['content'] ?? ''));
|
|
||||||
|
|
||||||
// Ensure that the contact has got the right network type
|
// Ensure that the contact has got the right network type
|
||||||
self::switchContact($item['author-id']);
|
self::switchContact($item['author-id']);
|
||||||
|
|
||||||
$result = Contact::addRelationship($owner, $contact, $item, false, $note);
|
$result = Contact::addRelationship($owner, [], $item, false, $activity['content'] ?? '');
|
||||||
if ($result === true) {
|
if ($result === true) {
|
||||||
ActivityPub\Transmitter::sendContactAccept($item['author-link'], $activity['id'], $owner['uid']);
|
ActivityPub\Transmitter::sendContactAccept($item['author-link'], $activity['id'], $owner['uid']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,28 @@ use Friendica\Util\HTTPSignature;
|
||||||
|
|
||||||
class APDelivery
|
class APDelivery
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Delivers ActivityPub messages
|
||||||
|
*
|
||||||
|
* @param string $cmd
|
||||||
|
* @param integer $target_id
|
||||||
|
* @param string|array $inboxes
|
||||||
|
* @param integer $uid
|
||||||
|
* @param array $receivers
|
||||||
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
|
*/
|
||||||
|
public static function execute(string $cmd, int $target_id, $inboxes, int $uid, array $receivers = [])
|
||||||
|
{
|
||||||
|
if (is_string($inboxes)) {
|
||||||
|
$inboxes = [$inboxes];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($inboxes as $inbox) {
|
||||||
|
self::perform($cmd, $target_id, $inbox, $uid, $receivers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delivers ActivityPub messages
|
* Delivers ActivityPub messages
|
||||||
*
|
*
|
||||||
|
@ -42,7 +64,7 @@ class APDelivery
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
public static function execute($cmd, $target_id, $inbox, $uid, $receivers = [])
|
private static function perform(string $cmd, int $target_id, string $inbox, int $uid, array $receivers = [])
|
||||||
{
|
{
|
||||||
if (ActivityPub\Transmitter::archivedInbox($inbox)) {
|
if (ActivityPub\Transmitter::archivedInbox($inbox)) {
|
||||||
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $target_id, 'uid' => $uid]);
|
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $target_id, 'uid' => $uid]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user