commit
09bb0dff42
|
@ -1271,6 +1271,7 @@ class OStatus
|
|||
$root = $doc->createElementNS(ActivityNamespace::ATOM1, 'feed');
|
||||
$doc->appendChild($root);
|
||||
|
||||
if (!$feed_mode) {
|
||||
$root->setAttribute("xmlns:thr", ActivityNamespace::THREAD);
|
||||
$root->setAttribute("xmlns:georss", ActivityNamespace::GEORSS);
|
||||
$root->setAttribute("xmlns:activity", ActivityNamespace::ACTIVITY);
|
||||
|
@ -1279,6 +1280,7 @@ class OStatus
|
|||
$root->setAttribute("xmlns:ostatus", ActivityNamespace::OSTATUS);
|
||||
$root->setAttribute("xmlns:statusnet", ActivityNamespace::STATUSNET);
|
||||
$root->setAttribute("xmlns:mastodon", ActivityNamespace::MASTODON);
|
||||
}
|
||||
|
||||
$title = '';
|
||||
$selfUri = '/feed/' . $owner["nick"] . '/';
|
||||
|
@ -1308,7 +1310,7 @@ class OStatus
|
|||
XML::addElement($doc, $root, "logo", $owner["photo"]);
|
||||
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));
|
||||
|
||||
$author = self::addAuthor($doc, $owner);
|
||||
$author = self::addAuthor($doc, $owner, true, $feed_mode);
|
||||
$root->appendChild($author);
|
||||
|
||||
$attributes = ["href" => $owner["url"], "rel" => "alternate", "type" => "text/html"];
|
||||
|
@ -1322,6 +1324,7 @@ class OStatus
|
|||
|
||||
self::hublinks($doc, $root, $owner["nick"]);
|
||||
|
||||
if (!$feed_mode) {
|
||||
$attributes = ["href" => DI::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "salmon"];
|
||||
XML::addElement($doc, $root, "link", "", $attributes);
|
||||
|
||||
|
@ -1330,6 +1333,7 @@ class OStatus
|
|||
|
||||
$attributes = ["href" => DI::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
|
||||
XML::addElement($doc, $root, "link", "", $attributes);
|
||||
}
|
||||
|
||||
$attributes = ["href" => DI::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
|
||||
XML::addElement($doc, $root, "link", "", $attributes);
|
||||
|
@ -1389,7 +1393,7 @@ class OStatus
|
|||
$attributes = ["rel" => "enclosure",
|
||||
"href" => $siteinfo["url"],
|
||||
"type" => "text/html; charset=UTF-8",
|
||||
"length" => "",
|
||||
"length" => "0",
|
||||
"title" => ($siteinfo["title"] ?? '') ?: $siteinfo["url"],
|
||||
];
|
||||
XML::addElement($doc, $root, "link", "", $attributes);
|
||||
|
@ -1438,27 +1442,31 @@ class OStatus
|
|||
* @param DOMDocument $doc XML document
|
||||
* @param array $owner Contact data of the poster
|
||||
* @param bool $show_profile Whether to show profile
|
||||
* @param bool $feed_mode Behave like a regular feed for users if true
|
||||
*
|
||||
* @return \DOMElement author element
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true)
|
||||
private static function addAuthor(DOMDocument $doc, array $owner, $show_profile = true, $feed_mode = false)
|
||||
{
|
||||
$profile = DBA::selectFirst('profile', ['homepage', 'publish'], ['uid' => $owner['uid']]);
|
||||
$author = $doc->createElement("author");
|
||||
if (!$feed_mode) {
|
||||
XML::addElement($doc, $author, "id", $owner["url"]);
|
||||
if ($owner['account-type'] == User::ACCOUNT_TYPE_COMMUNITY) {
|
||||
XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::GROUP);
|
||||
} else {
|
||||
XML::addElement($doc, $author, "activity:object-type", Activity\ObjectType::PERSON);
|
||||
}
|
||||
}
|
||||
XML::addElement($doc, $author, "uri", $owner["url"]);
|
||||
XML::addElement($doc, $author, "name", $owner["nick"]);
|
||||
XML::addElement($doc, $author, "email", $owner["addr"]);
|
||||
if ($show_profile) {
|
||||
if ($show_profile && !$feed_mode) {
|
||||
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
|
||||
}
|
||||
|
||||
if (!$feed_mode) {
|
||||
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
|
||||
XML::addElement($doc, $author, "link", "", $attributes);
|
||||
|
||||
|
@ -1508,6 +1516,7 @@ class OStatus
|
|||
XML::addElement($doc, $author, "mastodon:scope", "public");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $author;
|
||||
}
|
||||
|
@ -1569,7 +1578,7 @@ class OStatus
|
|||
|
||||
$repeated_guid = self::getResharedGuid($item);
|
||||
if ($repeated_guid != "") {
|
||||
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel);
|
||||
$xml = self::reshareEntry($doc, $item, $owner, $repeated_guid, $toplevel, $feed_mode);
|
||||
}
|
||||
|
||||
if ($xml) {
|
||||
|
@ -1668,12 +1677,13 @@ class OStatus
|
|||
* @param array $owner Contact data of the poster
|
||||
* @param string $repeated_guid guid
|
||||
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
|
||||
* @param bool $feed_mode Behave like a regular feed for users if true
|
||||
*
|
||||
* @return bool Entry element
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @throws \ImagickException
|
||||
*/
|
||||
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel)
|
||||
private static function reshareEntry(DOMDocument $doc, array $item, array $owner, $repeated_guid, $toplevel, $feed_mode = false)
|
||||
{
|
||||
if (($item['gravity'] != GRAVITY_PARENT) && (Strings::normaliseLink($item["author-link"]) != Strings::normaliseLink($owner["url"]))) {
|
||||
Logger::log("OStatus entry is from author ".$owner["url"]." - not from ".$item["author-link"].". Quitting.", Logger::DEBUG);
|
||||
|
@ -1692,8 +1702,9 @@ class OStatus
|
|||
|
||||
$title = $owner["nick"]." repeated a notice by ".$contact["nick"];
|
||||
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, Activity::SHARE, false);
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, Activity::SHARE, false, $feed_mode);
|
||||
|
||||
if (!$feed_mode) {
|
||||
$as_object = $doc->createElement("activity:object");
|
||||
|
||||
XML::addElement($doc, $as_object, "activity:object-type", ActivityNamespace::ACTIVITY_SCHEMA . "activity");
|
||||
|
@ -1720,8 +1731,9 @@ class OStatus
|
|||
$as_object->appendChild($source);
|
||||
|
||||
$entry->appendChild($as_object);
|
||||
}
|
||||
|
||||
self::entryFooter($doc, $entry, $item, $owner);
|
||||
self::entryFooter($doc, $entry, $item, $owner, true, $feed_mode);
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
@ -1906,7 +1918,9 @@ class OStatus
|
|||
|
||||
$entry = self::entryHeader($doc, $owner, $item, $toplevel);
|
||||
|
||||
if (!$feed_mode) {
|
||||
XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::NOTE);
|
||||
}
|
||||
|
||||
self::entryContent($doc, $entry, $item, $owner, $title, '', true, $feed_mode);
|
||||
|
||||
|
@ -2063,6 +2077,7 @@ class OStatus
|
|||
}
|
||||
}
|
||||
|
||||
if (!$feed_mode) {
|
||||
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:conversation", "href" => $conversation_href]);
|
||||
|
||||
$attributes = [
|
||||
|
@ -2072,6 +2087,7 @@ class OStatus
|
|||
|
||||
XML::addElement($doc, $entry, "ostatus:conversation", $conversation_uri, $attributes);
|
||||
}
|
||||
}
|
||||
|
||||
// uri-id isn't present for follow entry pseudo-items
|
||||
$tags = Tag::getByURIId($item['uri-id'] ?? 0);
|
||||
|
@ -2079,6 +2095,7 @@ class OStatus
|
|||
$mentioned[$tag['url']] = $tag['url'];
|
||||
}
|
||||
|
||||
if (!$feed_mode) {
|
||||
// Make sure that mentions are accepted (GNU Social has problems with mixing HTTP and HTTPS)
|
||||
$newmentions = [];
|
||||
foreach ($mentioned as $mention) {
|
||||
|
@ -2114,7 +2131,7 @@ class OStatus
|
|||
]);
|
||||
}
|
||||
|
||||
if (($item['private'] != Item::PRIVATE) && !$feed_mode) {
|
||||
if ($item['private'] != Item::PRIVATE) {
|
||||
XML::addElement($doc, $entry, "link", "", ["rel" => "ostatus:attention",
|
||||
"href" => "http://activityschema.org/collection/public"]);
|
||||
XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
|
||||
|
@ -2122,6 +2139,7 @@ class OStatus
|
|||
"href" => "http://activityschema.org/collection/public"]);
|
||||
XML::addElement($doc, $entry, "mastodon:scope", "public");
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if ($tag['type'] == Tag::HASHTAG) {
|
||||
|
@ -2131,7 +2149,7 @@ class OStatus
|
|||
|
||||
self::getAttachment($doc, $entry, $item);
|
||||
|
||||
if ($complete && ($item["id"] > 0)) {
|
||||
if (!$feed_mode && $complete && ($item["id"] > 0)) {
|
||||
$app = $item["app"];
|
||||
if ($app == "") {
|
||||
$app = "web";
|
||||
|
@ -2238,6 +2256,10 @@ class OStatus
|
|||
$item['body'] .= '🍼';
|
||||
}
|
||||
|
||||
if (in_array($item["verb"], [Activity::FOLLOW, Activity::O_UNFOLLOW, Activity::LIKE])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = self::entry($doc, $item, $owner, false, $feed_mode);
|
||||
$root->appendChild($entry);
|
||||
|
||||
|
|
Loading…
Reference in a new issue