summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Activity/Manager.php30
-rw-r--r--lib/private/Server.php7
-rw-r--r--lib/public/Activity/IManager.php2
3 files changed, 24 insertions, 15 deletions
diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php
index 04a8dd96a45..c4f3d348dbe 100644
--- a/lib/private/Activity/Manager.php
+++ b/lib/private/Activity/Manager.php
@@ -24,7 +24,6 @@
namespace OC\Activity;
-use OC\RichObjectStrings\Validator;
use OCP\Activity\IConsumer;
use OCP\Activity\IEvent;
use OCP\Activity\IExtension;
@@ -36,6 +35,7 @@ use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserSession;
+use OCP\RichObjectStrings\IValidator;
class Manager implements IManager {
/** @var IRequest */
@@ -47,6 +47,9 @@ class Manager implements IManager {
/** @var IConfig */
protected $config;
+ /** @var IValidator */
+ protected $validator;
+
/** @var string */
protected $formattingObjectType;
@@ -62,13 +65,16 @@ class Manager implements IManager {
* @param IRequest $request
* @param IUserSession $session
* @param IConfig $config
+ * @param IValidator $validator
*/
public function __construct(IRequest $request,
IUserSession $session,
- IConfig $config) {
+ IConfig $config,
+ IValidator $validator) {
$this->request = $request;
$this->session = $session;
$this->config = $config;
+ $this->validator = $validator;
}
/** @var \Closure[] */
@@ -151,9 +157,7 @@ class Manager implements IManager {
* @return IEvent
*/
public function generateEvent() {
- return new Event(
- new Validator()
- );
+ return new Event($this->validator);
}
/**
@@ -166,12 +170,18 @@ class Manager implements IManager {
* - setSubject()
*
* @param IEvent $event
- * @return null
* @throws \BadMethodCallException if required values have not been set
*/
public function publish(IEvent $event) {
+ $this->publishToConsumers($event, false);
+ }
- if ($event->getAuthor() === null) {
+ /**
+ * @param IEvent $event
+ * @param bool $legacyActivity
+ */
+ protected function publishToConsumers(IEvent $event, $legacyActivity) {
+ if ($event->getAuthor() === '') {
if ($this->session->getUser() instanceof IUser) {
$event->setAuthor($this->session->getUser()->getUID());
}
@@ -181,7 +191,7 @@ class Manager implements IManager {
$event->setTimestamp(time());
}
- if (!$event->isValid()) {
+ if (!$legacyActivity && !$event->isValid()) {
throw new \BadMethodCallException('The given event is invalid');
}
@@ -201,7 +211,6 @@ class Manager implements IManager {
* @param string $affectedUser Recipient of the activity
* @param string $type Type of the notification
* @param int $priority Priority of the notification
- * @return null
*/
public function publishActivity($app, $subject, $subjectParams, $message, $messageParams, $file, $link, $affectedUser, $type, $priority) {
$event = $this->generateEvent();
@@ -213,7 +222,7 @@ class Manager implements IManager {
->setObject('', 0, $file)
->setLink($link);
- $this->publish($event);
+ $this->publishToConsumers($event, true);
}
/**
@@ -236,7 +245,6 @@ class Manager implements IManager {
* $callable has to return an instance of OCA\Activity\IExtension
*
* @param \Closure $callable
- * @return void
*/
public function registerExtension(\Closure $callable) {
array_push($this->extensionsClosures, $callable);
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 8e41ba212ad..abedf8230ed 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -90,6 +90,7 @@ use OC\Tagging\TagMapper;
use OCA\Theming\ThemingDefaults;
use OCP\IL10N;
use OCP\IServerContainer;
+use OCP\RichObjectStrings\IValidator;
use OCP\Security\IContentSecurityPolicyManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -394,9 +395,11 @@ class Server extends ServerContainer implements IServerContainer {
return new \OC\Activity\Manager(
$c->getRequest(),
$c->getUserSession(),
- $c->getConfig()
+ $c->getConfig(),
+ $c->query(IValidator::class)
);
});
+ $this->registerAlias(IValidator::class, Validator::class);
$this->registerService('AvatarManager', function (Server $c) {
return new AvatarManager(
$c->getUserManager(),
@@ -662,7 +665,7 @@ class Server extends ServerContainer implements IServerContainer {
});
$this->registerService('NotificationManager', function (Server $c) {
return new Manager(
- $c->query(Validator::class)
+ $c->query(IValidator::class)
);
});
$this->registerService('CapabilitiesManager', function (Server $c) {
diff --git a/lib/public/Activity/IManager.php b/lib/public/Activity/IManager.php
index 48071729ed1..abad12f15f0 100644
--- a/lib/public/Activity/IManager.php
+++ b/lib/public/Activity/IManager.php
@@ -64,7 +64,6 @@ interface IManager {
* - setSubject()
*
* @param IEvent $event
- * @return null
* @since 8.2.0
*/
public function publish(IEvent $event);
@@ -80,7 +79,6 @@ interface IManager {
* @param string $affectedUser Recipient of the activity
* @param string $type Type of the notification
* @param int $priority Priority of the notification
- * @return null
* @since 6.0.0
* @deprecated 8.2.0 Grab an IEvent from generateEvent() instead and use the publish() method
*/