summaryrefslogtreecommitdiffstats
path: root/lib/private/activitymanager.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2016-03-24 09:33:00 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2016-03-24 09:36:44 +0100
commitc0858f42aac8bf15f01bb5ffed2c4c6301f42424 (patch)
tree330e5d41c7d6f5f9c61555da7c524f703dfca10a /lib/private/activitymanager.php
parentdad98542a5a5b8df5b63074f0edea69008169f60 (diff)
downloadnextcloud-server-c0858f42aac8bf15f01bb5ffed2c4c6301f42424.tar.gz
nextcloud-server-c0858f42aac8bf15f01bb5ffed2c4c6301f42424.zip
Allow the activity app to set the current user when sending emails
Diffstat (limited to 'lib/private/activitymanager.php')
-rw-r--r--lib/private/activitymanager.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php
index 373105291dd..e522dca9e3b 100644
--- a/lib/private/activitymanager.php
+++ b/lib/private/activitymanager.php
@@ -49,6 +49,9 @@ class ActivityManager implements IManager {
/** @var int */
protected $formattingObjectId;
+ /** @var string */
+ protected $currentUserId;
+
/**
* constructor of the controller
*
@@ -476,6 +479,19 @@ class ActivityManager implements IManager {
}
/**
+ * Set the user we need to use
+ *
+ * @param string|null $currentUserId
+ * @throws \UnexpectedValueException If the user is invalid
+ */
+ public function setCurrentUserId($currentUserId) {
+ if (!is_string($currentUserId) && $currentUserId !== null) {
+ throw new \UnexpectedValueException('The given current user is invalid');
+ }
+ $this->currentUserId = $currentUserId;
+ }
+
+ /**
* Get the user we need to use
*
* Either the user is logged in, or we try to get it from the token
@@ -484,7 +500,9 @@ class ActivityManager implements IManager {
* @throws \UnexpectedValueException If the token is invalid, does not exist or is not unique
*/
public function getCurrentUserId() {
- if (!$this->session->isLoggedIn()) {
+ if ($this->currentUserId !== null) {
+ return $this->currentUserId;
+ } else if (!$this->session->isLoggedIn()) {
return $this->getUserFromToken();
} else {
return $this->session->getUser()->getUID();