Merge pull request #6144 from Alkarex/ATOM-self
Correct self attribute in ATOM feeds
This commit is contained in:
commit
9dfc970bd6
1 changed files with 20 additions and 7 deletions
|
@ -1263,10 +1263,11 @@ class OStatus
|
||||||
* @param object $doc XML document
|
* @param object $doc XML document
|
||||||
* @param array $owner Contact data of the poster
|
* @param array $owner Contact data of the poster
|
||||||
* @param string $filter The related feed filter (activity, posts or comments)
|
* @param string $filter The related feed filter (activity, posts or comments)
|
||||||
|
* @param bool $feed_mode Behave like a regular feed for users if true
|
||||||
*
|
*
|
||||||
* @return object header root element
|
* @return object header root element
|
||||||
*/
|
*/
|
||||||
private static function addHeader(DOMDocument $doc, array $owner, $filter)
|
private static function addHeader(DOMDocument $doc, array $owner, $filter, $feed_mode = false)
|
||||||
{
|
{
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
|
@ -1283,10 +1284,23 @@ class OStatus
|
||||||
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
$root->setAttribute("xmlns:mastodon", NAMESPACE_MASTODON);
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
|
$selfUri = '/feed/' . $owner["nick"] . '/';
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case 'activity': $title = L10n::t('%s\'s timeline', $owner['name']); break;
|
case 'activity':
|
||||||
case 'posts' : $title = L10n::t('%s\'s posts' , $owner['name']); break;
|
$title = L10n::t('%s\'s timeline', $owner['name']);
|
||||||
case 'comments': $title = L10n::t('%s\'s comments', $owner['name']); break;
|
$selfUri .= $filter;
|
||||||
|
break;
|
||||||
|
case 'posts':
|
||||||
|
$title = L10n::t('%s\'s posts', $owner['name']);
|
||||||
|
break;
|
||||||
|
case 'comments':
|
||||||
|
$title = L10n::t('%s\'s comments', $owner['name']);
|
||||||
|
$selfUri .= $filter;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$feed_mode) {
|
||||||
|
$selfUri = "/dfrn_poll/" . $owner["nick"];
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION];
|
$attributes = ["uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION . "-" . DB_UPDATE_VERSION];
|
||||||
|
@ -1320,8 +1334,7 @@ class OStatus
|
||||||
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
|
$attributes = ["href" => System::baseUrl() . "/salmon/" . $owner["nick"], "rel" => "http://salmon-protocol.org/ns/salmon-mention"];
|
||||||
XML::addElement($doc, $root, "link", "", $attributes);
|
XML::addElement($doc, $root, "link", "", $attributes);
|
||||||
|
|
||||||
$attributes = ["href" => System::baseUrl() . "/dfrn_poll/" . $owner["nick"],
|
$attributes = ["href" => System::baseUrl() . $selfUri, "rel" => "self", "type" => "application/atom+xml"];
|
||||||
"rel" => "self", "type" => "application/atom+xml"];
|
|
||||||
XML::addElement($doc, $root, "link", "", $attributes);
|
XML::addElement($doc, $root, "link", "", $attributes);
|
||||||
|
|
||||||
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
|
if ($owner['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
|
||||||
|
@ -2206,7 +2219,7 @@ class OStatus
|
||||||
$doc = new DOMDocument('1.0', 'utf-8');
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
$doc->formatOutput = true;
|
$doc->formatOutput = true;
|
||||||
|
|
||||||
$root = self::addHeader($doc, $owner, $filter);
|
$root = self::addHeader($doc, $owner, $filter, $feed_mode);
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if (Config::get('system', 'ostatus_debug')) {
|
if (Config::get('system', 'ostatus_debug')) {
|
||||||
|
|
Loading…
Reference in a new issue