/** * Submit task notification message * @param Task $task * @param string $action * @param null|User $relatedUser, the user associated with the task notification. In case of * @param null|Comment $comment * owner change it would be previous owner, in case of comment, it would be the user * making the comment */ public static function submitTaskNotificationMessage(Task $task, $action, User $relatedUser = null, Comment $comment = null) { assert('is_string($action)'); $message = static::getNotificationMessageByAction($task, $action, $relatedUser, $comment); $rule = new TaskNotificationRules(); $peopleToSendNotification = static::resolvePeopleToSendNotification($task, $action, $relatedUser); foreach ($peopleToSendNotification as $person) { $rule->addUser($person); } $rule->setModel($task); $rule->setCritical(true); $rule->setAllowDuplicates(true); static::processTaskNotification($message, $rule, $action); }