2013-09-20 10:37:52 -04:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2019-01-24 10:52:38 -05:00
|
|
|
declare(strict_types=1);
|
2013-11-03 07:51:39 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2013-09-20 10:37:52 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCP\Activity;
|
|
|
|
|
|
2024-04-17 09:29:33 -04:00
|
|
|
use OCP\Activity\Exceptions\FilterNotFoundException;
|
2024-04-17 07:13:10 -04:00
|
|
|
use OCP\Activity\Exceptions\IncompleteActivityException;
|
2024-04-17 09:29:33 -04:00
|
|
|
use OCP\Activity\Exceptions\SettingNotFoundException;
|
2024-04-17 07:13:10 -04:00
|
|
|
|
2015-04-16 11:00:08 -04:00
|
|
|
/**
|
|
|
|
|
* Interface IManager
|
|
|
|
|
*
|
|
|
|
|
* @since 6.0.0
|
|
|
|
|
*/
|
2013-09-20 10:37:52 -04:00
|
|
|
interface IManager {
|
2015-08-19 11:37:55 -04:00
|
|
|
/**
|
2015-08-20 09:35:24 -04:00
|
|
|
* Generates a new IEvent object
|
|
|
|
|
*
|
|
|
|
|
* Make sure to call at least the following methods before sending it to the
|
|
|
|
|
* app with via the publish() method:
|
|
|
|
|
* - setApp()
|
|
|
|
|
* - setType()
|
|
|
|
|
* - setAffectedUser()
|
|
|
|
|
* - setSubject()
|
2020-09-15 04:22:54 -04:00
|
|
|
* - setObject()
|
2015-08-20 09:35:24 -04:00
|
|
|
*
|
2015-08-19 11:37:55 -04:00
|
|
|
* @return IEvent
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function generateEvent(): IEvent;
|
2015-08-19 11:37:55 -04:00
|
|
|
|
|
|
|
|
/**
|
2015-08-20 09:35:24 -04:00
|
|
|
* Publish an event to the activity consumers
|
|
|
|
|
*
|
|
|
|
|
* Make sure to call at least the following methods before sending an Event:
|
|
|
|
|
* - setApp()
|
|
|
|
|
* - setType()
|
|
|
|
|
* - setAffectedUser()
|
|
|
|
|
* - setSubject()
|
2020-09-15 04:22:54 -04:00
|
|
|
* - setObject()
|
2015-08-20 09:35:24 -04:00
|
|
|
*
|
2015-08-19 11:37:55 -04:00
|
|
|
* @param IEvent $event
|
2024-04-17 07:13:10 -04:00
|
|
|
* @throws IncompleteActivityException if required values have not been set
|
2015-08-19 11:37:55 -04:00
|
|
|
* @since 8.2.0
|
2024-04-17 07:13:10 -04:00
|
|
|
* @since 30.0.0 throws {@see IncompleteActivityException} instead of \BadMethodCallException
|
2015-08-19 11:37:55 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function publish(IEvent $event): void;
|
2013-09-20 10:37:52 -04:00
|
|
|
|
2025-07-28 10:11:21 -04:00
|
|
|
/**
|
|
|
|
|
* Bulk publish an event for multiple users
|
|
|
|
|
* taking into account the app specific activity settings
|
|
|
|
|
*
|
|
|
|
|
* Make sure to call at least the following methods before sending an Event:
|
|
|
|
|
* - setApp()
|
|
|
|
|
* - setType()
|
|
|
|
|
*
|
|
|
|
|
* @param IEvent $event
|
|
|
|
|
* @throws IncompleteActivityException if required values have not been set
|
|
|
|
|
* @since 32.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void;
|
|
|
|
|
|
2013-09-20 10:37:52 -04:00
|
|
|
/**
|
|
|
|
|
* In order to improve lazy loading a closure can be registered which will be called in case
|
|
|
|
|
* activity consumers are actually requested
|
|
|
|
|
*
|
2014-07-03 07:48:15 -04:00
|
|
|
* $callable has to return an instance of \OCP\Activity\IConsumer
|
2013-09-20 10:37:52 -04:00
|
|
|
*
|
|
|
|
|
* @param \Closure $callable
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 6.0.0
|
2013-09-20 10:37:52 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function registerConsumer(\Closure $callable): void;
|
2014-07-03 07:48:15 -04:00
|
|
|
|
2016-10-20 11:57:44 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $filter Class must implement OCA\Activity\IFilter
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-10-20 11:57:44 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function registerFilter(string $filter): void;
|
2016-10-20 11:57:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return IFilter[]
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-10-20 11:57:44 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getFilters(): array;
|
2016-10-20 11:57:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $id
|
|
|
|
|
* @return IFilter
|
2024-04-17 09:29:33 -04:00
|
|
|
* @throws FilterNotFoundException when the filter was not found
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2024-04-17 09:29:33 -04:00
|
|
|
* @since 30.0.0 throws {@see FilterNotFoundException} instead of \InvalidArgumentException
|
2016-10-20 11:57:44 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getFilterById(string $id): IFilter;
|
2016-10-20 11:57:44 -04:00
|
|
|
|
2016-10-25 12:00:25 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $setting Class must implement OCA\Activity\ISetting
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-10-25 12:00:25 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function registerSetting(string $setting): void;
|
2016-10-25 12:00:25 -04:00
|
|
|
|
|
|
|
|
/**
|
2020-06-15 09:01:52 -04:00
|
|
|
* @return ActivitySettings[]
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-10-25 12:00:25 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getSettings(): array;
|
2016-10-25 12:00:25 -04:00
|
|
|
|
2016-11-04 06:33:33 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $provider Class must implement OCA\Activity\IProvider
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-11-04 06:33:33 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function registerProvider(string $provider): void;
|
2016-11-04 06:33:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return IProvider[]
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2016-11-04 06:33:33 -04:00
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getProviders(): array;
|
2016-11-04 06:33:33 -04:00
|
|
|
|
2016-10-25 12:00:25 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $id
|
2020-06-15 09:01:52 -04:00
|
|
|
* @return ActivitySettings
|
2024-04-17 09:29:33 -04:00
|
|
|
* @throws SettingNotFoundException when the setting was not found
|
2016-11-16 03:29:27 -05:00
|
|
|
* @since 11.0.0
|
2024-04-17 09:29:33 -04:00
|
|
|
* @since 30.0.0 throws {@see SettingNotFoundException} instead of \InvalidArgumentException
|
2016-10-25 12:00:25 -04:00
|
|
|
*/
|
2020-06-15 09:01:52 -04:00
|
|
|
public function getSettingById(string $id): ActivitySettings;
|
2014-07-03 07:48:15 -04:00
|
|
|
|
2015-10-02 03:53:39 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @param int $id
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function setFormattingObject(string $type, int $id): void;
|
2015-10-02 03:53:39 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function isFormattingFilteredObject(): bool;
|
2015-10-02 03:53:39 -04:00
|
|
|
|
2017-06-20 06:40:45 -04:00
|
|
|
/**
|
|
|
|
|
* @param bool $status Set to true, when parsing events should not use SVG icons
|
|
|
|
|
* @since 12.0.1
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function setRequirePNG(bool $status): void;
|
2017-06-20 06:40:45 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
* @since 12.0.1
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getRequirePNG(): bool;
|
2016-10-20 11:57:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the user we need to use
|
|
|
|
|
*
|
|
|
|
|
* @param string|null $currentUserId
|
|
|
|
|
* @since 9.0.1
|
|
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
public function setCurrentUserId(?string $currentUserId = null): void;
|
2016-10-20 11:57:44 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the user we need to use
|
|
|
|
|
*
|
|
|
|
|
* Either the user is logged in, or we try to get it from the token
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
|
|
|
|
* @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
|
|
|
|
|
* @since 8.1.0
|
|
|
|
|
*/
|
2019-01-24 10:52:38 -05:00
|
|
|
public function getCurrentUserId(): string;
|
2013-09-20 10:37:52 -04:00
|
|
|
}
|