|
|
|
@ -28,6 +28,7 @@ declare(strict_types=1);
|
|
|
|
|
*/
|
|
|
|
|
namespace OC\Activity;
|
|
|
|
|
|
|
|
|
|
use OCP\Activity\Exceptions\InvalidValueException;
|
|
|
|
|
use OCP\Activity\IEvent;
|
|
|
|
|
use OCP\RichObjectStrings\InvalidObjectExeption;
|
|
|
|
|
use OCP\RichObjectStrings\IValidator;
|
|
|
|
@ -89,16 +90,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the app of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $app
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the app id is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setApp(string $app): IEvent {
|
|
|
|
|
if ($app === '' || isset($app[32])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given app is invalid');
|
|
|
|
|
throw new InvalidValueException('app');
|
|
|
|
|
}
|
|
|
|
|
$this->app = $app;
|
|
|
|
|
return $this;
|
|
|
|
@ -112,16 +108,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the type of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $type
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the type is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setType(string $type): IEvent {
|
|
|
|
|
if ($type === '' || isset($type[255])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given type is invalid');
|
|
|
|
|
throw new InvalidValueException('type');
|
|
|
|
|
}
|
|
|
|
|
$this->type = $type;
|
|
|
|
|
return $this;
|
|
|
|
@ -135,16 +126,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the affected user of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $affectedUser
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the affected user is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setAffectedUser(string $affectedUser): IEvent {
|
|
|
|
|
if ($affectedUser === '' || isset($affectedUser[64])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given affected user is invalid');
|
|
|
|
|
throw new InvalidValueException('affectedUser');
|
|
|
|
|
}
|
|
|
|
|
$this->affectedUser = $affectedUser;
|
|
|
|
|
return $this;
|
|
|
|
@ -158,16 +144,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the author of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $author
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the author is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setAuthor(string $author): IEvent {
|
|
|
|
|
if (isset($author[64])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given author user is invalid');
|
|
|
|
|
throw new InvalidValueException('author');
|
|
|
|
|
}
|
|
|
|
|
$this->author = $author;
|
|
|
|
|
return $this;
|
|
|
|
@ -181,14 +162,12 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the timestamp of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param int $timestamp
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the timestamp is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setTimestamp(int $timestamp): IEvent {
|
|
|
|
|
if ($timestamp < 0) {
|
|
|
|
|
throw new InvalidValueException('timestamp');
|
|
|
|
|
}
|
|
|
|
|
$this->timestamp = $timestamp;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
@ -201,17 +180,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the subject of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $subject
|
|
|
|
|
* @param array $parameters
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the subject or parameters are invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setSubject(string $subject, array $parameters = []): IEvent {
|
|
|
|
|
if (isset($subject[255])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given subject is invalid');
|
|
|
|
|
throw new InvalidValueException('subject');
|
|
|
|
|
}
|
|
|
|
|
$this->subject = $subject;
|
|
|
|
|
$this->subjectParameters = $parameters;
|
|
|
|
@ -233,14 +206,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $subject
|
|
|
|
|
* @return $this
|
|
|
|
|
* @throws \InvalidArgumentException if the subject is invalid
|
|
|
|
|
* @since 11.0.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setParsedSubject(string $subject): IEvent {
|
|
|
|
|
if ($subject === '') {
|
|
|
|
|
throw new \InvalidArgumentException('The given parsed subject is invalid');
|
|
|
|
|
throw new InvalidValueException('parsedSubject');
|
|
|
|
|
}
|
|
|
|
|
$this->subjectParsed = $subject;
|
|
|
|
|
return $this;
|
|
|
|
@ -255,21 +225,21 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $subject
|
|
|
|
|
* @param array $parameters
|
|
|
|
|
* @return $this
|
|
|
|
|
* @throws \InvalidArgumentException if the subject or parameters are invalid
|
|
|
|
|
* @since 11.0.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setRichSubject(string $subject, array $parameters = []): IEvent {
|
|
|
|
|
if ($subject === '') {
|
|
|
|
|
throw new \InvalidArgumentException('The given parsed subject is invalid');
|
|
|
|
|
throw new InvalidValueException('richSubject');
|
|
|
|
|
}
|
|
|
|
|
$this->subjectRich = $subject;
|
|
|
|
|
$this->subjectRichParameters = $parameters;
|
|
|
|
|
|
|
|
|
|
if ($this->subjectParsed === '') {
|
|
|
|
|
$this->subjectParsed = $this->richToParsed($subject, $parameters);
|
|
|
|
|
try {
|
|
|
|
|
$this->subjectParsed = $this->richToParsed($subject, $parameters);
|
|
|
|
|
} catch (\InvalidArgumentException $e) {
|
|
|
|
|
throw new InvalidValueException('richSubjectParameters', $e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
@ -316,17 +286,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the message of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @param array $parameters
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the message or parameters are invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setMessage(string $message, array $parameters = []): IEvent {
|
|
|
|
|
if (isset($message[255])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given message is invalid');
|
|
|
|
|
throw new InvalidValueException('message');
|
|
|
|
|
}
|
|
|
|
|
$this->message = $message;
|
|
|
|
|
$this->messageParameters = $parameters;
|
|
|
|
@ -348,10 +312,7 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @return $this
|
|
|
|
|
* @throws \InvalidArgumentException if the message is invalid
|
|
|
|
|
* @since 11.0.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setParsedMessage(string $message): IEvent {
|
|
|
|
|
$this->messageParsed = $message;
|
|
|
|
@ -367,18 +328,18 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $message
|
|
|
|
|
* @param array $parameters
|
|
|
|
|
* @return $this
|
|
|
|
|
* @throws \InvalidArgumentException if the subject or parameters are invalid
|
|
|
|
|
* @since 11.0.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setRichMessage(string $message, array $parameters = []): IEvent {
|
|
|
|
|
$this->messageRich = $message;
|
|
|
|
|
$this->messageRichParameters = $parameters;
|
|
|
|
|
|
|
|
|
|
if ($this->messageParsed === '') {
|
|
|
|
|
$this->messageParsed = $this->richToParsed($message, $parameters);
|
|
|
|
|
try {
|
|
|
|
|
$this->messageParsed = $this->richToParsed($message, $parameters);
|
|
|
|
|
} catch (\InvalidArgumentException $e) {
|
|
|
|
|
throw new InvalidValueException('richMessageParameters', $e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
@ -401,21 +362,14 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the object of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $objectType
|
|
|
|
|
* @param int $objectId
|
|
|
|
|
* @param string $objectName
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the object is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setObject(string $objectType, int $objectId, string $objectName = ''): IEvent {
|
|
|
|
|
if (isset($objectType[255])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given object type is invalid');
|
|
|
|
|
throw new InvalidValueException('objectType');
|
|
|
|
|
}
|
|
|
|
|
if (isset($objectName[4000])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given object name is invalid');
|
|
|
|
|
throw new InvalidValueException('objectName');
|
|
|
|
|
}
|
|
|
|
|
$this->objectType = $objectType;
|
|
|
|
|
$this->objectId = $objectId;
|
|
|
|
@ -445,16 +399,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the link of the activity
|
|
|
|
|
*
|
|
|
|
|
* @param string $link
|
|
|
|
|
* @return IEvent
|
|
|
|
|
* @throws \InvalidArgumentException if the link is invalid
|
|
|
|
|
* @since 8.2.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setLink(string $link): IEvent {
|
|
|
|
|
if (isset($link[4000])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given link is invalid');
|
|
|
|
|
throw new InvalidValueException('link');
|
|
|
|
|
}
|
|
|
|
|
$this->link = $link;
|
|
|
|
|
return $this;
|
|
|
|
@ -468,14 +417,11 @@ class Event implements IEvent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $icon
|
|
|
|
|
* @return $this
|
|
|
|
|
* @throws \InvalidArgumentException if the icon is invalid
|
|
|
|
|
* @since 11.0.0
|
|
|
|
|
* {@inheritDoc}
|
|
|
|
|
*/
|
|
|
|
|
public function setIcon(string $icon): IEvent {
|
|
|
|
|
if (isset($icon[4000])) {
|
|
|
|
|
throw new \InvalidArgumentException('The given icon is invalid');
|
|
|
|
|
throw new InvalidValueException('icon');
|
|
|
|
|
}
|
|
|
|
|
$this->icon = $icon;
|
|
|
|
|
return $this;
|
|
|
|
|