diff options
author | Joas Schilling <coding@schilljs.com> | 2018-01-05 12:17:56 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-01-05 12:17:56 +0300 |
commit | f5cc6cc1140ffe29029103283dcc466b4f54d563 (patch) | |
tree | f12d749f5b85083001efec66b063a4fd893d6023 | |
parent | 693a5ab0f2661c8eeb70b663eb12b97f741095c7 (diff) |
First check the UID before using it
Signed-off-by: Joas Schilling <coding@schilljs.com>
-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); } |