]> source.dussan.org Git - nextcloud-server.git/commitdiff
Deduplicate icon assignment
authorJoas Schilling <coding@schilljs.com>
Tue, 29 Nov 2016 14:56:22 +0000 (15:56 +0100)
committerJoas Schilling <coding@schilljs.com>
Tue, 29 Nov 2016 15:08:58 +0000 (16:08 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/CalDAV/Activity/Provider/Calendar.php

index 2307c2048e0845ad523faf0e4fff69c808c23c36..05881866ce613d519144638e39811759a14e1fb4 100644 (file)
@@ -81,63 +81,48 @@ class Calendar implements IProvider {
         * @since 11.0.0
         */
        public function parse(IEvent $event, IEvent $previousEvent = null) {
-               if ($event->getApp() !== 'dav') {
+               if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') {
                        throw new \InvalidArgumentException();
                }
 
+               $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
+
                if ($event->getSubject() === self::SUBJECT_ADD) {
                        $subject = $this->l->t('{actor} created calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_ADD . '_self') {
                        $subject = $this->l->t('You created calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_DELETE) {
                        $subject = $this->l->t('{actor} deleted calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_DELETE . '_self') {
                        $subject = $this->l->t('You deleted calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UPDATE) {
                        $subject = $this->l->t('{actor} updated calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UPDATE . '_self') {
                        $subject = $this->l->t('You updated calendar {calendar}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
 
                } else if ($event->getSubject() === self::SUBJECT_SHARE_USER) {
                        $subject = $this->l->t('{actor} shared calendar {calendar} with you');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_you') {
                        $subject = $this->l->t('You shared calendar {calendar} with {user}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_SHARE_USER . '_by') {
                        $subject = $this->l->t('{actor} shared calendar {calendar} with {user}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER) {
                        $subject = $this->l->t('{actor} unshared calendar {calendar} from you');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_you') {
                        $subject = $this->l->t('You unshared calendar {calendar} from {user}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_by') {
                        $subject = $this->l->t('{actor} unshared calendar {calendar} from {user}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_USER . '_self') {
                        $subject = $this->l->t('{actor} unshared calendar {calendar} from themselves');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
 
                } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_you') {
                        $subject = $this->l->t('You shared calendar {calendar} with group {group}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_SHARE_GROUP . '_by') {
                        $subject = $this->l->t('{actor} shared calendar {calendar} with group {group}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_you') {
                        $subject = $this->l->t('You unshared calendar {calendar} from group {group}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else if ($event->getSubject() === self::SUBJECT_UNSHARE_GROUP . '_by') {
                        $subject = $this->l->t('{actor} unshared calendar {calendar} from group {group}');
-                       $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'places/calendar-dark.svg')));
                } else {
                        throw new \InvalidArgumentException();
                }