From 2abc7dda9294a133cab9ccfffe9437e150c32545 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 27 Nov 2019 17:23:17 +0100 Subject: [PATCH] show a nice message, if the entity offers one Signed-off-by: Arthur Schiwon --- lib/Flow/Operation.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index 013f315efe8..c43edb462e7 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -36,6 +36,7 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; +use OCP\WorkflowEngine\EntityContext\IDisplayText; use OCP\WorkflowEngine\IManager as FlowManager; use OCP\WorkflowEngine\IOperation; use OCP\WorkflowEngine\IRuleMatcher; @@ -121,6 +122,15 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch $uid = $flow['scope_actor_id']; $this->validateOperationConfig($mode, $token, $uid); + $entity = $ruleMatcher->getEntity(); + + $message = $eventName; + if($entity instanceof IDisplayText) { + $message = $entity->getDisplayText(3); + if($message === '') { + continue; + } + } $room = $this->getRoom($token, $uid); $participant = $this->getParticipant($uid, $room); @@ -129,7 +139,7 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch $participant, 'bots', $participant->getUser(), - $this->prepareMention($mode, $participant) . 'MESSAGE TODO', + $this->prepareMention($mode, $participant) . $message, new \DateTime(), null );