|
|
|
|
@ -11,12 +11,14 @@ use OCP\Activity\ActivitySettings;
|
|
|
|
|
use OCP\Activity\Exceptions\FilterNotFoundException;
|
|
|
|
|
use OCP\Activity\Exceptions\IncompleteActivityException;
|
|
|
|
|
use OCP\Activity\Exceptions\SettingNotFoundException;
|
|
|
|
|
use OCP\Activity\IBulkConsumer;
|
|
|
|
|
use OCP\Activity\IConsumer;
|
|
|
|
|
use OCP\Activity\IEvent;
|
|
|
|
|
use OCP\Activity\IFilter;
|
|
|
|
|
use OCP\Activity\IManager;
|
|
|
|
|
use OCP\Activity\IProvider;
|
|
|
|
|
use OCP\Activity\ISetting;
|
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\IL10N;
|
|
|
|
|
use OCP\IRequest;
|
|
|
|
|
@ -46,6 +48,7 @@ class Manager implements IManager {
|
|
|
|
|
protected IValidator $validator,
|
|
|
|
|
protected IRichTextFormatter $richTextFormatter,
|
|
|
|
|
protected IL10N $l10n,
|
|
|
|
|
protected ITimeFactory $timeFactory,
|
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -96,6 +99,31 @@ class Manager implements IManager {
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function publish(IEvent $event): void {
|
|
|
|
|
if ($event->getAuthor() === '' && $this->session->getUser() instanceof IUser) {
|
|
|
|
|
$event->setAuthor($this->session->getUser()->getUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$event->getTimestamp()) {
|
|
|
|
|
$event->setTimestamp($this->timeFactory->getTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($event->getAffectedUser() === '' || !$event->isValid()) {
|
|
|
|
|
throw new IncompleteActivityException('The given event is invalid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($this->getConsumers() as $c) {
|
|
|
|
|
$c->receive($event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function bulkPublish(IEvent $event, array $affectedUserIds, ISetting $setting): void {
|
|
|
|
|
if (empty($affectedUserIds)) {
|
|
|
|
|
throw new IncompleteActivityException('The given event is invalid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($event->getAuthor() === '') {
|
|
|
|
|
if ($this->session->getUser() instanceof IUser) {
|
|
|
|
|
$event->setAuthor($this->session->getUser()->getUID());
|
|
|
|
|
@ -103,7 +131,7 @@ class Manager implements IManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$event->getTimestamp()) {
|
|
|
|
|
$event->setTimestamp(time());
|
|
|
|
|
$event->setTimestamp($this->timeFactory->getTime());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$event->isValid()) {
|
|
|
|
|
@ -111,10 +139,17 @@ class Manager implements IManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($this->getConsumers() as $c) {
|
|
|
|
|
$c->receive($event);
|
|
|
|
|
if ($c instanceof IBulkConsumer) {
|
|
|
|
|
$c->bulkReceive($event, $affectedUserIds, $setting);
|
|
|
|
|
}
|
|
|
|
|
foreach ($affectedUserIds as $affectedUserId) {
|
|
|
|
|
$event->setAffectedUser($affectedUserId);
|
|
|
|
|
$c->receive($event);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* In order to improve lazy loading a closure can be registered which will be called in case
|
|
|
|
|
* activity consumers are actually requested
|
|
|
|
|
|