Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Service/MailService.php')
-rw-r--r--lib/Service/MailService.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php
index 54fe8a34..2456fb84 100644
--- a/lib/Service/MailService.php
+++ b/lib/Service/MailService.php
@@ -156,6 +156,32 @@ class MailService {
}
+
+ /**
+ * @param integer $pollId
+ * @param string $userId
+ * @return string
+ */
+ public function resolveEmailAddress($pollId, $userId) {
+ $contactsManager = \OC::$server->getContactsManager();
+
+ if ($this->userManager->get($userId) instanceof IUser) {
+ return \OC::$server->getConfig()->getUserValue($userId, 'settings', 'email');
+ }
+
+ // if $userId is no site user, eval via shares
+ try {
+ $share = $this->shareMapper->findByPollAndUser($pollId, $userId);
+ if ($share->getUserEmail()) {
+ return $share->getUserEmail();
+ }
+ } catch (\Exception $e) {
+ // catch silently
+ }
+ return $userId;
+ }
+
+
/**
* @param Share $share
* @param String $defaultLang
@@ -219,7 +245,7 @@ class MailService {
return;
}
- } elseif ($share->getType() === 'external' || $share->getType() === 'email') {
+ } elseif ($share->getType() === 'external') {
$recipients[] = array(
'userId' => $share->getUserId(),
'eMailAddress' => $share->getUserEmail(),
@@ -341,6 +367,7 @@ class MailService {
if ($this->userManager->get($subscription->getUserId()) instanceof IUser) {
$lang = $this->config->getUserValue($subscription->getUserId(), 'core', 'lang');
} else {
+ $lang = $this->config->getUserValue($poll->getOwner(), 'core', 'lang');
continue;
}