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