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:
authordartcafe <github@dartcafe.de>2020-06-22 21:43:42 +0300
committerdartcafe <github@dartcafe.de>2020-06-22 21:43:42 +0300
commit17c03b27e1e0efe74817b3ce622f773a8291bcfd (patch)
treec840c7d445c96c6c3d37661e38e8cce44edb5d21 /lib/Service
parent863d50ecfa2963664cb16892d31af65ad3289b5e (diff)
code maintenance
Diffstat (limited to 'lib/Service')
-rw-r--r--lib/Service/OptionService.php3
-rw-r--r--lib/Service/PollService.php4
-rw-r--r--lib/Service/SubscriptionService.php13
3 files changed, 12 insertions, 8 deletions
diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php
index 93052c3d..0afe4b8c 100644
--- a/lib/Service/OptionService.php
+++ b/lib/Service/OptionService.php
@@ -24,8 +24,9 @@
namespace OCA\Polls\Service;
use Exception;
-
+use OCP\AppFramework\Db\DoesNotExistException;
use OCA\Polls\Exceptions\NotAuthorizedException;
+
use OCA\Polls\Db\Option;
use OCA\Polls\Db\OptionMapper;
use OCA\Polls\Service\LogService;
diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php
index d57f1124..31a6f36d 100644
--- a/lib/Service/PollService.php
+++ b/lib/Service/PollService.php
@@ -233,7 +233,7 @@
$this->poll = new Poll();
$this->poll->setType($type);
$this->poll->setCreated(time());
- $this->poll->setOwner($this->userId);
+ $this->poll->setOwner(\OC::$server->getUserSession()->getUser()->getUID());
$this->poll->setTitle($title);
$this->poll->setDescription('');
$this->poll->setAccess('hidden');
@@ -316,7 +316,7 @@
$this->poll = $this->pollMapper->find($pollId);
$this->poll->setCreated(time());
- $this->poll->setOwner($this->userId);
+ $this->poll->setOwner(\OC::$server->getUserSession()->getUser()->getUID());
$this->poll->setTitle('Clone of ' . $this->poll->getTitle());
$this->poll->setDeleted(0);
$this->poll->setId(0);
diff --git a/lib/Service/SubscriptionService.php b/lib/Service/SubscriptionService.php
index a8801520..bca84345 100644
--- a/lib/Service/SubscriptionService.php
+++ b/lib/Service/SubscriptionService.php
@@ -94,23 +94,26 @@ class SubscriptionService {
$subscription = $this->subscriptionMapper->findByUserAndPoll($pollId, $this->acl->getUserId());
if (!$subscribed) {
$this->subscriptionMapper->delete($subscription);
- return 'Unsubscribed';
+ return ['status' => 'Unsubscribed from poll ' . $pollId];
} else {
// subscription already exists, just return the existing subscription
- return $subscription;
+ return ['status' => 'Subscribed to poll ' . $pollId];
}
+
} catch (DoesNotExistException $e){
+
if ($subscribed) {
$subscription = new Subscription();
$subscription->setPollId($pollId);
$subscription->setUserId($this->acl->getUserId());
$this->subscriptionMapper->insert($subscription);
- return $subscription;
+ return ['status' => 'Subscribed to poll ' . $pollId];
} else {
// subscription is not found, just approve the unsubscription
- return 'Unsubscribed';
+ return ['status' => 'Unsubscribed from poll ' . $pollId];
}
+
} catch (MultipleObjectsReturnedException $e) {
// Duplicates should not exist but if found, fix it
// unsubscribe from all and resubscribe, if requested
@@ -125,7 +128,7 @@ class SubscriptionService {
$this->logger->debug('Added new subscription');
return $subscription;
} else {
- return 'Unsubscribed';
+ return ['status' => 'Unsubscribed from poll ' . $pollId];
}
}