diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-15 15:28:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 15:28:30 +0200 |
commit | 51b9847fad73a1ca67dbf504358d90bd8f9e71d8 (patch) | |
tree | b104cf1c540dd1dd195ca5fd30c42b888012cbab /lib/public | |
parent | 6d6662ec68c8e15c4c6bfdf1c694794badd412d7 (diff) | |
parent | cb97e8f15c75cc46e345ebfc79dcad1b9c48bd01 (diff) | |
download | nextcloud-server-51b9847fad73a1ca67dbf504358d90bd8f9e71d8.tar.gz nextcloud-server-51b9847fad73a1ca67dbf504358d90bd8f9e71d8.zip |
Merge branch 'master' into display-name-cache-public
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'lib/public')
46 files changed, 1319 insertions, 289 deletions
diff --git a/lib/public/App.php b/lib/public/App.php deleted file mode 100644 index 5103e624316..00000000000 --- a/lib/public/App.php +++ /dev/null @@ -1,104 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Bart Visscher <bartv@thisnet.nl> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Frank Karlitschek <frank@karlitschek.de> - * @author Georg Ehrke <oc.list@georgehrke.com> - * @author Joas Schilling <coding@schilljs.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Julius Härtl <jus@bitgrid.net> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin McCorkell <robin@mccorkell.me.uk> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal ownCloud classes - -namespace OCP; - -/** - * This class provides functions to manage apps in ownCloud - * @since 4.0.0 - * @deprecated 14.0.0 - */ -class App { - - - /** - * Register a Configuration Screen that should appear in the personal settings section. - * @param string $app appid - * @param string $page page to be included - * @return void - * @since 4.0.0 - * @deprecated 14.0.0 Use settings section in appinfo.xml to register personal admin sections - */ - public static function registerPersonal($app, $page) { - \OC_App::registerPersonal($app, $page); - } - - /** - * Register a Configuration Screen that should appear in the Admin section. - * @param string $app string appid - * @param string $page string page to be included - * @return void - * @since 4.0.0 - * @deprecated 14.0.0 Use settings section in appinfo.xml to register admin sections - */ - public static function registerAdmin($app, $page) { - \OC_App::registerAdmin($app, $page); - } - - /** - * Read app metadata from the info.xml file - * @param string $app id of the app or the path of the info.xml file - * @param boolean $path (optional) - * @return array|null - * @deprecated 14.0.0 ise \OC::$server->getAppManager()->getAppInfo($appId) - * @since 4.0.0 - */ - public static function getAppInfo($app, $path = false) { - return \OC_App::getAppInfo($app, $path); - } - - /** - * checks whether or not an app is enabled - * @param string $app - * @return boolean - * - * This function checks whether or not an app is enabled. - * @since 4.0.0 - * @deprecated 13.0.0 use \OC::$server->getAppManager()->isEnabledForUser($appId) - */ - public static function isEnabled($app) { - return \OC::$server->getAppManager()->isEnabledForUser($app); - } - - /** - * Get the last version of the app from appinfo/info.xml - * @param string $app - * @return string - * @since 4.0.0 - * @deprecated 14.0.0 use \OC::$server->getAppManager()->getAppVersion($appId) - */ - public static function getAppVersion($app) { - return \OC::$server->getAppManager()->getAppVersion($app); - } -} diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 7473b229427..e0b5c049290 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -36,6 +36,9 @@ use OCP\IUser; /** * Interface IAppManager * + * @warning This interface shouldn't be included with dependency injection in + * classes used for installing Nextcloud. + * * @since 8.0.0 */ interface IAppManager { diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index a5d675f14c7..6b10d7bfc0f 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -306,4 +306,15 @@ interface IRegistrationContext { * @since 24.0.0 */ public function registerUserMigrator(string $migratorClass): void; + + /** + * Announce methods of classes that may contain sensitive values, which + * should be obfuscated before being logged. + * + * @param string $class + * @param string[] $methods + * @return void + * @since 25.0.0 + */ + public function registerSensitiveMethods(string $class, array $methods): void; } diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index a059e3a27b0..dcd1c77c042 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -113,6 +113,9 @@ abstract class Entity { $type = $this->_fieldTypes[$name]; if ($type === 'blob') { // (B)LOB is treated as string when we read from the DB + if (is_resource($args[0])) { + $args[0] = stream_get_contents($args[0]); + } $type = 'string'; } diff --git a/lib/public/AppFramework/Http/JSONResponse.php b/lib/public/AppFramework/Http/JSONResponse.php index f4b936435c8..4870a64afd7 100644 --- a/lib/public/AppFramework/Http/JSONResponse.php +++ b/lib/public/AppFramework/Http/JSONResponse.php @@ -64,13 +64,7 @@ class JSONResponse extends Response { * @throws \Exception If data could not get encoded */ public function render() { - $response = json_encode($this->data, JSON_HEX_TAG); - if ($response === false) { - throw new \Exception(sprintf('Could not json_encode due to invalid ' . - 'non UTF-8 characters in the array: %s', var_export($this->data, true))); - } - - return $response; + return json_encode($this->data, JSON_HEX_TAG | JSON_THROW_ON_ERROR); } /** diff --git a/lib/public/AppFramework/Http/TemplateResponse.php b/lib/public/AppFramework/Http/TemplateResponse.php index 9b010d38bae..23843cd21d1 100644 --- a/lib/public/AppFramework/Http/TemplateResponse.php +++ b/lib/public/AppFramework/Http/TemplateResponse.php @@ -139,6 +139,15 @@ class TemplateResponse extends Response { /** + * @return string the app id of the used template + * @since 25.0.0 + */ + public function getApp(): string { + return $this->appName; + } + + + /** * Used for accessing the name of the set template * @return string the name of the used template * @since 6.0.0 diff --git a/lib/public/AppFramework/Http/ZipResponse.php b/lib/public/AppFramework/Http/ZipResponse.php index 7495583ae12..23e9f1f7a94 100644 --- a/lib/public/AppFramework/Http/ZipResponse.php +++ b/lib/public/AppFramework/Http/ZipResponse.php @@ -37,7 +37,7 @@ use OCP\IRequest; * @since 15.0.0 */ class ZipResponse extends Response implements ICallbackResponse { - /** @var array{internalName: string, resource: string, size: int, time: int}[] Files to be added to the zip response */ + /** @var array{internalName: string, resource: resource, size: int, time: int}[] Files to be added to the zip response */ private array $resources = []; /** @var string Filename that the zip file should have */ private string $name; diff --git a/lib/public/BackgroundJob.php b/lib/public/Authentication/IProvideUserSecretBackend.php index 2be11ab0a6e..08f4043d828 100644 --- a/lib/public/BackgroundJob.php +++ b/lib/public/Authentication/IProvideUserSecretBackend.php @@ -1,10 +1,8 @@ <?php /** - * @copyright Copyright (c) 2016, ownCloud, Inc. + * @copyright Copyright (c) 2021, MichaIng <micha@dietpi.com> * - * @author Jakob Sack <mail@jakobsack.de> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> + * @author MichaIng <micha@dietpi.com> * * @license AGPL-3.0 * @@ -21,25 +19,23 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ -namespace OCP; +// use OCP namespace for all classes that are considered public. +// This means that they should be used by apps instead of the internal ownCloud classes + +namespace OCP\Authentication; /** - * @since 4.5.0 - * @deprecated 14.0.0 + * Interface IProvideUserSecretBackend + * + * @since 23.0.0 */ -class BackgroundJob { - /** - * @since 5.0.0 - * @deprecated 14.0.0 - */ - public static function getExecutionType() { - return ''; - } +interface IProvideUserSecretBackend { /** - * @since 5.0.0 - * @deprecated 14.0.0 + * Optionally returns a stable per-user secret. This secret is for + * instance used to secure file encryption keys. + * @return string + * @since 23.0.0 */ - public static function setExecutionType($type) { - } + public function getCurrentUserSecret(): string; } diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php index eab37a03f36..8f6449b070b 100644 --- a/lib/public/BackgroundJob/IJobList.php +++ b/lib/public/BackgroundJob/IJobList.php @@ -7,6 +7,7 @@ * @author Noveen Sachdeva <noveen.sachdeva@research.iiit.ac.in> * @author Robin Appelman <robin@icewind.nl> * @author Robin McCorkell <robin@mccorkell.me.uk> + * @author Côme Chilliet <come.chilliet@nextcloud.com> * * @license AGPL-3.0 * @@ -41,66 +42,71 @@ namespace OCP\BackgroundJob; * be specified in the constructor of the job by calling * $this->setInterval($interval) with $interval in seconds. * + * This interface should be used directly and not implemented by an application. + * The implementation is provided by the server. + * * @since 7.0.0 */ interface IJobList { /** * Add a job to the list * - * @param \OCP\BackgroundJob\IJob|string $job + * @param IJob|class-string<IJob> $job * @param mixed $argument The argument to be passed to $job->run() when the job is exectured * @since 7.0.0 */ - public function add($job, $argument = null); + public function add($job, $argument = null): void; /** * Remove a job from the list * - * @param \OCP\BackgroundJob\IJob|string $job + * @param IJob|class-string<IJob> $job * @param mixed $argument * @since 7.0.0 */ - public function remove($job, $argument = null); + public function remove($job, $argument = null): void; /** * check if a job is in the list * - * @param \OCP\BackgroundJob\IJob|string $job + * @param IJob|class-string<IJob> $job * @param mixed $argument - * @return bool * @since 7.0.0 */ - public function has($job, $argument); + public function has($job, $argument): bool; /** * get all jobs in the list * - * @return \OCP\BackgroundJob\IJob[] + * @return IJob[] * @since 7.0.0 * @deprecated 9.0.0 - This method is dangerous since it can cause load and - * memory problems when creating too many instances. + * memory problems when creating too many instances. Use getJobs instead. + */ + public function getAll(): array; + + /** + * Get jobs matching the search + * + * @param IJob|class-string<IJob>|null $job + * @return IJob[] + * @since 25.0.0 */ - public function getAll(); + public function getJobs($job, ?int $limit, int $offset): array; /** * get the next job in the list * - * @param bool $onlyTimeSensitive - * @return \OCP\BackgroundJob\IJob|null * @since 7.0.0 - In 24.0.0 parameter $onlyTimeSensitive got added */ public function getNext(bool $onlyTimeSensitive = false): ?IJob; /** - * @param int $id - * @return \OCP\BackgroundJob\IJob|null * @since 7.0.0 */ - public function getById($id); + public function getById(int $id): ?IJob; /** - * @param int $id - * @return array|null * @since 23.0.0 */ public function getDetailsById(int $id): ?array; @@ -108,40 +114,34 @@ interface IJobList { /** * set the job that was last ran to the current time * - * @param \OCP\BackgroundJob\IJob $job * @since 7.0.0 */ - public function setLastJob(IJob $job); + public function setLastJob(IJob $job): void; /** * Remove the reservation for a job * - * @param IJob $job * @since 9.1.0 */ - public function unlockJob(IJob $job); + public function unlockJob(IJob $job): void; /** * set the lastRun of $job to now * - * @param IJob $job * @since 7.0.0 */ - public function setLastRun(IJob $job); + public function setLastRun(IJob $job): void; /** * set the run duration of $job * - * @param IJob $job - * @param $timeTaken * @since 12.0.0 */ - public function setExecutionTime(IJob $job, $timeTaken); + public function setExecutionTime(IJob $job, int $timeTaken): void; /** * Reset the $job so it executes on the next trigger * - * @param IJob $job * @since 23.0.0 */ public function resetBackgroundJob(IJob $job): void; diff --git a/lib/public/Cache/CappedMemoryCache.php b/lib/public/Cache/CappedMemoryCache.php new file mode 100644 index 00000000000..6699600d42c --- /dev/null +++ b/lib/public/Cache/CappedMemoryCache.php @@ -0,0 +1,160 @@ +<?php +/** + * @copyright Copyright (c) 2016, ownCloud, Inc. + * + * @author Robin Appelman <robin@icewind.nl> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCP\Cache; + +use OCP\ICache; + +/** + * In-memory cache with a capacity limit to keep memory usage in check + * + * Uses a simple FIFO expiry mechanism + * + * @since 25.0.0 + * @template T + */ +class CappedMemoryCache implements ICache, \ArrayAccess { + private int $capacity; + /** @var T[] */ + private array $cache = []; + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function __construct(int $capacity = 512) { + $this->capacity = $capacity; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function hasKey($key): bool { + return isset($this->cache[$key]); + } + + /** + * @return ?T + * @since 25.0.0 + */ + public function get($key) { + return $this->cache[$key] ?? null; + } + + /** + * @inheritdoc + * @param string $key + * @param T $value + * @param int $ttl + * @since 25.0.0 + * @return bool + */ + public function set($key, $value, $ttl = 0): bool { + if (is_null($key)) { + $this->cache[] = $value; + } else { + $this->cache[$key] = $value; + } + $this->garbageCollect(); + return true; + } + + /** + * @since 25.0.0 + */ + public function remove($key): bool { + unset($this->cache[$key]); + return true; + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function clear($prefix = ''): bool { + $this->cache = []; + return true; + } + + /** + * @since 25.0.0 + */ + public function offsetExists($offset): bool { + return $this->hasKey($offset); + } + + /** + * @inheritdoc + * @return T + * @since 25.0.0 + */ + #[\ReturnTypeWillChange] + public function &offsetGet($offset) { + return $this->cache[$offset]; + } + + /** + * @inheritdoc + * @param string $offset + * @param T $value + * @since 25.0.0 + */ + public function offsetSet($offset, $value): void { + $this->set($offset, $value); + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public function offsetUnset($offset): void { + $this->remove($offset); + } + + /** + * @return T[] + * @since 25.0.0 + */ + public function getData(): array { + return $this->cache; + } + + + /** + * @since 25.0.0 + */ + private function garbageCollect(): void { + while (count($this->cache) > $this->capacity) { + reset($this->cache); + $key = key($this->cache); + $this->remove($key); + } + } + + /** + * @inheritdoc + * @since 25.0.0 + */ + public static function isAvailable(): bool { + return true; + } +} diff --git a/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php b/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php new file mode 100644 index 00000000000..2f1dc5a0a00 --- /dev/null +++ b/lib/public/Collaboration/Resources/LoadAdditionalScriptsEvent.php @@ -0,0 +1,40 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright Copyright (c) 2022 Julius Härtl <jus@bitgrid.net> + * + * @author Julius Härtl <jus@bitgrid.net> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Collaboration\Resources; + +use OCP\EventDispatcher\Event; + +/** + * This event is used by apps to register their own frontend scripts for integrating + * projects in their app. Apps also need to dispatch the event in order to load + * scripts during page load + * + * @see https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/projects.html + * @since 25.0.0 + */ +class LoadAdditionalScriptsEvent extends Event { +} diff --git a/lib/public/Color.php b/lib/public/Color.php new file mode 100644 index 00000000000..e2cabd9c2fc --- /dev/null +++ b/lib/public/Color.php @@ -0,0 +1,142 @@ +<?php +/** + * @copyright Copyright (c) 2016, John Molakvoæ <skjnldsv@protonmail.com> + * + * @author Christoph Wurst <christoph@winzerhof-wurst.at> + * @author Morris Jobke <hey@morrisjobke.de> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP; + +/** + * Simple RGB color container + * @since 25.0.0 + */ +class Color { + private int $r; + private int $g; + private int $b; + + /** + * @since 25.0.0 + */ + public function __construct($r, $g, $b) { + $this->r = $r; + $this->g = $g; + $this->b = $b; + } + + /** + * Returns the red color component of this color as an int from 0 to 255 + * + * @since 25.0.0 + */ + public function red(): int { + return $this->r; + } + + /** + * Returns the red color component of this color as a float from 0 to 1 + * + * @since 25.0.0 + */ + public function redF(): float { + return $this->r / 255; + } + + /** + * Returns the green color component of this color as an int from 0 to 255 + * + * @since 25.0.0 + */ + public function green(): int { + return $this->g; + } + + /** + * Returns the green color component of this color as a float from 0 to 1 + * + * @since 25.0.0 + */ + public function greenF(): float { + return $this->g / 255; + } + + /** + * Returns the green blue component of this color as an int from 0 to 255 + * + * @since 25.0.0 + */ + public function blue(): int { + return $this->b; + } + + /** + * Returns the blue color component of this color as a float from 0 to 1 + * + * @since 25.0.0 + */ + public function blueF(): float { + return $this->g / 255; + } + + /** + * Returns the name of the color in the format "#RRGGBB"; i.e. a "#" character followed by three two-digit hexadecimal numbers. + * + * @since 25.0.0 + */ + public function name(): string { + return sprintf("#%02x%02x%02x", $this->r, $this->g, $this->b); + } + + /** + * Mix two colors + * + * @param int $steps the number of intermediate colors that should be generated for the palette + * @param Color $color1 the first color + * @param Color $color2 the second color + * @return list<Color> + * @since 25.0.0 + */ + public static function mixPalette(int $steps, Color $color1, Color $color2): array { + $palette = [$color1]; + $step = self::stepCalc($steps, [$color1, $color2]); + for ($i = 1; $i < $steps; $i++) { + $r = intval($color1->red() + ($step[0] * $i)); + $g = intval($color1->green() + ($step[1] * $i)); + $b = intval($color1->blue() + ($step[2] * $i)); + $palette[] = new Color($r, $g, $b); + } + return $palette; + } + + /** + * Calculate steps between two Colors + * @param int $steps start color + * @param Color[] $ends end color + * @return array{0: int, 1: int, 2: int} [r,g,b] steps for each color to go from $steps to $ends + * @since 25.0.0 + */ + private static function stepCalc(int $steps, array $ends): array { + $step = []; + $step[0] = ($ends[1]->red() - $ends[0]->red()) / $steps; + $step[1] = ($ends[1]->green() - $ends[0]->green()) / $steps; + $step[2] = ($ends[1]->blue() - $ends[0]->blue()) / $steps; + return $step; + } +} diff --git a/lib/public/Comments/IComment.php b/lib/public/Comments/IComment.php index 8465eaf49f4..eb696fa5f06 100644 --- a/lib/public/Comments/IComment.php +++ b/lib/public/Comments/IComment.php @@ -230,11 +230,11 @@ interface IComment { /** * sets the date of the most recent child * - * @param \DateTime $dateTime + * @param \DateTime|null $dateTime * @return IComment * @since 9.0.0 */ - public function setLatestChildDateTime(\DateTime $dateTime); + public function setLatestChildDateTime(?\DateTime $dateTime = null); /** * returns the object type the comment is attached to @@ -299,4 +299,21 @@ interface IComment { * @since 24.0.0 */ public function setReactions(?array $reactions): IComment; + + /** + * Set message expire date + * + * @param \DateTime|null $dateTime + * @return IComment + * @since 25.0.0 + */ + public function setExpireDate(?\DateTime $dateTime): IComment; + + /** + * Get message expire date + * + * @return ?\DateTime + * @since 25.0.0 + */ + public function getExpireDate(): ?\DateTime; } diff --git a/lib/public/Comments/ICommentsManager.php b/lib/public/Comments/ICommentsManager.php index c34bd4718cc..da9e4d76a38 100644 --- a/lib/public/Comments/ICommentsManager.php +++ b/lib/public/Comments/ICommentsManager.php @@ -482,4 +482,15 @@ interface ICommentsManager { * @since 21.0.0 */ public function load(): void; + + /** + * Delete comments with field expire_date less than current date + * Only will delete the message related with the object. + * + * @param string $objectType the object type (e.g. 'files') + * @param string $objectId e.g. the file id, leave empty to expire on all objects of this type + * @return boolean true if at least one row was deleted + * @since 25.0.0 + */ + public function deleteCommentsExpiredAtObject(string $objectType, string $objectId = ''): bool; } diff --git a/lib/public/Config/BeforePreferenceDeletedEvent.php b/lib/public/Config/BeforePreferenceDeletedEvent.php new file mode 100644 index 00000000000..a2d1dad7034 --- /dev/null +++ b/lib/public/Config/BeforePreferenceDeletedEvent.php @@ -0,0 +1,83 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Config; + +use OCP\EventDispatcher\Event; + +/** + * @since 25.0.0 + */ +class BeforePreferenceDeletedEvent extends Event { + protected string $userId; + protected string $appId; + protected string $configKey; + protected bool $valid = false; + + /** + * @since 25.0.0 + */ + public function __construct(string $userId, string $appId, string $configKey) { + parent::__construct(); + $this->userId = $userId; + $this->appId = $appId; + $this->configKey = $configKey; + } + + /** + * @since 25.0.0 + */ + public function getUserId(): string { + return $this->userId; + } + + /** + * @since 25.0.0 + */ + public function getAppId(): string { + return $this->appId; + } + + /** + * @since 25.0.0 + */ + public function getConfigKey(): string { + return $this->configKey; + } + + /** + * @since 25.0.0 + */ + public function isValid(): bool { + return $this->valid; + } + + /** + * @since 25.0.0 + */ + public function setValid(bool $valid): void { + $this->valid = $valid; + } +} diff --git a/lib/public/Config/BeforePreferenceSetEvent.php b/lib/public/Config/BeforePreferenceSetEvent.php new file mode 100644 index 00000000000..31681405a47 --- /dev/null +++ b/lib/public/Config/BeforePreferenceSetEvent.php @@ -0,0 +1,92 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> + * + * @author Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Config; + +use OCP\EventDispatcher\Event; + +/** + * @since 25.0.0 + */ +class BeforePreferenceSetEvent extends Event { + protected string $userId; + protected string $appId; + protected string $configKey; + protected string $configValue; + protected bool $valid = false; + + /** + * @since 25.0.0 + */ + public function __construct(string $userId, string $appId, string $configKey, string $configValue) { + parent::__construct(); + $this->userId = $userId; + $this->appId = $appId; + $this->configKey = $configKey; + $this->configValue = $configValue; + } + + /** + * @since 25.0.0 + */ + public function getUserId(): string { + return $this->userId; + } + + /** + * @since 25.0.0 + */ + public function getAppId(): string { + return $this->appId; + } + + /** + * @since 25.0.0 + */ + public function getConfigKey(): string { + return $this->configKey; + } + + /** + * @since 25.0.0 + */ + public function getConfigValue(): string { + return $this->configValue; + } + + /** + * @since 25.0.0 + */ + public function isValid(): bool { + return $this->valid; + } + + /** + * @since 25.0.0 + */ + public function setValid(bool $valid): void { + $this->valid = $valid; + } +} diff --git a/lib/public/Contacts/IManager.php b/lib/public/Contacts/IManager.php index e9bdc01c060..65be12c4c39 100644 --- a/lib/public/Contacts/IManager.php +++ b/lib/public/Contacts/IManager.php @@ -105,7 +105,7 @@ interface IManager { /** * This function can be used to delete the contact identified by the given id * - * @param object $id the unique identifier to a contact + * @param int $id the unique identifier to a contact * @param string $address_book_key identifier of the address book in which the contact shall be deleted * @return bool successful or not * @since 6.0.0 diff --git a/lib/public/DB/QueryBuilder/IExpressionBuilder.php b/lib/public/DB/QueryBuilder/IExpressionBuilder.php index 53dc1fa5a7f..8f7cd10dee5 100644 --- a/lib/public/DB/QueryBuilder/IExpressionBuilder.php +++ b/lib/public/DB/QueryBuilder/IExpressionBuilder.php @@ -107,7 +107,7 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x @@ -115,7 +115,7 @@ interface IExpressionBuilder { * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function comparison($x, string $operator, $y, $type = null): string; + public function comparison($x, string $operator, $y, $type = null): IQueryFunction; /** * Creates an equality comparison expression with the given arguments. @@ -132,14 +132,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function eq($x, $y, $type = null): string; + public function eq($x, $y, $type = null): IQueryFunction; /** * Creates a non equality comparison expression with the given arguments. @@ -155,14 +155,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function neq($x, $y, $type = null): string; + public function neq($x, $y, $type = null): IQueryFunction; /** * Creates a lower-than comparison expression with the given arguments. @@ -178,14 +178,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function lt($x, $y, $type = null): string; + public function lt($x, $y, $type = null): IQueryFunction; /** * Creates a lower-than-equal comparison expression with the given arguments. @@ -201,14 +201,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function lte($x, $y, $type = null): string; + public function lte($x, $y, $type = null): IQueryFunction; /** * Creates a greater-than comparison expression with the given arguments. @@ -224,14 +224,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function gt($x, $y, $type = null): string; + public function gt($x, $y, $type = null): IQueryFunction; /** * Creates a greater-than-equal comparison expression with the given arguments. @@ -247,38 +247,38 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function gte($x, $y, $type = null): string; + public function gte($x, $y, $type = null): IQueryFunction; /** * Creates an IS NULL expression with the given arguments. * * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NULL. * - * @return string + * @return IQueryFunction * @since 8.2.0 * * @psalm-taint-sink sql $x */ - public function isNull($x): string; + public function isNull($x): IQueryFunction; /** * Creates an IS NOT NULL expression with the given arguments. * * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be restricted by IS NOT NULL. * - * @return string + * @return IQueryFunction * @since 8.2.0 * * @psalm-taint-sink sql $x */ - public function isNotNull($x): string; + public function isNotNull($x): IQueryFunction; /** * Creates a LIKE() comparison expression with the given arguments. @@ -288,14 +288,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function like($x, $y, $type = null): string; + public function like($x, $y, $type = null): IQueryFunction; /** * Creates a NOT LIKE() comparison expression with the given arguments. @@ -305,14 +305,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function notLike($x, $y, $type = null): string; + public function notLike($x, $y, $type = null): IQueryFunction; /** * Creates a ILIKE() comparison expression with the given arguments. @@ -322,14 +322,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function iLike($x, $y, $type = null): string; + public function iLike($x, $y, $type = null): IQueryFunction; /** * Creates a IN () comparison expression with the given arguments. @@ -339,14 +339,14 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function in($x, $y, $type = null): string; + public function in($x, $y, $type = null): IQueryFunction; /** * Creates a NOT IN () comparison expression with the given arguments. @@ -356,36 +356,36 @@ interface IExpressionBuilder { * @param mixed|null $type one of the IQueryBuilder::PARAM_* constants * required when comparing text fields for oci compatibility * - * @return string + * @return IQueryFunction * @since 8.2.0 - Parameter $type was added in 9.0.0 * * @psalm-taint-sink sql $x * @psalm-taint-sink sql $y * @psalm-taint-sink sql $type */ - public function notIn($x, $y, $type = null): string; + public function notIn($x, $y, $type = null): IQueryFunction; /** * Creates a $x = '' statement, because Oracle needs a different check * * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. - * @return string + * @return IQueryFunction * @since 13.0.0 * * @psalm-taint-sink sql $x */ - public function emptyString($x): string; + public function emptyString($x): IQueryFunction; /** * Creates a `$x <> ''` statement, because Oracle needs a different check * * @param string|ILiteral|IParameter|IQueryFunction $x The field in string format to be inspected by the comparison. - * @return string + * @return IQueryFunction * @since 13.0.0 * * @psalm-taint-sink sql $x */ - public function nonEmptyString($x): string; + public function nonEmptyString($x): IQueryFunction; /** diff --git a/lib/public/DB/QueryBuilder/IFunctionBuilder.php b/lib/public/DB/QueryBuilder/IFunctionBuilder.php index d4edc8ea9f8..811e8d06aaf 100644 --- a/lib/public/DB/QueryBuilder/IFunctionBuilder.php +++ b/lib/public/DB/QueryBuilder/IFunctionBuilder.php @@ -188,4 +188,16 @@ interface IFunctionBuilder { * @since 18.0.0 */ public function least($x, $y): IQueryFunction; + + /** + * Takes the minimum of multiple values + * + * If you want to get the minimum value of all rows in a column, use `min` instead + * + * @param array<array{"when": string|ILiteral|IParameter|IQueryFunction, "then": string|ILiteral|IParameter|IQueryFunction}> $whens + * @param string|ILiteral|IParameter|IQueryFunction $else + * @return IQueryFunction + * @since 18.0.0 + */ + public function case(array $whens, $else): IQueryFunction; } diff --git a/lib/public/DB/QueryBuilder/IQueryBuilder.php b/lib/public/DB/QueryBuilder/IQueryBuilder.php index e3257e82bca..446e9a00b4c 100644 --- a/lib/public/DB/QueryBuilder/IQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/IQueryBuilder.php @@ -503,7 +503,7 @@ interface IQueryBuilder { * @param string $fromAlias The alias that points to a from clause. * @param string $join The table name to join. * @param string $alias The alias of the join table. - * @param string|ICompositeExpression|null $condition The condition for the join. + * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join. * * @return $this This QueryBuilder instance. * @since 8.2.0 @@ -528,7 +528,7 @@ interface IQueryBuilder { * @param string $fromAlias The alias that points to a from clause. * @param string $join The table name to join. * @param string $alias The alias of the join table. - * @param string|ICompositeExpression|null $condition The condition for the join. + * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join. * * @return $this This QueryBuilder instance. * @since 8.2.0 @@ -553,7 +553,7 @@ interface IQueryBuilder { * @param string $fromAlias The alias that points to a from clause. * @param string $join The table name to join. * @param string $alias The alias of the join table. - * @param string|ICompositeExpression|null $condition The condition for the join. + * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join. * * @return $this This QueryBuilder instance. * @since 8.2.0 @@ -578,7 +578,7 @@ interface IQueryBuilder { * @param string $fromAlias The alias that points to a from clause. * @param string $join The table name to join. * @param string $alias The alias of the join table. - * @param string|ICompositeExpression|null $condition The condition for the join. + * @param string|IQueryFunction|ICompositeExpression|null $condition The condition for the join. * * @return $this This QueryBuilder instance. * @since 8.2.0 @@ -820,7 +820,7 @@ interface IQueryBuilder { * Specifies an ordering for the query results. * Replaces any previously specified orderings, if any. * - * @param string $sort The ordering expression. + * @param string|IQueryFunction|ILiteral|IParameter $sort The ordering expression. * @param string $order The ordering direction. * * @return $this This QueryBuilder instance. diff --git a/lib/public/Dashboard/IManager.php b/lib/public/Dashboard/IManager.php index 396624876ef..d9e73c89eb9 100644 --- a/lib/public/Dashboard/IManager.php +++ b/lib/public/Dashboard/IManager.php @@ -36,7 +36,7 @@ interface IManager { * @param string $widgetClass * @since 20.0.0 */ - public function lazyRegisterWidget(string $widgetClass): void; + public function lazyRegisterWidget(string $widgetClass, string $appId): void; /** * @since 20.0.0 diff --git a/lib/public/Federation/Events/TrustedServerRemovedEvent.php b/lib/public/Federation/Events/TrustedServerRemovedEvent.php new file mode 100644 index 00000000000..785991c1554 --- /dev/null +++ b/lib/public/Federation/Events/TrustedServerRemovedEvent.php @@ -0,0 +1,48 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Carl Schwan <carl@carlschwan.eu> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Federation\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 25.0.0 + */ +class TrustedServerRemovedEvent extends Event { + private string $urlHash; + + /** + * @since 25.0.0 + */ + public function __construct(string $urlHash) { + parent::__construct(); + $this->urlHash = $urlHash; + } + + /** + * @since 25.0.0 + */ + public function getUrlHash(): string { + return $this->urlHash; + } +} diff --git a/lib/public/Files/Cache/ICache.php b/lib/public/Files/Cache/ICache.php index e27f4207f1e..37e71f3ac79 100644 --- a/lib/public/Files/Cache/ICache.php +++ b/lib/public/Files/Cache/ICache.php @@ -243,7 +243,7 @@ interface ICache { * use the one with the highest id gives the best result with the background scanner, since that is most * likely the folder where we stopped scanning previously * - * @return string|bool the path of the folder or false when no folder matched + * @return string|false the path of the folder or false when no folder matched * @since 9.0.0 */ public function getIncomplete(); diff --git a/lib/public/Files/Cache/ICacheEntry.php b/lib/public/Files/Cache/ICacheEntry.php index 17eecf89ddb..e1e8129394c 100644 --- a/lib/public/Files/Cache/ICacheEntry.php +++ b/lib/public/Files/Cache/ICacheEntry.php @@ -162,4 +162,14 @@ interface ICacheEntry extends ArrayAccess { * @since 18.0.0 */ public function getUploadTime(): ?int; + + /** + * Get the unencrypted size + * + * This might be different from the result of getSize + * + * @return int + * @since 25.0.0 + */ + public function getUnencryptedSize(): int; } diff --git a/lib/public/Files/Events/BeforeDirectFileDownloadEvent.php b/lib/public/Files/Events/BeforeDirectFileDownloadEvent.php new file mode 100644 index 00000000000..a32c95c6408 --- /dev/null +++ b/lib/public/Files/Events/BeforeDirectFileDownloadEvent.php @@ -0,0 +1,84 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Carl Schwan <carl@carlschwan.eu> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * This event is triggered when a user tries to download a file + * directly. + * + * @since 25.0.0 + */ +class BeforeDirectFileDownloadEvent extends Event { + private string $path; + private bool $successful = true; + private ?string $errorMessage = null; + + /** + * @since 25.0.0 + */ + public function __construct(string $path) { + parent::__construct(); + $this->path = $path; + } + + /** + * @since 25.0.0 + */ + public function getPath(): string { + return $this->path; + } + + /** + * @since 25.0.0 + */ + public function isSuccessful(): bool { + return $this->successful; + } + + /** + * Set if the event was successful + * + * @since 25.0.0 + */ + public function setSuccessful(bool $successful): void { + $this->successful = $successful; + } + + /** + * Get the error message, if any + * @since 25.0.0 + */ + public function getErrorMessage(): ?string { + return $this->errorMessage; + } + + /** + * @since 25.0.0 + */ + public function setErrorMessage(string $errorMessage): void { + $this->errorMessage = $errorMessage; + } +} diff --git a/lib/public/Files/Events/BeforeZipCreatedEvent.php b/lib/public/Files/Events/BeforeZipCreatedEvent.php new file mode 100644 index 00000000000..18f41a42899 --- /dev/null +++ b/lib/public/Files/Events/BeforeZipCreatedEvent.php @@ -0,0 +1,91 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Carl Schwan <carl@carlschwan.eu> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Files\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 25.0.0 + */ +class BeforeZipCreatedEvent extends Event { + private string $directory; + private array $files; + private bool $successful = true; + private ?string $errorMessage = null; + + /** + * @since 25.0.0 + */ + public function __construct(string $directory, array $files) { + parent::__construct(); + $this->directory = $directory; + $this->files = $files; + } + + /** + * @since 25.0.0 + */ + public function getDirectory(): string { + return $this->directory; + } + + /** + * @since 25.0.0 + */ + public function getFiles(): array { + return $this->files; + } + + /** + * @since 25.0.0 + */ + public function isSuccessful(): bool { + return $this->successful; + } + + /** + * Set if the event was successful + * + * @since 25.0.0 + */ + public function setSuccessful(bool $successful): void { + $this->successful = $successful; + } + + /** + * Get the error message, if any + * @since 25.0.0 + */ + public function getErrorMessage(): ?string { + return $this->errorMessage; + } + + /** + * @since 25.0.0 + */ + public function setErrorMessage(string $errorMessage): void { + $this->errorMessage = $errorMessage; + } +} diff --git a/lib/public/Files/SimpleFS/ISimpleFile.php b/lib/public/Files/SimpleFS/ISimpleFile.php index 8f1921cb7cb..34cd128d449 100644 --- a/lib/public/Files/SimpleFS/ISimpleFile.php +++ b/lib/public/Files/SimpleFS/ISimpleFile.php @@ -41,44 +41,39 @@ interface ISimpleFile { /** * Get the name * - * @return string * @since 11.0.0 */ - public function getName(); + public function getName(): string; /** * Get the size in bytes * - * @return int * @since 11.0.0 */ - public function getSize(); + public function getSize(): int; /** * Get the ETag * - * @return string * @since 11.0.0 */ - public function getETag(); + public function getETag(): string; /** * Get the last modification time * - * @return int * @since 11.0.0 */ - public function getMTime(); + public function getMTime(): int; /** * Get the content * * @throws NotPermittedException * @throws NotFoundException - * @return string * @since 11.0.0 */ - public function getContent(); + public function getContent(): string; /** * Overwrite the file @@ -88,7 +83,7 @@ interface ISimpleFile { * @throws NotFoundException * @since 11.0.0 */ - public function putContent($data); + public function putContent($data): void; /** * Delete the file @@ -96,15 +91,14 @@ interface ISimpleFile { * @throws NotPermittedException * @since 11.0.0 */ - public function delete(); + public function delete(): void; /** * Get the MimeType * - * @return string * @since 11.0.0 */ - public function getMimeType(); + public function getMimeType(): string; /** * @since 24.0.0 diff --git a/lib/public/Files/SimpleFS/ISimpleFolder.php b/lib/public/Files/SimpleFS/ISimpleFolder.php index 0159c41760b..3c8e6e88ab3 100644 --- a/lib/public/Files/SimpleFS/ISimpleFolder.php +++ b/lib/public/Files/SimpleFS/ISimpleFolder.php @@ -38,7 +38,7 @@ interface ISimpleFolder { * @return ISimpleFile[] * @since 11.0.0 */ - public function getDirectoryListing(); + public function getDirectoryListing(): array; /** * Check if a file with $name exists @@ -47,28 +47,24 @@ interface ISimpleFolder { * @return bool * @since 11.0.0 */ - public function fileExists($name); + public function fileExists(string $name): bool; /** * Get the file named $name from the folder * - * @param string $name - * @return ISimpleFile * @throws NotFoundException * @since 11.0.0 */ - public function getFile($name); + public function getFile(string $name): ISimpleFile; /** * Creates a new file with $name in the folder * - * @param string $name * @param string|resource|null $content @since 19.0.0 - * @return ISimpleFile * @throws NotPermittedException * @since 11.0.0 */ - public function newFile($name, $content = null); + public function newFile(string $name, $content = null): ISimpleFile; /** * Remove the folder and all the files in it @@ -76,13 +72,12 @@ interface ISimpleFolder { * @throws NotPermittedException * @since 11.0.0 */ - public function delete(); + public function delete(): void; /** * Get the folder name * - * @return string * @since 11.0.0 */ - public function getName(); + public function getName(): string; } diff --git a/lib/public/Files/SimpleFS/ISimpleRoot.php b/lib/public/Files/SimpleFS/ISimpleRoot.php index fd590b66b31..31c3efe76dd 100644 --- a/lib/public/Files/SimpleFS/ISimpleRoot.php +++ b/lib/public/Files/SimpleFS/ISimpleRoot.php @@ -35,8 +35,6 @@ interface ISimpleRoot { /** * Get the folder with name $name * - * @param string $name - * @return ISimpleFolder * @throws NotFoundException * @throws \RuntimeException * @since 11.0.0 @@ -56,8 +54,6 @@ interface ISimpleRoot { /** * Create a new folder named $name * - * @param string $name - * @return ISimpleFolder * @throws NotPermittedException * @throws \RuntimeException * @since 11.0.0 diff --git a/lib/public/Files/SimpleFS/InMemoryFile.php b/lib/public/Files/SimpleFS/InMemoryFile.php index 590cb43e1d6..393449d4f1f 100644 --- a/lib/public/Files/SimpleFS/InMemoryFile.php +++ b/lib/public/Files/SimpleFS/InMemoryFile.php @@ -36,17 +36,13 @@ use OCP\Files\NotPermittedException; class InMemoryFile implements ISimpleFile { /** * Holds the file name. - * - * @var string */ - private $name; + private string $name; /** * Holds the file contents. - * - * @var string */ - private $contents; + private string $contents; /** * InMemoryFile constructor. @@ -64,7 +60,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getName() { + public function getName(): string { return $this->name; } @@ -72,7 +68,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getSize() { + public function getSize(): int { return strlen($this->contents); } @@ -80,7 +76,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getETag() { + public function getETag(): string { return ''; } @@ -88,7 +84,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getMTime() { + public function getMTime(): int { return time(); } @@ -96,7 +92,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getContent() { + public function getContent(): string { return $this->contents; } @@ -104,7 +100,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function putContent($data) { + public function putContent($data): void { $this->contents = $data; } @@ -113,7 +109,7 @@ class InMemoryFile implements ISimpleFile { * * @since 16.0.0 */ - public function delete() { + public function delete(): void { // unimplemented for in memory files } @@ -121,7 +117,7 @@ class InMemoryFile implements ISimpleFile { * @inheritdoc * @since 16.0.0 */ - public function getMimeType() { + public function getMimeType(): string { $fileInfo = new \finfo(FILEINFO_MIME_TYPE); return $fileInfo->buffer($this->contents); } diff --git a/lib/public/IAddressBook.php b/lib/public/IAddressBook.php index 4bb632ae070..8df9a0c007d 100644 --- a/lib/public/IAddressBook.php +++ b/lib/public/IAddressBook.php @@ -10,6 +10,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin McCorkell <robin@mccorkell.me.uk> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Thomas Citharel <nextcloud@tcit.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 @@ -47,7 +48,6 @@ namespace OCP { /** * @return string defining the unique uri * @since 16.0.0 - * @return string */ public function getUri(): string; @@ -98,7 +98,7 @@ namespace OCP { public function getPermissions(); /** - * @param object $id the unique identifier to a contact + * @param int $id the unique identifier to a contact * @return bool successful or not * @since 5.0.0 */ diff --git a/lib/public/IAvatar.php b/lib/public/IAvatar.php index 8a1bc792450..d05a12e1dbf 100644 --- a/lib/public/IAvatar.php +++ b/lib/public/IAvatar.php @@ -36,66 +36,70 @@ use OCP\Files\SimpleFS\ISimpleFile; interface IAvatar { /** - * get the users avatar + * Get the users avatar + * * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image - * @return boolean|\OCP\IImage containing the avatar or false if there's no image + * @return false|\OCP\IImage containing the avatar or false if there's no image * @since 6.0.0 - size of -1 was added in 9.0.0 */ - public function get($size = 64); + public function get(int $size = 64); /** * Check if an avatar exists for the user * - * @return bool * @since 8.1.0 */ - public function exists(); + public function exists(): bool; /** * Check if the avatar of a user is a custom uploaded one * - * @return bool * @since 14.0.0 */ public function isCustomAvatar(): bool; /** - * sets the users avatar + * Sets the users avatar + * * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar * @throws \Exception if the provided file is not a jpg or png image * @throws \Exception if the provided image is not valid * @throws \OC\NotSquareException if the image is not square - * @return void * @since 6.0.0 */ - public function set($data); + public function set($data): void; /** - * remove the users avatar - * @return void + * Remove the user's avatar + * + * @param bool $silent Whether removing the avatar should trigger a change * @since 6.0.0 */ - public function remove(); + public function remove(bool $silent = false): void; /** * Get the file of the avatar - * @param int $size -1 can be used to not scale the image - * @return ISimpleFile + * + * @param int $size The desired image size. -1 can be used to not scale the image * @throws NotFoundException * @since 9.0.0 */ - public function getFile($size); + public function getFile(int $size): ISimpleFile; /** - * @param string $text - * @return Color Object containting r g b int in the range [0, 255] + * Get the avatar background color + * * @since 14.0.0 */ - public function avatarBackgroundColor(string $text); + public function avatarBackgroundColor(string $hash): Color; /** - * Handle a changed user + * Updates the display name if changed. + * + * @param string $feature The changed feature + * @param mixed $oldValue The previous value + * @param mixed $newValue The new value * @since 13.0.0 */ - public function userChanged($feature, $oldValue, $newValue); + public function userChanged(string $feature, $oldValue, $newValue): void; } diff --git a/lib/public/IAvatarManager.php b/lib/public/IAvatarManager.php index 573e109f003..15894550d10 100644 --- a/lib/public/IAvatarManager.php +++ b/lib/public/IAvatarManager.php @@ -37,15 +37,14 @@ namespace OCP; interface IAvatarManager { /** - * return a user specific instance of \OCP\IAvatar + * Return a user specific instance of \OCP\IAvatar * @see IAvatar - * @param string $user the ownCloud user id - * @return IAvatar + * @param string $userId the Nextcloud user id * @throws \Exception In case the username is potentially dangerous * @throws \OCP\Files\NotFoundException In case there is no user folder yet * @since 6.0.0 */ - public function getAvatar(string $user) : IAvatar; + public function getAvatar(string $userId): IAvatar; /** * Returns a guest user avatar instance. diff --git a/lib/public/IDBConnection.php b/lib/public/IDBConnection.php index d12baa400c0..69ede2c8438 100644 --- a/lib/public/IDBConnection.php +++ b/lib/public/IDBConnection.php @@ -199,7 +199,7 @@ interface IDBConnection { * @param array $updatePreconditionValues ensure values match preconditions (column name => value) * @return int number of new rows * @throws Exception used to be the removed dbal exception, since 21.0.0 it's \OCP\DB\Exception - * @throws PreconditionNotMetException + * @throws PreConditionNotMetException * @since 9.0.0 */ public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []): int; diff --git a/lib/public/IUser.php b/lib/public/IUser.php index 1a1d1e44d8a..daf993df6cd 100644 --- a/lib/public/IUser.php +++ b/lib/public/IUser.php @@ -112,8 +112,7 @@ interface IUser { /** * Get the backend for the current user object - * - * @return UserInterface + * @return ?UserInterface * @since 15.0.0 */ public function getBackend(); diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index da7d477ad43..c107b2c5025 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -109,7 +109,7 @@ interface IUserManager { * * @param string $loginName * @param string $password - * @return mixed the User object on success, false otherwise + * @return IUser|false the User object on success, false otherwise * @since 8.0.0 */ public function checkPassword($loginName, $password); @@ -152,7 +152,7 @@ interface IUserManager { * @param string $uid * @param string $password * @throws \InvalidArgumentException - * @return bool|\OCP\IUser the created user or false + * @return false|\OCP\IUser the created user or false * @since 8.0.0 */ public function createUser($uid, $password); @@ -168,9 +168,9 @@ interface IUserManager { public function createUserFromBackend($uid, $password, UserInterface $backend); /** - * returns how many users per backend exist (if supported by backend) + * Get how many users per backend exist (if supported by backend) * - * @return array an array of backend class as key and count number as value + * @return array<string, int> an array of backend class name as key and count number as value * @since 8.0.0 */ public function countUsers(); diff --git a/lib/public/Log/functions.php b/lib/public/Log/functions.php new file mode 100644 index 00000000000..cc6961d8fba --- /dev/null +++ b/lib/public/Log/functions.php @@ -0,0 +1,73 @@ +<?php + +declare(strict_types=1); + +/* + * @copyright 2022 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @author 2022 Christoph Wurst <christoph@winzerhof-wurst.at> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +namespace OCP\Log; + +use OC; +use OCP\AppFramework\QueryException; +use Psr\Log\LoggerInterface; +use Psr\Log\NullLogger; +use function class_exists; + +/** + * Get a PSR logger + * + * Whenever possible, inject a logger into your classes instead of relying on + * this helper function. + * + * @warning the returned logger implementation is not guaranteed to be the same + * between two function calls. During early stages of the process you + * might in fact get a noop implementation when Nextcloud isn't ready + * to log. Therefore you MUST NOT cache the result of this function but + * fetch a new logger for every log line you want to write. + * + * @param string|null $appId optional parameter to acquire the app-specific logger + * + * @return LoggerInterface + * @since 24.0.0 + */ +function logger(string $appId = null): LoggerInterface { + if (!class_exists(OC::class) || OC::$server === null) { + // If someone calls this log before Nextcloud is initialized, there is + // no logging available. In that case we return a noop implementation + // TODO: evaluate whether logging to error_log could be an alternative + return new NullLogger(); + } + + if ($appId !== null) { + try { + $appContainer = OC::$server->getRegisteredAppContainer($appId); + return $appContainer->get(LoggerInterface::class); + } catch (QueryException $e) { + // Ignore and return the server logger below + } + } + + try { + return OC::$server->get(LoggerInterface::class); + } catch (QueryException $e) { + return new NullLogger(); + } +} diff --git a/lib/public/Security/Bruteforce/IThrottler.php b/lib/public/Security/Bruteforce/IThrottler.php new file mode 100644 index 00000000000..6f492d6c59d --- /dev/null +++ b/lib/public/Security/Bruteforce/IThrottler.php @@ -0,0 +1,126 @@ +<?php + +declare(strict_types=1); +/** + * @copyright Copyright (c) 2022 Joas Schilling <coding@schilljs.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\Security\Bruteforce; + +/** + * Class Throttler implements the bruteforce protection for security actions in + * Nextcloud. + * + * It is working by logging invalid login attempts to the database and slowing + * down all login attempts from the same subnet. The max delay is 30 seconds and + * the starting delay are 200 milliseconds. (after the first failed login) + * + * This is based on Paragonie's AirBrake for Airship CMS. You can find the original + * code at https://github.com/paragonie/airship/blob/7e5bad7e3c0fbbf324c11f963fd1f80e59762606/src/Engine/Security/AirBrake.php + * + * @package OC\Security\Bruteforce + * @since 25.0.0 + */ +interface IThrottler { + /** + * @since 25.0.0 + */ + public const MAX_DELAY = 25; + + /** + * @since 25.0.0 + */ + public const MAX_DELAY_MS = 25000; // in milliseconds + + /** + * @since 25.0.0 + */ + public const MAX_ATTEMPTS = 10; + + /** + * Register a failed attempt to bruteforce a security control + * + * @param string $action + * @param string $ip + * @param array $metadata Optional metadata logged to the database + * @since 25.0.0 + */ + public function registerAttempt(string $action, string $ip, array $metadata = []): void; + + /** + * Get the throttling delay (in milliseconds) + * + * @param string $ip + * @param string $action optionally filter by action + * @param float $maxAgeHours + * @return int + * @since 25.0.0 + */ + public function getAttempts(string $ip, string $action = '', float $maxAgeHours = 12): int; + + /** + * Get the throttling delay (in milliseconds) + * + * @param string $ip + * @param string $action optionally filter by action + * @return int + * @since 25.0.0 + */ + public function getDelay(string $ip, string $action = ''): int; + + /** + * Reset the throttling delay for an IP address, action and metadata + * + * @param string $ip + * @param string $action + * @param array $metadata + * @since 25.0.0 + */ + public function resetDelay(string $ip, string $action, array $metadata): void; + + /** + * Reset the throttling delay for an IP address + * + * @param string $ip + * @since 25.0.0 + */ + public function resetDelayForIP(string $ip): void; + + /** + * Will sleep for the defined amount of time + * + * @param string $ip + * @param string $action optionally filter by action + * @return int the time spent sleeping + * @since 25.0.0 + */ + public function sleepDelay(string $ip, string $action = ''): int; + + /** + * Will sleep for the defined amount of time unless maximum was reached in the last 30 minutes + * In this case a "429 Too Many Request" exception is thrown + * + * @param string $ip + * @param string $action optionally filter by action + * @return int the time spent sleeping + * @throws MaxDelayReached when reached the maximum + * @since 25.0.0 + */ + public function sleepDelayOrThrowOnMax(string $ip, string $action = ''): int; +} diff --git a/lib/public/Share/IAttributes.php b/lib/public/Share/IAttributes.php new file mode 100644 index 00000000000..6e4cee08b12 --- /dev/null +++ b/lib/public/Share/IAttributes.php @@ -0,0 +1,68 @@ +<?php +/** + * @author Piotr Mrowczynski <piotr@owncloud.com> + * + * @copyright Copyright (c) 2019, ownCloud GmbH + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCP\Share; + +/** + * Interface IAttributes + * + * @package OCP\Share + * @since 25.0.0 + */ +interface IAttributes { + + /** + * Sets an attribute enabled/disabled. If the key did not exist before it will be created. + * + * @param string $scope scope + * @param string $key key + * @param bool $enabled enabled + * @return IAttributes The modified object + * @since 25.0.0 + */ + public function setAttribute($scope, $key, $enabled); + + /** + * Returns if attribute is enabled/disabled for given scope id and key. + * If attribute does not exist, returns null + * + * @param string $scope scope + * @param string $key key + * @return bool|null + * @since 25.0.0 + */ + public function getAttribute($scope, $key); + + /** + * Formats the IAttributes object to array with the following format: + * [ + * 0 => [ + * "scope" => <string>, + * "key" => <string>, + * "enabled" => <bool> + * ], + * ... + * ] + * + * @return array formatted IAttributes + * @since 25.0.0 + */ + public function toArray(); +} diff --git a/lib/public/Share/IManager.php b/lib/public/Share/IManager.php index f207ca87a2c..0810acc673a 100644 --- a/lib/public/Share/IManager.php +++ b/lib/public/Share/IManager.php @@ -135,10 +135,11 @@ interface IManager { * @param string $userId * @param Folder $node * @param bool $reshares + * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders. * @return IShare[][] [$fileId => IShare[], ...] * @since 11.0.0 */ - public function getSharesInFolder($userId, Folder $node, $reshares = false); + public function getSharesInFolder($userId, Folder $node, $reshares = false, $shallow = true); /** * Get shares shared by (initiated) by the provided user. diff --git a/lib/public/Share/IShare.php b/lib/public/Share/IShare.php index 1d3cf9bbbdf..5a825552e26 100644 --- a/lib/public/Share/IShare.php +++ b/lib/public/Share/IShare.php @@ -36,7 +36,9 @@ use OCP\Files\NotFoundException; use OCP\Share\Exceptions\IllegalIDChangeException; /** - * Interface IShare + * This interface allows to represent a share object. + * + * This interface must not be implemented in your application. * * @since 9.0.0 */ @@ -300,7 +302,7 @@ interface IShare { * See \OCP\Constants::PERMISSION_* * * @param int $permissions - * @return \OCP\Share\IShare The modified object + * @return IShare The modified object * @since 9.0.0 */ public function setPermissions($permissions); @@ -315,6 +317,31 @@ interface IShare { public function getPermissions(); /** + * Create share attributes object + * + * @since 25.0.0 + * @return IAttributes + */ + public function newAttributes(): IAttributes; + + /** + * Set share attributes + * + * @param ?IAttributes $attributes + * @since 25.0.0 + * @return IShare The modified object + */ + public function setAttributes(?IAttributes $attributes); + + /** + * Get share attributes + * + * @since 25.0.0 + * @return ?IAttributes + */ + public function getAttributes(): ?IAttributes; + + /** * Set the accepted status * See self::STATUS_* * diff --git a/lib/public/Share/IShareProvider.php b/lib/public/Share/IShareProvider.php index 6af513360fe..c549592d6f6 100644 --- a/lib/public/Share/IShareProvider.php +++ b/lib/public/Share/IShareProvider.php @@ -123,10 +123,11 @@ interface IShareProvider { * @param string $userId * @param Folder $node * @param bool $reshares Also get the shares where $user is the owner instead of just the shares where $user is the initiator + * @param bool $shallow Whether the method should stop at the first level, or look into sub-folders. * @return \OCP\Share\IShare[][] * @since 11.0.0 */ - public function getSharesInFolder($userId, Folder $node, $reshares); + public function getSharesInFolder($userId, Folder $node, $reshares, $shallow = true); /** * Get all shares by the given user diff --git a/lib/public/User/Backend/ICheckPasswordBackend.php b/lib/public/User/Backend/ICheckPasswordBackend.php index b3eaf7cedb0..0d4026be859 100644 --- a/lib/public/User/Backend/ICheckPasswordBackend.php +++ b/lib/public/User/Backend/ICheckPasswordBackend.php @@ -35,7 +35,7 @@ interface ICheckPasswordBackend { * * @param string $loginName The loginname * @param string $password The password - * @return string|bool The uid on success false on failure + * @return string|false The uid on success false on failure */ public function checkPassword(string $loginName, string $password); } diff --git a/lib/public/User/Events/UserChangedEvent.php b/lib/public/User/Events/UserChangedEvent.php index 3a40f8c3f11..f48dd3914e6 100644 --- a/lib/public/User/Events/UserChangedEvent.php +++ b/lib/public/User/Events/UserChangedEvent.php @@ -32,16 +32,10 @@ use OCP\IUser; * @since 18.0.0 */ class UserChangedEvent extends Event { - - /** @var IUser */ - private $user; - - /** @var string */ - private $feature; - + private IUser $user; + private string $feature; /** @var mixed */ private $value; - /** @var mixed */ private $oldValue; diff --git a/lib/public/UserMigration/ISizeEstimationMigrator.php b/lib/public/UserMigration/ISizeEstimationMigrator.php new file mode 100644 index 00000000000..05abe48ea8f --- /dev/null +++ b/lib/public/UserMigration/ISizeEstimationMigrator.php @@ -0,0 +1,43 @@ +<?php + +declare(strict_types=1); + +/** + * @copyright 2022 Christopher Ng <chrng8@gmail.com> + * + * @author Christopher Ng <chrng8@gmail.com> + * @author Côme Chilliet <come.chilliet@nextcloud.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCP\UserMigration; + +use OCP\IUser; + +/** + * @since 25.0.0 + */ +interface ISizeEstimationMigrator { + /** + * Returns an estimate of the exported data size in KiB. + * Should be fast, favor performance over accuracy. + * + * @since 25.0.0 + */ + public function getEstimatedExportSize(IUser $user): int; +} diff --git a/lib/public/UserStatus/IUserStatus.php b/lib/public/UserStatus/IUserStatus.php index bf743dea08d..8803b328ad5 100644 --- a/lib/public/UserStatus/IUserStatus.php +++ b/lib/public/UserStatus/IUserStatus.php @@ -65,6 +65,18 @@ interface IUserStatus { public const INVISIBLE = 'invisible'; /** + * @var string + * @since 25.0.0 + */ + public const MESSAGE_CALL = 'call'; + + /** + * @var string + * @since 25.0.0 + */ + public const MESSAGE_AVAILABILITY = 'availability'; + + /** * Get the user this status is connected to * * @return string |