1 | <?php |
||
29 | class Api { |
||
30 | const DEFAULT_LIMIT = 30; |
||
31 | |||
32 | 5 | public static function get() { |
|
33 | 5 | $app = new AppInfo\Application(); |
|
34 | /** @var Data $data */ |
||
35 | 5 | $data = $app->getContainer()->query('ActivityData'); |
|
36 | |||
37 | 5 | $start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
38 | 5 | $count = isset($_GET['count']) ? (int) $_GET['count'] : self::DEFAULT_LIMIT; |
|
39 | 5 | $user = $app->getContainer()->getServer()->getUserSession()->getUser()->getUID(); |
|
40 | |||
41 | 5 | if ($start !== 0) { |
|
42 | 2 | $start = self::getSinceFromOffset($user, $start); |
|
43 | } |
||
44 | |||
45 | 5 | $activities = $data->get( |
|
46 | 5 | $app->getContainer()->query('GroupHelper'), |
|
47 | 5 | $app->getContainer()->query('UserSettings'), |
|
48 | 5 | $user, $start, $count, 'desc', 'all' |
|
49 | ); |
||
50 | 5 | $parser = new PlainTextParser(\OC::$server->getL10NFactory()->get('activity')); |
|
51 | |||
52 | 5 | $entries = []; |
|
53 | 5 | foreach ($activities['data'] as $entry) { |
|
54 | 4 | $entries[] = [ |
|
55 | 4 | 'id' => $entry['activity_id'], |
|
56 | 4 | 'subject' => $parser->parseMessage($entry['subject_prepared']), |
|
57 | 4 | 'message' => $parser->parseMessage($entry['message_prepared']), |
|
58 | 4 | 'file' => $entry['object_name'], |
|
59 | 4 | 'link' => $entry['link'], |
|
60 | 4 | 'date' => \date('c', $entry['timestamp']), |
|
61 | ]; |
||
62 | } |
||
63 | |||
64 | 5 | return new \OC_OCS_Result($entries); |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param string $user |
||
69 | * @param int $offset |
||
70 | * @return int |
||
71 | */ |
||
72 | 2 | protected static function getSinceFromOffset($user, $offset) { |
|
91 | } |
||
92 |