Use events for watch and nofication events

Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
dartcafe 2021-05-24 19:48:35 +02:00
Родитель cbff872ddd
Коммит b95e380b97
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: CCE73CEF3035D3C8
31 изменённых файлов: 1062 добавлений и 90 удалений

Просмотреть файл

@ -31,8 +31,25 @@ use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\Notification\IManager as NotificationManager;
use OCP\User\Events\UserDeletedEvent;
use OCA\Polls\Event\CommentEvent;
use OCA\Polls\Event\OptionEvent;
use OCA\Polls\Event\OptionConfirmedEvent;
use OCA\Polls\Event\OptionCreatedEvent;
use OCA\Polls\Event\OptionDeletedEvent;
use OCA\Polls\Event\PollArchivedEvent;
use OCA\Polls\Event\PollCreatedEvent;
use OCA\Polls\Event\PollDeletedEvent;
use OCA\Polls\Event\PollRestoredEvent;
use OCA\Polls\Event\PollUpdatedEvent;
use OCA\Polls\Event\ShareEvent;
use OCA\Polls\Event\VoteEvent;
use OCA\Polls\Notification\Notifier;
use OCA\Polls\Listener\UserDeletedListener;
use OCA\Polls\Listener\CommentListener;
use OCA\Polls\Listener\OptionListener;
use OCA\Polls\Listener\PollListener;
use OCA\Polls\Listener\ShareListener;
use OCA\Polls\Listener\VoteListener;
class Application extends App implements IBootstrap {
@ -50,6 +67,19 @@ class Application extends App implements IBootstrap {
public function register(IRegistrationContext $context): void {
include_once __DIR__ . '/../../vendor/autoload.php';
$context->registerEventListener(CommentEvent::class, CommentListener::class);
$context->registerEventListener(OptionEvent::class, OptionListener::class);
$context->registerEventListener(OptionConfirmedEvent::class, OptionListener::class);
$context->registerEventListener(OptionCreatedEvent::class, OptionListener::class);
$context->registerEventListener(OptionDeletedEvent::class, OptionListener::class);
$context->registerEventListener(PollArchivedEvent::class, PollListener::class);
$context->registerEventListener(PollCreatedEvent::class, PollListener::class);
$context->registerEventListener(PollDeletedEvent::class, PollListener::class);
$context->registerEventListener(PollExpiredEvent::class, PollListener::class);
$context->registerEventListener(PollRestoredEvent::class, PollListener::class);
$context->registerEventListener(PollUpdatedEvent::class, PollListener::class);
$context->registerEventListener(ShareEvent::class, ShareListener::class);
$context->registerEventListener(VoteEvent::class, VoteListener::class);
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
}

Просмотреть файл

@ -48,7 +48,10 @@ class Log extends Entity implements JsonSerializable {
public const MSG_ID_DELETEPOLL = 'deletePoll';
public const MSG_ID_RESTOREPOLL = 'restorePoll';
public const MSG_ID_EXPIREPOLL = 'expirePoll';
public const MSG_ID_ADDOPTION = 'addOption';
public const MSG_ID_UPDATEOPTION = 'updateOption';
public const MSG_ID_CONFIRMOPTION = 'confirmeOption';
public const MSG_ID_DELETEOPTION = 'deleteOption';
public const MSG_ID_SETVOTE = 'setVote';
public const MSG_ID_OWNERCHANGE = 'updateOwner';

Просмотреть файл

@ -42,6 +42,7 @@ class Watch extends Entity implements JsonSerializable {
public const OBJECT_VOTES = "votes";
public const OBJECT_OPTIONS = "options";
public const OBJECT_COMMENTS = "comments";
public const OBJECT_SHARES = "shares";
/** @var int $pollId */
protected $pollId;

Просмотреть файл

@ -0,0 +1,53 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCP\EventDispatcher\Event;
use OCA\Polls\Db\Comment;
class CommentEvent extends Event {
private $comment;
public function __construct(Comment $comment) {
parent::__construct();
$this->comment = $comment;
}
public function getComment(): Comment {
return $this->comment;
}
public function getPollId(): int {
return $this->comment->getPollId();
}
public function getLogMsg(): string {
return '';
}
public function getActor(): string {
return \OC::$server->getUserSession()->getUser()->getUID();
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class OptionConfirmedEvent extends OptionEvent {
public function getLogMsg(): string {
return Log::MSG_ID_CONFIRMOPTION;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class OptionCreatedEvent extends OptionEvent {
public function getLogMsg(): string {
return Log::MSG_ID_ADDOPTION;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class OptionDeletedEvent extends OptionEvent {
public function getLogMsg(): string {
return Log::MSG_ID_DELETEOPTION;
}
}

53
lib/Event/OptionEvent.php Normal file
Просмотреть файл

@ -0,0 +1,53 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCP\EventDispatcher\Event;
use OCA\Polls\Db\Option;
class OptionEvent extends Event {
private $option;
public function __construct(Option $option) {
parent::__construct();
$this->option = $option;
}
public function getOption(): Option {
return $this->option;
}
public function getPollId(): int {
return $this->option->getPollId();
}
public function getLogMsg(): string {
return '';
}
public function getActor(): string {
return \OC::$server->getUserSession()->getUser()->getUID();
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class OptionUpdatedEvent extends OptionEvent {
public function getLogMsg(): string {
return Log::MSG_ID_UPDATEDOPTION;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class PollArchivedEvent extends PollEvent {
public function getLogMsg(): string {
return Log::MSG_ID_DELETEPOLL;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class PollCreatedEvent extends PollEvent {
public function getLogMsg(): string {
return Log::MSG_ID_ADDPOLL;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
// use OCA\Polls\Db\Log;
class PollDeletedEvent extends PollEvent {
public function getLogMsg(): string {
return ''; // Log::MSG_ID_DELETEPOLL;
}
}

53
lib/Event/PollEvent.php Normal file
Просмотреть файл

@ -0,0 +1,53 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCP\EventDispatcher\Event;
use OCA\Polls\Db\Poll;
abstract class PollEvent extends Event {
private $poll;
public function __construct(Poll $poll) {
parent::__construct();
$this->poll = $poll;
}
public function getPoll(): Poll {
return $this->poll;
}
public function getPollId(): int {
return $this->poll->getId();
}
public function getLogMsg(): string {
return '';
}
public function getActor(): string {
return \OC::$server->getUserSession()->getUser()->getUID();
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class PollExpiredEvent extends PollEvent {
public function getLogMsg(): string {
return Log::MSG_ID_EXPIREPOLL;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class PollRestoredEvent extends PollEvent {
public function getLogMsg(): string {
return Log::MSG_ID_RESTOREPOLL;
}
}

Просмотреть файл

@ -0,0 +1,32 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCA\Polls\Db\Log;
class PollUpdatedEvent extends PollEvent {
public function getLogMsg(): string {
return Log::MSG_ID_UPDATEPOLL;
}
}

56
lib/Event/ShareEvent.php Normal file
Просмотреть файл

@ -0,0 +1,56 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCP\EventDispatcher\Event;
use OCA\Polls\Db\Share;
class ShareEvent extends Event {
private $share;
public function __construct(Share $share) {
parent::__construct();
$this->share = $share;
}
public function getShare(): Share {
return $this->share;
}
public function getPollId(): int {
return $this->share->getPollId();
}
public function getLogMsg(): string {
return '';
}
public function getActor(): string {
if (\OC::$server->getUserSession()->isLoggedIn()) {
return \OC::$server->getUserSession()->getUser()->getUID();
}
return $this->share->getDisplayName();
}
}

54
lib/Event/VoteEvent.php Normal file
Просмотреть файл

@ -0,0 +1,54 @@
<?php
/*
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Event;
use OCP\EventDispatcher\Event;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Vote;
class VoteEvent extends Event {
private $vote;
public function __construct(Vote $vote) {
parent::__construct();
$this->vote = $vote;
}
public function getVote(): Vote {
return $this->vote;
}
public function getPollId(): int {
return $this->vote->getPollId();
}
public function getLogMsg(): string {
return Log::MSG_ID_SETVOTE;
}
public function getActor(): string {
return \OC::$server->getUserSession()->getUser()->getUID();
}
}

Просмотреть файл

@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Listener;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\Polls\Event\CommentEvent;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Watch;
use OCA\Polls\Service\LogService;
use OCA\Polls\Service\WatchService;
class CommentListener implements IEventListener {
/** @var LogService */
private $logService;
/** @var WatchService */
private $watchService;
/** @var string */
private $table = Watch::OBJECT_COMMENTS;
public function __construct(
LogService $logService,
WatchService $watchService
) {
$this->logService = $logService;
$this->watchService = $watchService;
}
public function handle(Event $event): void {
if (!($event instanceof CommentEvent)) {
return;
}
if ($event->getLogMsg()) {
$this->logService->setLog($event->getPollId(), $event->getLogMsg(), $event->getActor());
}
$this->watchService->writeUpdate($event->getPollId(), $this->table);
}
}

Просмотреть файл

@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Listener;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\Polls\Event\OptionEvent;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Watch;
use OCA\Polls\Service\LogService;
use OCA\Polls\Service\WatchService;
class OptionListener implements IEventListener {
/** @var LogService */
private $logService;
/** @var WatchService */
private $watchService;
/** @var string */
private $table = Watch::OBJECT_OPTIONS;
public function __construct(
LogService $logService,
WatchService $watchService
) {
$this->logService = $logService;
$this->watchService = $watchService;
}
public function handle(Event $event): void {
if (!($event instanceof OptionEvent)) {
return;
}
if ($event->getLogMsg()) {
$this->logService->setLog($event->getPollId(), $event->getLogMsg(), $event->getActor());
}
$this->watchService->writeUpdate($event->getPollId(), $this->table);
}
}

Просмотреть файл

@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Listener;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\Polls\Event\PollEvent;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Watch;
use OCA\Polls\Service\LogService;
use OCA\Polls\Service\WatchService;
class PollListener implements IEventListener {
/** @var LogService */
private $logService;
/** @var WatchService */
private $watchService;
/** @var string */
private $table = Watch::OBJECT_POLLS;
public function __construct(
LogService $logService,
WatchService $watchService
) {
$this->logService = $logService;
$this->watchService = $watchService;
}
public function handle(Event $event): void {
if (!($event instanceof PollEvent)) {
return;
}
if ($event->getLogMsg()) {
$this->logService->setLog($event->getPollId(), $event->getLogMsg(), $event->getActor());
}
$this->watchService->writeUpdate($event->getPollId(), $this->table);
}
}

Просмотреть файл

@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Listener;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\Polls\Event\ShareEvent;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Watch;
use OCA\Polls\Service\LogService;
use OCA\Polls\Service\WatchService;
class ShareListener implements IEventListener {
/** @var LogService */
private $logService;
/** @var WatchService */
private $watchService;
/** @var string */
private $table = Watch::OBJECT_SHARES;
public function __construct(
LogService $logService,
WatchService $watchService
) {
$this->logService = $logService;
$this->watchService = $watchService;
}
public function handle(Event $event): void {
if (!($event instanceof ShareEvent)) {
return;
}
if ($event->getLogMsg()) {
$this->logService->setLog($event->getPollId(), $event->getLogMsg(), $event->getActor());
}
$this->watchService->writeUpdate($event->getPollId(), $this->table);
}
}

Просмотреть файл

@ -23,18 +23,20 @@
namespace OCA\Polls\Listener;
use OCA\Polls\Cron\UserDeletedJob;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\User\Events\UserDeletedEvent;
use OCA\Polls\Cron\UserDeletedJob;
class UserDeletedListener implements IEventListener {
/** @var IJobList */
private $jobList;
public function __construct(IJobList $jobList) {
public function __construct(
IJobList $jobList
) {
$this->jobList = $jobList;
}

Просмотреть файл

@ -0,0 +1,63 @@
<?php
/**
* @copyright Copyright (c) 2021 René Gieling <github@dartcafe.de>
*
* @author René Gieling <github@dartcafe.de>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Polls\Listener;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCA\Polls\Event\VoteEvent;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\Watch;
use OCA\Polls\Service\LogService;
use OCA\Polls\Service\WatchService;
class VoteListener implements IEventListener {
/** @var LogService */
private $logService;
/** @var WatchService */
private $watchService;
/** @var string */
private $table = Watch::OBJECT_VOTES;
public function __construct(
LogService $logService,
WatchService $watchService
) {
$this->logService = $logService;
$this->watchService = $watchService;
}
public function handle(Event $event): void {
if (!($event instanceof VoteEvent)) {
return;
}
if ($event->getLogMsg()) {
$this->logService->setLog($event->getPollId(), $event->getLogMsg(), $event->getActor());
}
$this->watchService->writeUpdate($event->getPollId(), $this->table);
}
}

Просмотреть файл

@ -21,7 +21,6 @@
*
*/
namespace OCA\Polls\Model;
use OCP\IUserManager;

Просмотреть файл

@ -23,9 +23,10 @@
namespace OCA\Polls\Service;
use OCP\EventDispatcher\IEventDispatcher;
use OCA\Polls\Db\Comment;
use OCA\Polls\Db\CommentMapper;
use OCA\Polls\Db\Watch;
use OCA\Polls\Event\CommentEvent;
use OCA\Polls\Model\Acl;
class CommentService {
@ -42,21 +43,21 @@ class CommentService {
/** @var Comment */
private $comment;
/** @var WatchService */
private $watchService;
/** @var IEventDispatcher */
private $eventDispatcher;
public function __construct(
Acl $acl,
AnonymizeService $anonymizer,
CommentMapper $commentMapper,
Comment $comment,
WatchService $watchService
IEventDispatcher $eventDispatcher
) {
$this->acl = $acl;
$this->anonymizer = $anonymizer;
$this->commentMapper = $commentMapper;
$this->comment = $comment;
$this->watchService = $watchService;
$this->eventDispatcher = $eventDispatcher;
}
/**
@ -81,7 +82,7 @@ class CommentService {
/**
* Add comment
*/
public function add(int $pollId = 0, ?string $token = '', string $message): Comment {
public function add(int $pollId = 0, ?string $token = '', string $message = ''): Comment {
if ($token) {
$this->acl->setToken($token, Acl::PERMISSION_COMMENT_ADD);
} else {
@ -93,7 +94,9 @@ class CommentService {
$this->comment->setComment($message);
$this->comment->setTimestamp(time());
$this->comment = $this->commentMapper->insert($this->comment);
$this->watchService->writeUpdate($this->comment->getPollId(), Watch::OBJECT_COMMENTS);
$this->eventDispatcher->dispatchTyped(new CommentEvent($this->comment));
return $this->comment;
}
@ -114,7 +117,9 @@ class CommentService {
}
$this->commentMapper->delete($this->comment);
$this->watchService->writeUpdate($this->comment->getPollId(), Watch::OBJECT_COMMENTS);
$this->eventDispatcher->dispatchTyped(new CommentEvent($this->comment));
return $this->comment;
}
}

Просмотреть файл

@ -244,6 +244,8 @@ class MailService {
Log::MSG_ID_RESTOREPOLL => $this->trans->t('- The poll got restored.'),
Log::MSG_ID_EXPIREPOLL => $this->trans->t('- The poll was closed.'),
Log::MSG_ID_ADDOPTION => $this->trans->t('- A vote option was added.'),
Log::MSG_ID_UPDATEOPTION => $this->trans->t('- A vote option changed.'),
Log::MSG_ID_CONFIRMEDOPTION => $this->trans->t('- A vote option got confirmed.'),
Log::MSG_ID_DELETEOPTION => $this->trans->t('- A vote option was removed.'),
Log::MSG_ID_OWNERCHANGE => $this->trans->t('- The poll owner changed.'),
Log::MSG_ID_ADDPOLL => $this->trans->t('- %s created the poll.', [$displayName]),

Просмотреть файл

@ -23,23 +23,33 @@
namespace OCA\Polls\Service;
use Psr\Log\LoggerInterface;
use DateTime;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Psr\Log\LoggerInterface;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCA\Polls\Exceptions\DuplicateEntryException;
use OCA\Polls\Exceptions\InvalidPollTypeException;
use OCA\Polls\Exceptions\InvalidOptionPropertyException;
use OCA\Polls\Db\OptionMapper;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Db\Vote;
use OCA\Polls\Db\Option;
use OCA\Polls\Db\Poll;
use OCA\Polls\Db\Watch;
use OCA\Polls\Event\OptionEvent;
use OCA\Polls\Event\OptionConfirmedEvent;
use OCA\Polls\Event\OptionCreatedEvent;
use OCA\Polls\Event\OptionDeletedEvent;
use OCA\Polls\Model\Acl;
class OptionService {
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var LoggerInterface */
private $logger;
@ -67,25 +77,22 @@ class OptionService {
/** @var VoteMapper */
private $voteMapper;
/** @var WatchService */
private $watchService;
public function __construct(
string $AppName,
LoggerInterface $logger,
Acl $acl,
IEventDispatcher $eventDispatcher,
LoggerInterface $logger,
Option $option,
OptionMapper $optionMapper,
VoteMapper $voteMapper,
WatchService $watchService
VoteMapper $voteMapper
) {
$this->appName = $AppName;
$this->logger = $logger;
$this->acl = $acl;
$this->eventDispatcher = $eventDispatcher;
$this->logger = $logger;
$this->option = $option;
$this->optionMapper = $optionMapper;
$this->voteMapper = $voteMapper;
$this->watchService = $watchService;
}
/**
@ -156,14 +163,15 @@ class OptionService {
try {
$this->option = $this->optionMapper->insert($this->option);
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
} catch (Exception $e) {
} catch (UniqueConstraintViolationException $e) {
if ($e->getReason() === Exception::REASON_UNIQUE_CONSTRAINT_VIOLATION) {
throw new DuplicateEntryException('This option already exists');
}
throw $e;
}
$this->eventDispatcher->dispatchTyped(new OptionCreatedEvent($this->option));
return $this->option;
}
@ -179,7 +187,8 @@ class OptionService {
$this->setOption($timestamp, $pollOptionText, $duration);
$this->option = $this->optionMapper->update($this->option);
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionEvent($this->option));
return $this->option;
}
@ -202,7 +211,7 @@ class OptionService {
}
$this->optionMapper->delete($this->option);
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionDeletedEvent($this->option));
return $this->option;
}
@ -219,7 +228,7 @@ class OptionService {
$this->option->setConfirmed($this->option->getConfirmed() ? 0 : time());
$this->option = $this->optionMapper->update($this->option);
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionConfirmedEvent($this->option));
return $this->option;
}
@ -269,7 +278,8 @@ class OptionService {
}
}
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionCreatedEvent($this->option));
return $this->optionMapper->findByPoll($this->acl->getPollId());
}
@ -355,7 +365,7 @@ class OptionService {
}
}
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionEvent($this->option));
return $this->optionMapper->findByPoll($this->acl->getPollId());
}
@ -386,7 +396,8 @@ class OptionService {
$this->optionMapper->update($option);
}
$this->watchService->writeUpdate($this->acl->getPollId(), Watch::OBJECT_OPTIONS);
$this->eventDispatcher->dispatchTyped(new OptionEvent($this->option));
return $this->optionMapper->findByPoll($this->acl->getPollId());
}

Просмотреть файл

@ -24,18 +24,22 @@
namespace OCA\Polls\Service;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\EventDispatcher\IEventDispatcher;
use OCA\Polls\Exceptions\EmptyTitleException;
use OCA\Polls\Exceptions\InvalidAccessException;
use OCA\Polls\Exceptions\InvalidShowResultsException;
use OCA\Polls\Exceptions\InvalidPollTypeException;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\PollMapper;
use OCA\Polls\Db\Poll;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Db\Vote;
use OCA\Polls\Db\Watch;
use OCA\Polls\Event\PollArchivedEvent;
use OCA\Polls\Event\PollCreatedEvent;
use OCA\Polls\Event\PollDeletedEvent;
use OCA\Polls\Event\PollRestoredEvent;
use OCA\Polls\Event\PollUpdatedEvent;
use OCA\Polls\Model\Acl;
class PollService {
@ -43,6 +47,9 @@ class PollService {
/** @var string */
private $userId;
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var PollMapper */
private $pollMapper;
@ -52,15 +59,9 @@ class PollService {
/** @var VoteMapper */
private $voteMapper;
/** @var WatchService */
private $watchService;
/** @var Vote */
private $vote;
/** @var LogService */
private $logService;
/** @var NotificationService */
private $notificationService;
@ -71,27 +72,25 @@ class PollService {
private $acl;
public function __construct(
?string $UserId,
PollMapper $pollMapper,
Poll $poll,
VoteMapper $voteMapper,
Vote $vote,
WatchService $watchService,
LogService $logService,
NotificationService $notificationService,
Acl $acl,
IEventDispatcher $eventDispatcher,
MailService $mailService,
Acl $acl
NotificationService $notificationService,
Poll $poll,
PollMapper $pollMapper,
?string $UserId,
VoteMapper $voteMapper,
Vote $vote
) {
$this->acl = $acl;
$this->eventDispatcher = $eventDispatcher;
$this->mailService = $mailService;
$this->notificationService = $notificationService;
$this->poll = $poll;
$this->pollMapper = $pollMapper;
$this->userId = $UserId;
$this->poll = $poll;
$this->voteMapper = $voteMapper;
$this->watchService = $watchService;
$this->vote = $vote;
$this->logService = $logService;
$this->notificationService = $notificationService;
$this->mailService = $mailService;
$this->acl = $acl;
}
/**
@ -205,8 +204,7 @@ class PollService {
$this->poll->setImportant(0);
$this->poll = $this->pollMapper->insert($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->logService->setLog($this->poll->getId(), Log::MSG_ID_ADDPOLL);
$this->eventDispatcher->dispatchTyped(new PollCreatedEvent($this->poll));
return $this->poll;
}
@ -240,8 +238,7 @@ class PollService {
$this->poll->deserializeArray($poll);
$this->pollMapper->update($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->logService->setLog($this->poll->getId(), Log::MSG_ID_UPDATEPOLL);
$this->eventDispatcher->dispatchTyped(new PollUpdatedEvent($this->poll));
return $this->poll;
}
@ -258,8 +255,12 @@ class PollService {
$this->poll->setDeleted($this->poll->getDeleted() ? 0 : time());
$this->poll = $this->pollMapper->update($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->logService->setLog($this->poll->getId(), Log::MSG_ID_DELETEPOLL);
if ($this->poll->getDeleted()) {
$this->eventDispatcher->dispatchTyped(new PollArchivedEvent($this->poll));
} else {
$this->eventDispatcher->dispatchTyped(new PollRestoredEvent($this->poll));
}
if ($this->userId !== $this->poll->getOwner()) {
// send notification to the original owner
@ -286,7 +287,7 @@ class PollService {
$this->poll = $this->acl->getPoll();
$this->pollMapper->delete($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->eventDispatcher->dispatchTyped(new PollDeletedEvent($this->poll));
if (!$this->acl->getIsOwner()) {
// send notification to the original owner
@ -329,7 +330,7 @@ class PollService {
$this->poll->setImportant($origin->getImportant());
$this->poll = $this->pollMapper->insert($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->eventDispatcher->dispatchTyped(new PollCreatedEvent($this->poll));
return $this->poll;
}

Просмотреть файл

@ -26,15 +26,18 @@ namespace OCA\Polls\Service;
use Psr\Log\LoggerInterface;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IGroupManager;
use OCP\Security\ISecureRandom;
use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Exceptions\InvalidShareTypeException;
use OCA\Polls\Exceptions\ShareAlreadyExistsException;
use OCA\Polls\Exceptions\NotFoundException;
use OCP\Security\ISecureRandom;
use OCP\IGroupManager;
use OCA\Polls\Db\ShareMapper;
use OCA\Polls\Db\Share;
use OCA\Polls\Event\ShareEvent;
use OCA\Polls\Model\Acl;
use OCA\Polls\Model\UserGroupClass;
@ -49,6 +52,9 @@ class ShareService {
/** @var string|null */
private $userId;
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var IGroupManager */
private $groupManager;
@ -74,6 +80,7 @@ class ShareService {
string $AppName,
LoggerInterface $logger,
?string $UserId,
IEventDispatcher $eventDispatcher,
IGroupManager $groupManager,
SystemService $systemService,
ShareMapper $shareMapper,
@ -85,6 +92,7 @@ class ShareService {
$this->appName = $AppName;
$this->logger = $logger;
$this->userId = $UserId;
$this->eventDispatcher = $eventDispatcher;
$this->groupManager = $groupManager;
$this->systemService = $systemService;
$this->shareMapper = $shareMapper;
@ -221,7 +229,11 @@ class ShareService {
$this->share->setDisplayName($userGroup->getDisplayName());
$this->share->setEmailAddress($userGroup->getEmailAddress());
return $this->shareMapper->insert($this->share);
$this->share = $this->shareMapper->insert($this->share);
$this->eventDispatcher->dispatchTyped(new ShareEvent($this->share));
return $this->share;
}
/**
@ -243,8 +255,9 @@ class ShareService {
}
}
$userGroup = UserGroupClass::getUserGroupChild($type, $userId);
return $this->create($pollId, $userGroup);
$this->create($pollId, UserGroupClass::getUserGroupChild($type, $userId));
return $this->share;
}
/**
@ -264,10 +277,14 @@ class ShareService {
$this->systemService->validateEmailAddress($emailAddress, $emptyIsValid);
$this->share->setEmailAddress($emailAddress);
// TODO: Send confirmation
return $this->shareMapper->update($this->share);
$this->share = $this->shareMapper->update($this->share);
} else {
throw new InvalidShareTypeException('Email address can only be set in external shares.');
}
$this->eventDispatcher->dispatchTyped(new ShareEvent($this->share));
return $this->share;
}
/**
@ -327,6 +344,9 @@ class ShareService {
}
$this->share->setEmailAddress($emailAddress);
$this->shareMapper->update($this->share);
$this->eventDispatcher->dispatchTyped(new ShareEvent($this->share));
} else {
throw new NotAuthorizedException;
}
@ -354,6 +374,9 @@ class ShareService {
} catch (DoesNotExistException $e) {
// silently catch
}
$this->eventDispatcher->dispatchTyped(new ShareEvent($this->share));
return $token;
}

Просмотреть файл

@ -24,14 +24,16 @@
namespace OCA\Polls\Service;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\EventDispatcher\IEventDispatcher;
use OCA\Polls\Exceptions\VoteLimitExceededException;
use OCA\Polls\Db\Log;
use OCA\Polls\Db\OptionMapper;
use OCA\Polls\Db\Option;
use OCA\Polls\Db\VoteMapper;
use OCA\Polls\Db\Vote;
use OCA\Polls\Db\Watch;
use OCA\Polls\Event\VoteEvent;
use OCA\Polls\Model\Acl;
class VoteService {
@ -42,8 +44,8 @@ class VoteService {
/** @var AnonymizeService */
private $anonymizer;
/** @var LogService */
private $logService;
/** @var IEventDispatcher */
private $eventDispatcher;
/** @var OptionMapper */
private $optionMapper;
@ -54,26 +56,20 @@ class VoteService {
/** @var VoteMapper */
private $voteMapper;
/** @var WatchService */
private $watchService;
public function __construct(
Acl $acl,
AnonymizeService $anonymizer,
LogService $logService,
IEventDispatcher $eventDispatcher,
OptionMapper $optionMapper,
Vote $vote,
VoteMapper $voteMapper,
WatchService $watchService
VoteMapper $voteMapper
) {
$this->acl = $acl;
$this->anonymizer = $anonymizer;
$this->logService = $logService;
$this->eventDispatcher = $eventDispatcher;
$this->optionMapper = $optionMapper;
$this->vote = $vote;
$this->voteMapper = $voteMapper;
$this->watchService = $watchService;
}
/**
@ -155,17 +151,13 @@ class VoteService {
$this->vote = $this->voteMapper->findSingleVote($this->acl->getPollId(), $option->getPollOptionText(), $this->acl->getUserId());
if (in_array(trim($setTo), ['no', '']) && !$this->acl->getPoll()->getUseNo()) {
try {
$this->voteMapper->delete($this->vote);
} catch (DoesNotExistException $e) {
// catch silently
}
$this->vote->setVoteAnswer('');
return $this->vote;
$this->voteMapper->delete($this->vote);
} else {
$this->vote->setVoteAnswer($setTo);
$this->voteMapper->update($this->vote);
}
$this->vote->setVoteAnswer($setTo);
$this->voteMapper->update($this->vote);
} catch (DoesNotExistException $e) {
// Vote does not exist, insert as new Vote
$this->vote = new Vote();
@ -177,8 +169,8 @@ class VoteService {
$this->vote->setVoteAnswer($setTo);
$this->voteMapper->insert($this->vote);
}
$this->logService->setLog($this->vote->getPollId(), Log::MSG_ID_SETVOTE, $this->vote->getUserId());
$this->watchService->writeUpdate($this->vote->getPollId(), Watch::OBJECT_VOTES);
$this->eventDispatcher->dispatchTyped(new VoteEvent($this->vote));
return $this->vote;
}
@ -188,7 +180,6 @@ class VoteService {
public function delete(int $pollId, string $userId): string {
$this->acl->setPollId($pollId, Acl::PERMISSION_POLL_EDIT);
$this->voteMapper->deleteByPollAndUserId($pollId, $userId);
$this->watchService->writeUpdate($pollId, Watch::OBJECT_VOTES);
return $userId;
}
}