]> git.mxchange.org Git - friendica.git/blob - src/Module/Feed.php
Merge pull request #7044 from MrPetovan/task/router
[friendica.git] / src / Module / Feed.php
1 <?php
2
3 namespace Friendica\Module;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\System;
7 use Friendica\Protocol\OStatus;
8
9 /**
10  * Provides public Atom feeds
11  *
12  * Currently supported:
13  * - /feed/[nickname]/ => posts
14  * - /feed/[nickname]/posts => posts
15  * - /feed/[nickname]/comments => comments
16  * - /feed/[nickname]/replies => comments
17  * - /feed/[nickname]/activity => activity
18  *
19  * The nocache GET parameter is provided mainly for debug purposes, requires auth
20  *
21  * @brief Provides public Atom feeds
22  *
23  * @author Hypolite Petovan <hypolite@mrpetovan.com>
24  */
25 class Feed extends BaseModule
26 {
27         public static function content()
28         {
29                 $a = self::getApp();
30
31                 $last_update = defaults($_GET, 'last_update', '');
32                 $nocache     = !empty($_GET['nocache']) && local_user();
33
34                 // @TODO: Replace with parameter from router
35                 if ($a->argc < 2) {
36                         System::httpExit(400);
37                 }
38
39                 $type = null;
40                 // @TODO: Replace with parameter from router
41                 if ($a->argc > 2) {
42                         $type = $a->argv[2];
43                 }
44
45                 switch ($type) {
46                         case 'posts':
47                         case 'comments':
48                         case 'activity':
49                                 // Correct type names, no change needed
50                                 break;
51                         case 'replies':
52                                 $type = 'comments';
53                                 break;
54                         default:
55                                 $type = 'posts';
56                 }
57
58                 // @TODO: Replace with parameter from router
59                 $nickname = $a->argv[1];
60                 header("Content-type: application/atom+xml; charset=utf-8");
61                 echo OStatus::feed($nickname, $last_update, 10, $type, $nocache, true);
62                 exit();
63         }
64 }