Skip to content

Commit

Permalink
take a URL into consideration, if the entity provides one
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz committed Nov 29, 2019
1 parent df7840d commit 54359ca
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions lib/Flow/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
use OCP\IUser;
use OCP\IUserSession;
use OCP\WorkflowEngine\EntityContext\IDisplayText;
use OCP\WorkflowEngine\EntityContext\IUrl;
use OCP\WorkflowEngine\IEntity;
use OCP\WorkflowEngine\IManager as FlowManager;
use OCP\WorkflowEngine\IOperation;
use OCP\WorkflowEngine\IRuleMatcher;
Expand Down Expand Up @@ -124,12 +126,9 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch

$entity = $ruleMatcher->getEntity();

$message = $eventName;
if($entity instanceof IDisplayText) {
$message = $entity->getDisplayText(3);
if($message === '') {
continue;
}
$message = $this->prepareText($entity, $eventName);
if($message === '') {
continue;
}

$room = $this->getRoom($token, $uid);
Expand All @@ -153,6 +152,17 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch
}
}

protected function prepareText(IEntity $entity, string $eventName) {
$message = $eventName;
if($entity instanceof IDisplayText) {
$message = trim($entity->getDisplayText(3));
}
if($entity instanceof IUrl && $message !== '') {
$message .= ' ' . $entity->getUrl();
}
return $message;
}

/**
* returns a mention including a trailing whitespace, or an empty string
*/
Expand Down

0 comments on commit 54359ca

Please sign in to comment.