@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Prevent repetition of the same log event |
|
| 54 | - * @NoAdminRequired |
|
| 55 | - * @return Bool |
|
| 56 | - */ |
|
| 53 | + * Prevent repetition of the same log event |
|
| 54 | + * @NoAdminRequired |
|
| 55 | + * @return Bool |
|
| 56 | + */ |
|
| 57 | 57 | public function isRepetition() { |
| 58 | 58 | try { |
| 59 | 59 | $lastRecord = $this->mapper->getLastRecord($this->logItem->getPollId()); |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * Log poll activity |
|
| 72 | - * @NoAdminRequired |
|
| 73 | - * @param $pollId related pollId |
|
| 74 | - * @param $messageId identifier for message notice |
|
| 75 | - * @param $userId (optional) |
|
| 76 | - * @param $message message text if $messageId is === 'custom' |
|
| 77 | - * @return Log |
|
| 78 | - */ |
|
| 71 | + * Log poll activity |
|
| 72 | + * @NoAdminRequired |
|
| 73 | + * @param $pollId related pollId |
|
| 74 | + * @param $messageId identifier for message notice |
|
| 75 | + * @param $userId (optional) |
|
| 76 | + * @param $message message text if $messageId is === 'custom' |
|
| 77 | + * @return Log |
|
| 78 | + */ |
|
| 79 | 79 | public function setLog($pollId, $messageId, $userId = null, $message = null) { |
| 80 | 80 | $this->logItem = new Log(); |
| 81 | 81 | $this->logItem->setPollId($pollId); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | use OCA\Polls\Db\Log; |
| 30 | 30 | use OCA\Polls\Db\LogMapper; |
| 31 | 31 | |
| 32 | -class LogService { |
|
| 32 | +class LogService { |
|
| 33 | 33 | |
| 34 | 34 | private $mapper; |
| 35 | 35 | private $logItem; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | public function isRepetition() { |
| 58 | 58 | try { |
| 59 | 59 | $lastRecord = $this->mapper->getLastRecord($this->logItem->getPollId()); |
| 60 | - return ( intval($lastRecord->getPollId()) === intval($this->logItem->getPollId()) |
|
| 60 | + return (intval($lastRecord->getPollId()) === intval($this->logItem->getPollId()) |
|
| 61 | 61 | && $lastRecord->getUserId() === $this->logItem->getUserId() |
| 62 | 62 | && $lastRecord->getMessageId() === $this->logItem->getMessageId() |
| 63 | 63 | && $lastRecord->getMessage() === $this->logItem->getMessage() |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | use OCA\Polls\Db\Log; |
| 30 | 30 | use OCA\Polls\Db\LogMapper; |
| 31 | 31 | |
| 32 | -class LogService { |
|
| 32 | +class LogService { |
|
| 33 | 33 | |
| 34 | 34 | private $mapper; |
| 35 | 35 | private $logItem; |
@@ -120,7 +120,7 @@ |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if (!$toEmail || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { |
| 123 | - throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 123 | + throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | try { |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | use OCA\Polls\Db\Share; |
| 42 | 42 | use OCA\Polls\Db\LogMapper; |
| 43 | 43 | |
| 44 | -class MailService { |
|
| 44 | +class MailService { |
|
| 45 | 45 | |
| 46 | 46 | private $userManager; |
| 47 | 47 | private $groupManager; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | if (!$toEmail || !filter_var($toEmail, FILTER_VALIDATE_EMAIL)) { |
| 123 | - throw new Exception( 'Invalid email address (' . $toEmail .')' ); |
|
| 123 | + throw new Exception('Invalid email address (' . $toEmail . ')'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | try { |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $emailTemplate->addBodyText(str_replace( |
| 253 | 253 | ['{owner}', '{title}'], |
| 254 | 254 | [$owner->getDisplayName(), $event->getTitle()], |
| 255 | - $trans->t('{owner} invited you to take part in the poll "{title}"' ) |
|
| 255 | + $trans->t('{owner} invited you to take part in the poll "{title}"') |
|
| 256 | 256 | )); |
| 257 | 257 | |
| 258 | 258 | $emailTemplate->addBodyButton( |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | $recipient['link'] |
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | - $emailTemplate->addFooter($trans->t('This email is sent to you, because you are invited to vote in this poll by the poll owner.' )); |
|
| 263 | + $emailTemplate->addFooter($trans->t('This email is sent to you, because you are invited to vote in this poll by the poll owner.')); |
|
| 264 | 264 | |
| 265 | 265 | try { |
| 266 | 266 | $this->sendMail( |
@@ -333,27 +333,27 @@ discard block |
||
| 333 | 333 | } elseif ($logItem->getMessageId() === 'setVote') { |
| 334 | 334 | $emailTemplate->addBodyText($trans->t( |
| 335 | 335 | '- %s voted.', |
| 336 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 336 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 337 | 337 | ); |
| 338 | 338 | } elseif ($logItem->getMessageId() === 'updatePoll') { |
| 339 | 339 | $emailTemplate->addBodyText($trans->t( |
| 340 | 340 | '- %s updated the poll configuration. Please check your votes.', |
| 341 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 341 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 342 | 342 | ); |
| 343 | 343 | } elseif ($logItem->getMessageId() === 'deletePoll') { |
| 344 | 344 | $emailTemplate->addBodyText($trans->t( |
| 345 | 345 | '- %s deleted the poll.', |
| 346 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 346 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 347 | 347 | ); |
| 348 | 348 | } elseif ($logItem->getMessageId() === 'restorePoll') { |
| 349 | 349 | $emailTemplate->addBodyText($trans->t( |
| 350 | 350 | '- %s restored the poll.', |
| 351 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 351 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 352 | 352 | ); |
| 353 | 353 | } elseif ($logItem->getMessageId() === 'expirePoll') { |
| 354 | 354 | $emailTemplate->addBodyText($trans->t( |
| 355 | 355 | '- The poll expired.', |
| 356 | - array( $this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 356 | + array($this->userManager->get($logItem->getUserId())->getDisplayName())) |
|
| 357 | 357 | ); |
| 358 | 358 | } |
| 359 | 359 | |
@@ -368,10 +368,10 @@ discard block |
||
| 368 | 368 | $url, |
| 369 | 369 | /** @scrutinizer ignore-type */ false |
| 370 | 370 | ); |
| 371 | - $emailTemplate->addFooter($trans->t('This email is sent to you, because you subscribed to notifications of this poll. To opt out, visit the poll and remove your subscription.' )); |
|
| 371 | + $emailTemplate->addFooter($trans->t('This email is sent to you, because you subscribed to notifications of this poll. To opt out, visit the poll and remove your subscription.')); |
|
| 372 | 372 | |
| 373 | 373 | try { |
| 374 | - $this->sendMail( $emailTemplate, $subscription->getUserId()); |
|
| 374 | + $this->sendMail($emailTemplate, $subscription->getUserId()); |
|
| 375 | 375 | } catch (Exeption $e) { |
| 376 | 376 | // todo alert Owner |
| 377 | 377 | // Notification to $subscription->getUserId() could not be sent |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | use OCA\Polls\Db\Share; |
| 42 | 42 | use OCA\Polls\Db\LogMapper; |
| 43 | 43 | |
| 44 | -class MailService { |
|
| 44 | +class MailService { |
|
| 45 | 45 | |
| 46 | 46 | private $userManager; |
| 47 | 47 | private $groupManager; |
@@ -119,7 +119,7 @@ |
||
| 119 | 119 | } else { |
| 120 | 120 | return false; |
| 121 | 121 | } |
| 122 | - }); |
|
| 122 | + }); |
|
| 123 | 123 | return new DataResponse($events, Http::STATUS_OK); |
| 124 | 124 | } catch (DoesNotExistException $e) { |
| 125 | 125 | $events = []; |
@@ -81,7 +81,7 @@ |
||
| 81 | 81 | ->from($this->getTableName()) |
| 82 | 82 | ->where($qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))) |
| 83 | 83 | ->setMaxResults( 1 ) |
| 84 | - ->orderBy('id', 'DESC'); |
|
| 84 | + ->orderBy('id', 'DESC'); |
|
| 85 | 85 | |
| 86 | 86 | return $this->findEntity($qb); |
| 87 | 87 | |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $qb->select('*') |
| 81 | 81 | ->from($this->getTableName()) |
| 82 | 82 | ->where($qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))) |
| 83 | - ->setMaxResults( 1 ) |
|
| 83 | + ->setMaxResults(1) |
|
| 84 | 84 | ->orderBy('id', 'DESC'); |
| 85 | 85 | |
| 86 | 86 | return $this->findEntity($qb); |
@@ -31,35 +31,35 @@ |
||
| 31 | 31 | class NotificationCron extends TimedJob { |
| 32 | 32 | |
| 33 | 33 | /** @var MailService*/ |
| 34 | - private $mailService; |
|
| 34 | + private $mailService; |
|
| 35 | 35 | private $logger; |
| 36 | 36 | |
| 37 | 37 | /** @param MailService $mailService |
| 38 | - */ |
|
| 39 | - public function __construct( |
|
| 38 | + */ |
|
| 39 | + public function __construct( |
|
| 40 | 40 | ILogger $logger, |
| 41 | 41 | MailService $mailService |
| 42 | 42 | ) { |
| 43 | 43 | $this->logger = $logger; |
| 44 | 44 | $this->setInterval(60); |
| 45 | 45 | $this->mailService = $mailService; |
| 46 | - } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | - * getByToken |
|
| 50 | - * Get pollId by token |
|
| 51 | - * @NoAdminRequired |
|
| 52 | - * @NoCSRFRequired |
|
| 53 | - * @PublicPage |
|
| 54 | - * @param string $token |
|
| 55 | - * @return DataResponse |
|
| 56 | - */ |
|
| 57 | - protected function run($arguments) { |
|
| 58 | - if ($this->mailService->sendNotifications()) { |
|
| 59 | - $this->logger->debug('Notifications sent'); |
|
| 60 | - } else { |
|
| 49 | + * getByToken |
|
| 50 | + * Get pollId by token |
|
| 51 | + * @NoAdminRequired |
|
| 52 | + * @NoCSRFRequired |
|
| 53 | + * @PublicPage |
|
| 54 | + * @param string $token |
|
| 55 | + * @return DataResponse |
|
| 56 | + */ |
|
| 57 | + protected function run($arguments) { |
|
| 58 | + if ($this->mailService->sendNotifications()) { |
|
| 59 | + $this->logger->debug('Notifications sent'); |
|
| 60 | + } else { |
|
| 61 | 61 | $this->logger->alert('error while sending notifications'); |
| 62 | - } |
|
| 63 | - } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |