]> git.mxchange.org Git - friendica.git/blobdiff - mod/poco.php
Merge pull request #11575 from annando/issue-11469
[friendica.git] / mod / poco.php
index f084361dc4f731368cf6a66df2c498375eb42cf9..73179a33f203bab06ab49f6b893471c3117a7b16 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2020, Friendica
+ * @copyright Copyright (C) 2010-2022, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -25,9 +25,11 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
+use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\DI;
-use Friendica\Util\Strings;
+use Friendica\Module\Response;
+use Friendica\Util\DateTimeFormat;
 use Friendica\Util\XML;
 
 function poco_init(App $a) {
@@ -35,7 +37,7 @@ function poco_init(App $a) {
                throw new \Friendica\Network\HTTPException\ForbiddenException();
        }
 
-       if ($a->argc > 1) {
+       if (DI::args()->getArgc() > 1) {
                // Only the system mode is supported 
                throw new \Friendica\Network\HTTPException\NotFoundException();
        }
@@ -121,10 +123,12 @@ function poco_init(App $a) {
                        if (isset($contact['account-type'])) {
                                $contact['contact-type'] = $contact['account-type'];
                        }
-                       $about = DI::cache()->get("about:" . $contact['updated'] . ":" . $contact['nurl']);
+
+                       $cacheKey = 'about:' . $contact['nick'] . ':' . DateTimeFormat::utc($contact['updated'], DateTimeFormat::ATOM);
+                       $about = DI::cache()->get($cacheKey);
                        if (is_null($about)) {
-                               $about = BBCode::convert($contact['about'], false);
-                               DI::cache()->set("about:" . $contact['updated'] . ":" . $contact['nurl'], $about);
+                               $about = BBCode::convertForUriId($contact['uri-id'], $contact['about']);
+                               DI::cache()->set($cacheKey, $about);
                        }
 
                        // Non connected persons can only see the keywords of a Diaspora account
@@ -226,14 +230,10 @@ function poco_init(App $a) {
        Logger::info("End of poco");
 
        if ($format === 'xml') {
-               header('Content-type: text/xml');
-               echo Renderer::replaceMacros(Renderer::getMarkupTemplate('poco_xml.tpl'), XML::arrayEscape(['$response' => $ret]));
-               exit();
+               System::httpExit(Renderer::replaceMacros(Renderer::getMarkupTemplate('poco_xml.tpl'), XML::arrayEscape(['$response' => $ret])), Response::TYPE_XML);
        }
        if ($format === 'json') {
-               header('Content-type: application/json');
-               echo json_encode($ret);
-               exit();
+               System::jsonExit($ret);
        } else {
                throw new \Friendica\Network\HTTPException\InternalServerErrorException();
        }