diff options
author | dartcafe <github@dartcafe.de> | 2021-05-25 01:04:22 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2021-06-15 11:42:45 +0300 |
commit | d96164a56918bdc2e20e8c1b3a2bae1501ab9ed3 (patch) | |
tree | 71410f1e65fe4bfb8452557b5f52e3a58806adfa /lib/Event/PollDeletedEvent.php | |
parent | b95e380b971c5602a11db6ec040626aab6ca58d8 (diff) |
fixes and move notification to events and listener
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib/Event/PollDeletedEvent.php')
-rw-r--r-- | lib/Event/PollDeletedEvent.php | 79 |
1 files changed, 47 insertions, 32 deletions
diff --git a/lib/Event/PollDeletedEvent.php b/lib/Event/PollDeletedEvent.php index e3c22981..6862f30d 100644 --- a/lib/Event/PollDeletedEvent.php +++ b/lib/Event/PollDeletedEvent.php @@ -1,32 +1,47 @@ -<?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;
- }
-}
+<?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\Notification\Notifier; + +class PollDeletedEvent extends PollEvent { + public function getLogMsg(): string { + return ''; // Log::MSG_ID_DELETEPOLL; + } + + public function getNotification(): array { + if ($this->getActor() === $this->getPollOwner()) { + return []; + } + + return [ + 'msgId' => Notifier::NOTIFY_POLL_DELETED_BY_OTHER, + 'objectType' => 'poll', + 'objectValue' => $this->getPollId(), + 'recipient' => $this->getPollOwner(), + 'actor' => $this->getActor(), + 'pollTitle' => $this->getPollTitle(), + ]; + } +} |