Skip to content

Commit

Permalink
Merge pull request #540 from nextcloud/follow/524/make-code-order-mor…
Browse files Browse the repository at this point in the history
…e-logical

First check the UID before using it
  • Loading branch information
nickvergessen authored Jan 5, 2018
2 parents b156e03 + f5cc6cc commit 6311164
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/ContactsMenu/Providers/CallProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;

class CallProvider implements IProvider {
Expand Down Expand Up @@ -63,12 +64,6 @@ public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGen
*/
public function process(IEntry $entry) {
$uid = $entry->getProperty('UID');
$user = $this->userManager->get($uid);
$talkAction = $this->l10n->t('Talk');

if ($user !== null) {
$talkAction = $this->l10n->t('Talk to %s', [$user->getDisplayName()]);
}

if ($uid === null) {
// Nothing to do
Expand All @@ -80,8 +75,15 @@ public function process(IEntry $entry) {
return;
}

$user = $this->userManager->get($uid);
$talkAction = $this->l10n->t('Talk');

if ($user instanceof IUser) {
$talkAction = $this->l10n->t('Talk to %s', [$user->getDisplayName()]);
}

$iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('spreed', 'app-dark.svg'));
$callUrl = $this->urlGenerator->linkToRouteAbsolute('spreed.Page.index') . '?callUser=' . $uid;
$callUrl = $this->urlGenerator->linkToRouteAbsolute('spreed.Page.index') . '?callUser=' . $user->getUID();
$action = $this->actionFactory->newLinkAction($iconUrl, $talkAction, $callUrl);
$entry->addAction($action);
}
Expand Down

0 comments on commit 6311164

Please sign in to comment.