$network = $data["network"];
// Canonicalize email-style profile locator
- $url = Probe::webfingerDfrn($data['url'], $hcard);
+ $url = Probe::webfingerDfrn($data['url'] ?? $url, $hcard);
if (substr($url, 0, 5) === 'stat:') {
// Every time we detect the remote subscription we define this as OStatus.
*
* @param array $fields Item-uri fields
*
- * @return integer item-uri id
+ * @return int|null item-uri id
* @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
$uri = substr($fields['uri'], 0, 255);
* @return string profile link
* @throws HTTPException\InternalServerErrorException
*/
- public static function webfingerDfrn($webbie, &$hcard_url)
+ public static function webfingerDfrn(string $webbie, string &$hcard_url)
{
$profile_link = '';
$item['guid'] = $activity['diaspora:guid'] ?: $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);
if (empty($item)) {
if (!empty($cid)) {
self::switchContact($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']),
'author-link' => $activity['actor']];
- $note = Strings::escapeTags(trim($activity['content'] ?? ''));
-
// Ensure that the contact has got the right network type
self::switchContact($item['author-id']);
- $result = Contact::addRelationship($owner, $contact, $item, false, $note);
+ $result = Contact::addRelationship($owner, [], $item, false, $activity['content'] ?? '');
if ($result === true) {
ActivityPub\Transmitter::sendContactAccept($item['author-link'], $activity['id'], $owner['uid']);
}
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
*
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @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)) {
Logger::info('Inbox is archived', ['cmd' => $cmd, 'inbox' => $inbox, 'id' => $target_id, 'uid' => $uid]);