Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
More buttons
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Jul 18, 2019
commit ebf7781e240e03afbd3c12f5301e756bcb764765
21 changes: 14 additions & 7 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,20 @@ protected function parseChatMessage(INotification $notification, Room $room, Par

$messageParameters = $notification->getMessageParameters();
if (!isset($messageParameters['commentId'])) {
throw new \InvalidArgumentException('Unknown comment');
throw new AlreadyProcessedException();
}

try {
$comment = $this->commentManager->get($messageParameters['commentId']);
} catch (NotFoundException $e) {
throw new \InvalidArgumentException('Unknown comment');
throw new AlreadyProcessedException();
}

$message = $this->messageParser->createMessage($room, $participant, $comment, $l);
$this->messageParser->parseMessage($message);

if (!$message->getVisibility()) {
throw new \InvalidArgumentException('Invisible comment');
throw new AlreadyProcessedException();
}

$placeholders = $replacements = [];
Expand Down Expand Up @@ -271,6 +271,7 @@ protected function parseChatMessage(INotification $notification, Room $room, Par
$subject = $l->t('A guest mentioned you in conversation {call}');
}
}
$notification = $this->addActionButton($notification, $l->t('View chat'), false);

if ($richSubjectParameters['user'] === null) {
unset($richSubjectParameters['user']);
Expand Down Expand Up @@ -332,6 +333,8 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
$subject = $l->t('{user} invited you to a private conversation');
if ($room->hasSessionsInCall()) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
}

$notification
Expand All @@ -356,6 +359,8 @@ protected function parseInvitation(INotification $notification, Room $room, IL10
$subject = $l->t('{user} invited you to a group conversation: {call}');
if ($room->hasSessionsInCall()) {
$notification = $this->addActionButton($notification, $l->t('Join call'));
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
}

$notification
Expand Down Expand Up @@ -405,6 +410,7 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
$notification = $this->addActionButton($notification, $l->t('Answer call'));
$subject = $l->t('{user} wants to talk with you');
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
$subject = $l->t('You missed a call from {user}');
}

Expand Down Expand Up @@ -434,6 +440,7 @@ protected function parseCall(INotification $notification, Room $room, IL10N $l):
$notification = $this->addActionButton($notification, $l->t('Join call'));
$subject = $l->t('A group call has started in {call}');
} else {
$notification = $this->addActionButton($notification, $l->t('View chat'), false);
$subject = $l->t('You missed a group call in {call}');
}

Expand Down Expand Up @@ -489,6 +496,8 @@ protected function parsePasswordRequest(INotification $notification, Room $room,
$callIsActive = $room->hasSessionsInCall();
if ($callIsActive) {
$notification = $this->addActionButton($notification, $l->t('Answer call'));
} else {
$notification = $this->addActionButton($notification, $l->t('Call back'));
}

if ($share->getShareType() === Share::SHARE_TYPE_EMAIL) {
Expand Down Expand Up @@ -522,17 +531,15 @@ protected function parsePasswordRequest(INotification $notification, Room $room,
->setRichSubject($subject, ['file' => $file]);
}

$notification = $this->addActionButton($notification, $l->t('Answer call'));

return $notification;
}

protected function addActionButton(INotification $notification, string $label): INotification {
protected function addActionButton(INotification $notification, string $label, bool $primary = true): INotification {
$action = $notification->createAction();
$action->setLabel($label)
->setParsedLabel($label)
->setLink($notification->getLink(), IAction::TYPE_WEB)
->setPrimary(true);
->setPrimary($primary);

$notification->addParsedAction($action);

Expand Down