$author["contact-id"] = $contact["id"];
- $contact = null;
+ $contact = [];
/*
This here would be better, but we would get problems with contacts from the statusnet addon
GContact::link($gcid, $contact["uid"], $contact["id"]);
} elseif ($contact["network"] != Protocol::DFRN) {
- $contact = null;
+ $contact = [];
}
return $author;
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
- self::entryHeader($doc, $entry, $owner, $item, $toplevel);
+ $entry = self::entryHeader($doc, $owner, $item, $toplevel);
$condition = ['uid' => $owner["uid"], 'guid' => $repeated_guid, 'private' => false,
'network' => [Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]];
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
- self::entryHeader($doc, $entry, $owner, $item, $toplevel);
+ $entry = self::entryHeader($doc, $owner, $item, $toplevel);
$verb = NAMESPACE_ACTIVITY_SCHEMA."favorite";
self::entryContent($doc, $entry, $item, $owner, "Favorite", $verb, false);
$item["body"] = sprintf($message, $owner["nick"], $contact["nick"]);
- self::entryHeader($doc, $entry, $owner, $item, $toplevel);
+ $entry = self::entryHeader($doc, $owner, $item, $toplevel);
self::entryContent($doc, $entry, $item, $owner, $title);
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
}
- $title = self::entryHeader($doc, $entry, $owner, $item, $toplevel);
+ if (!$toplevel) {
+ if (!empty($item['title'])) {
+ $title = BBCode::convert($item['title'], false, 7);
+ } else {
+ $title = sprintf("New note by %s", $owner["nick"]);
+ }
+ } else {
+ $title = sprintf("New comment by %s", $owner["nick"]);
+ }
+
+ $entry = self::entryHeader($doc, $owner, $item, $toplevel);
XML::addElement($doc, $entry, "activity:object-type", ACTIVITY_OBJ_NOTE);
* @brief Adds a header element to the XML document
*
* @param DOMDocument $doc XML document
- * @param object $entry The entry element where the elements are added
* @param array $owner Contact data of the poster
* @param array $item
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
- * @return string The title for the element
+ * @return \DOMElement The entry element where the elements are added
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- private static function entryHeader(DOMDocument $doc, &$entry, array $owner, array $item, $toplevel)
+ private static function entryHeader(DOMDocument $doc, array $owner, array $item, $toplevel)
{
- /// @todo Check if this title stuff is really needed (I guess not)
if (!$toplevel) {
$entry = $doc->createElement("entry");
- if (!empty($item['title'])) {
- $title = BBCode::convert($item['title'], false, 7);
- } else {
- $title = sprintf("New note by %s", $owner["nick"]);
- }
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
$contact = self::contactEntry($item['author-link'], $owner);
$author = self::addAuthor($doc, $owner);
$entry->appendChild($author);
-
- $title = sprintf("New comment by %s", $owner["nick"]);
}
- return $title;
+
+ return $entry;
}
/**
{
$inboxes = [];
+ $uid = $target_item['contact-uid'] ?: $target_item['uid'];
+
if ($target_item['origin']) {
- $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $target_item['contact-uid']);
+ $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($target_item, $uid);
Logger::log('Origin item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG);
} elseif (!DBA::exists('conversation', ['item-uri' => $target_item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB])) {
Logger::log('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' is no AP post. It will not be distributed.', Logger::DEBUG);
} elseif ($parent['origin']) {
// Remote items are transmitted via the personal inboxes.
// Doing so ensures that the dedicated receiver will get the message.
- $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $target_item['contact-uid'], true, $target_item['id']);
+ $inboxes = ActivityPub\Transmitter::fetchTargetInboxes($parent, $uid, true, $target_item['id']);
Logger::log('Remote item ' . $target_item['id'] . ' with URL ' . $target_item['uri'] . ' will be distributed.', Logger::DEBUG);
}
Logger::log('Deliver ' . $target_item['id'] .' to ' . $inbox .' via ActivityPub', Logger::DEBUG);
Worker::add(['priority' => $priority, 'created' => $created, 'dont_fork' => true],
- 'APDelivery', $cmd, $target_item['id'], $inbox, $target_item['contact-uid']);
+ 'APDelivery', $cmd, $target_item['id'], $inbox, $uid);
}
return count($inboxes);