diff options
author | Joas Schilling <coding@schilljs.com> | 2018-01-05 12:51:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-05 12:51:06 +0300 |
commit | 63111646f5d8373870cb3526ae0472126ddccd28 (patch) | |
tree | 49c329354bccc04673ab3b7deef09741fe68c8f2 | |
parent | b156e03f23d64c0616b22f2c7bd47886f967e9ba (diff) | |
parent | f5cc6cc1140ffe29029103283dcc466b4f54d563 (diff) |
Merge pull request #540 from nextcloud/follow/524/make-code-order-more-logicalv2.9.1
First check the UID before using it
-rw-r--r-- | lib/ContactsMenu/Providers/CallProvider.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/ContactsMenu/Providers/CallProvider.php b/lib/ContactsMenu/Providers/CallProvider.php index 54b590928..08df2cf41 100644 --- a/lib/ContactsMenu/Providers/CallProvider.php +++ b/lib/ContactsMenu/Providers/CallProvider.php @@ -29,6 +29,7 @@ use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IProvider; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserManager; class CallProvider implements IProvider { @@ -63,12 +64,6 @@ class CallProvider implements IProvider { */ 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 @@ -80,8 +75,15 @@ class CallProvider implements IProvider { 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); } |