Skip to content

Commit 2db1f60

Browse files
committed
refactor: Modernize code and remove long AI generated comment
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 5b6aab4 commit 2db1f60

2 files changed

Lines changed: 6 additions & 27 deletions

File tree

lib/Controller/APIv2Controller.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use OCP\Activity\IFilter;
2020
use OCP\Activity\IManager;
2121
use OCP\AppFramework\Http;
22+
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
2223
use OCP\AppFramework\Http\DataResponse;
2324
use OCP\AppFramework\OCSController;
2425
use OCP\Files\FileInfo;
@@ -94,36 +95,33 @@ protected function validateParameters(string $filter, int $since, int $limit, bo
9495
}
9596

9697
/**
97-
* @NoAdminRequired
98-
*
9998
* @param string $search Only return activities whose file path contains this substring
10099
* @param int $from Only return activities at or after this Unix timestamp
101100
* @param int $to Only return activities at or before this Unix timestamp
102101
* @param string $actor Only return activities authored by this account
103102
*/
103+
#[NoAdminRequired]
104104
public function getDefault(int $since = 0, int $limit = 50, bool $previews = false, string $object_type = '', int $object_id = 0, string $sort = 'desc', string $search = '', int $from = 0, int $to = 0, string $actor = ''): DataResponse {
105105
return $this->get('all', $since, $limit, $previews, $object_type, $object_id, $sort, $search, $from, $to, $actor);
106106
}
107107

108108
/**
109-
* @NoAdminRequired
110-
*
111109
* @param string $search Only return activities whose file path contains this substring
112110
* @param int $from Only return activities at or after this Unix timestamp
113111
* @param int $to Only return activities at or before this Unix timestamp
114112
* @param string $actor Only return activities authored by this account
115113
*/
114+
#[NoAdminRequired]
116115
public function getFilter(string $filter, int $since = 0, int $limit = 50, bool $previews = false, string $object_type = '', int $object_id = 0, string $sort = 'desc', string $search = '', int $from = 0, int $to = 0, string $actor = ''): DataResponse {
117116
return $this->get($filter, $since, $limit, $previews, $object_type, $object_id, $sort, $search, $from, $to, $actor);
118117
}
119118

120119
/**
121-
* @NoAdminRequired
122-
*
123120
* @param string $object_type Object type to count downloads for (must be 'files')
124121
* @param int $object_id File ID
125122
* @return DataResponse
126123
*/
124+
#[NoAdminRequired]
127125
public function getDownloadCount(string $object_type = 'files', int $object_id = 0): DataResponse {
128126
$user = $this->userSession->getUser();
129127
if (!$user instanceof IUser) {
@@ -141,10 +139,9 @@ public function getDownloadCount(string $object_type = 'files', int $object_id =
141139
}
142140

143141
/**
144-
* @NoAdminRequired
145-
*
146-
* @return DataResponse
142+
* @return DataResponse<Http::STATUS_OK, list<array{id: string, name: string, icon: string, priority: int}>, array{}>
147143
*/
144+
#[NoAdminRequired]
148145
public function listFilters(): DataResponse {
149146
$filters = $this->activityManager->getFilters();
150147

lib/Data.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -360,24 +360,6 @@ public function get(GroupHelper $groupHelper, UserSettings $userSettings, string
360360
/**
361361
* Narrow a stream query down to a date range, a file path search term
362362
* and/or the account that authored the activity.
363-
*
364-
* Every restriction is added with andWhere() so they compose with the
365-
* filter, object and pagination conditions the caller has already applied.
366-
*
367-
* On scalability: the date range is served by the existing
368-
* `activity_user_time` (affecteduser, timestamp) index, so it is a plain
369-
* index range scan and actually makes the query cheaper the narrower it
370-
* gets. The search term is a substring match and therefore cannot use an
371-
* index; it stays bounded because every stream query is already anchored to
372-
* a single `affecteduser`, and combining it with a date range narrows the
373-
* scan further. That is also why very short terms are rejected upfront in
374-
* {@see SearchCriteria::create()}.
375-
*
376-
* The actor restriction is served by `activity_filter_by`
377-
* (affecteduser, user, timestamp), so it stays index-ordered too. It
378-
* composes with the `self` and `by` filters, which restrict the same
379-
* column: `by` combined with an actor yields everyone else's activity
380-
* narrowed to that one account.
381363
*/
382364
private function applySearchCriteria(IQueryBuilder $query, SearchCriteria $criteria): void {
383365
if ($criteria->from !== null) {

0 commit comments

Comments
 (0)