From f300e60ead52919207fd8456aa458ed7d2b35dd2 Mon Sep 17 00:00:00 2001 From: Avinash Gusain Date: Tue, 29 Aug 2023 12:28:13 +0530 Subject: [PATCH 1/2] remove jitsi --- appinfo/info.xml | 3 - lib/AppInfo/Application.php | 13 --- lib/Dav/BeforeCreateFilePlugin.php | 109 ------------------ .../Editor/Invitees/InviteesList.vue | 1 - .../Properties/PropertyTextLocation.vue | 39 ------- src/views/EditSidebar.vue | 11 +- 6 files changed, 2 insertions(+), 174 deletions(-) delete mode 100644 lib/Dav/BeforeCreateFilePlugin.php diff --git a/appinfo/info.xml b/appinfo/info.xml index f0111f29e..59666f344 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -20,9 +20,6 @@ Anna Larch Nextcloud Groupware Team Calendar - - - https://docs.nextcloud.com/server/latest/user_manual/en/groupware/calendar.html https://docs.nextcloud.com/server/latest/admin_manual/groupware/calendar.html diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 3156b97c2..419566b91 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -36,7 +36,6 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\BackgroundJob\IJobList; use OCP\Calendar\IManager; use OCP\Defaults; -use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; @@ -45,7 +44,6 @@ use OCP\IRequest; use OCP\IUserManager; use OCP\L10N\IFactory as L10NFactory; use OCP\Mail\IMailer; -use OCP\SabrePluginEvent; use OCP\User\Events\UserDeletedEvent; use function method_exists; @@ -129,16 +127,5 @@ class Application extends App implements IBootstrap { // executed in the order that it is registered $containerinvite->registerMiddleware("InvitationMiddleware"); - - $serverContainer = $context->getServerContainer(); - $eventDispatcher = $serverContainer->get(IEventDispatcher::class); - $eventDispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) use ($context) { - $eventServer = $event->getServer(); - if ($eventServer !== null) { - $plugin = $context->getAppContainer()->get(BeforeCreateFilePlugin::class); - $eventServer->addPlugin($plugin); - } - }); - } } diff --git a/lib/Dav/BeforeCreateFilePlugin.php b/lib/Dav/BeforeCreateFilePlugin.php deleted file mode 100644 index 373fa13f3..000000000 --- a/lib/Dav/BeforeCreateFilePlugin.php +++ /dev/null @@ -1,109 +0,0 @@ -server = $server; - $server->on('beforeCreateFile', [$this, 'beforeCreateFile']); - $server->on('beforeWriteContent', [$this, 'beforeWriteContent']); - } - - - - /** - * Assign jitsi link to location - * - * @param string $uri target file URI - * @param resource $data data - * @param INode $parent Sabre Node - * @param bool $modified modified - * @return - */ - - public function beforeCreateFile($uri, &$data, INode $parent, &$modified) { - if (is_resource($data)) { - $data = stream_get_contents($data); - } - // Parse the data as a vCalendar object using Sabre\VObject. - try { - $vCalendar = Reader::read($data); - } catch (\Exception $e) { - // The data is not a valid vCalendar object. - return; - } - $this->processEventData($data); - - } - - /** - * Assign jitsi link to location - * - * @param string $uri target file URI - * @param INode $parent Sabre Node - * @param resource $data data - * @param bool $modified modified - * @return - */ - - public function beforeWriteContent($uri, INode $parent, &$data, &$modified) { - if (is_resource($data)) { - $data = stream_get_contents($data); - } - // Parse the data as a vCalendar object using Sabre\VObject. - try { - $vCalendar = Reader::read($data); - } catch (\Exception $e) { - // The data is not a valid vCalendar object. - return; - } - $this->processEventData($data); - } - - /** - * Process event data and assign a Jitsi link to the event location. - * - * @param string $data Data - */ - private function processEventData(&$data) { - // Check if the data contains 'ATTENDEE;' but not 'LOCATION:' - if (strpos($data, 'ATTENDEE;') !== false && strpos($data, 'LOCATION:') === false) { - // Set the base URL for the meeting - $baseURL = 'https://meet.jit.si/'; - - // Generate a random alphanumeric string of length 8 - $chars = '0123456789abcdefghijklmnopqrstuvwxyz'; - $randomString = substr(str_shuffle($chars), 0, 8); - - // Append the current date to the random string - $randomString .= date('dmy'); - - // Create the complete meeting URL - $meetingURL = $baseURL . $randomString; - - // Replace the BEGIN:VEVENT/ with 'BEGIN:VEVENT' followed by 'LOCATION:' - $data = preg_replace('/BEGIN:VEVENT/', "BEGIN:VEVENT\nLOCATION:$meetingURL", $data); - } - } -} diff --git a/src/components/Editor/Invitees/InviteesList.vue b/src/components/Editor/Invitees/InviteesList.vue index 6c9fc1971..4f8a47b3e 100644 --- a/src/components/Editor/Invitees/InviteesList.vue +++ b/src/components/Editor/Invitees/InviteesList.vue @@ -184,7 +184,6 @@ export default { timezoneId, organizer: this.$store.getters.getCurrentUserPrincipal, }) - this.$emit('new-attendee-added', 'added') }, removeAttendee(attendee) { this.$store.commit('removeAttendee', { diff --git a/src/components/Editor/Properties/PropertyTextLocation.vue b/src/components/Editor/Properties/PropertyTextLocation.vue index d96b6f7ea..b03d24da0 100644 --- a/src/components/Editor/Properties/PropertyTextLocation.vue +++ b/src/components/Editor/Properties/PropertyTextLocation.vue @@ -74,28 +74,6 @@ function isValidHttpUrl(string) { } return url.protocol === 'http:' || url.protocol === 'https:' } -/** - * - * @param length - * @param chars - */ -function generateRandomString(length, chars) { - let result = '' - for (let i = length; i > 0; --i) { result += chars[Math.floor(Math.random() * chars.length)] } - const todaynow = new Date() - result = result + todaynow.getDate() + todaynow.getMonth() + todaynow.getFullYear().toString().substr(-2) - return result -} -/** - * - */ -function JitsiUrlGenerator() { - let url = 'https://meet.jit.si/' - const charstr = '0123456789abcdefghijklmnopqrstuvwxyz' - const randomString = generateRandomString(8, charstr) - url = url + randomString - return url -} /** * @param el @@ -184,23 +162,6 @@ export default { this.vshow2 = false this.vshow1 = true }, - addJitsiUrl() { - if (typeof this.value !== 'string') { - this.$emit('update:value', JitsiUrlGenerator()) - this.visibleValue = true - this.clearUrl = true - this.vshow2 = true - this.vshow1 = false - } else if (this.value === '') { - this.$emit('update:value', JitsiUrlGenerator()) - this.visibleValue = true - this.clearUrl = true - this.vshow2 = true - this.vshow1 = false - } else { - this.visibleValue = this.clearUrl = isValidHttpUrl(this.value.trim()) - } - }, }, } diff --git a/src/views/EditSidebar.vue b/src/views/EditSidebar.vue index 31c74539a..020731aa8 100644 --- a/src/views/EditSidebar.vue +++ b/src/views/EditSidebar.vue @@ -123,8 +123,7 @@
- + :is-read-only="isReadOnly" />
Date: Tue, 29 Aug 2023 12:36:50 +0530 Subject: [PATCH 2/2] remove jitsi --- lib/AppInfo/Application.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 419566b91..39c29d82f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,7 +24,6 @@ declare(strict_types=1); namespace OCA\Calendar\AppInfo; use OCA\Calendar\Dashboard\CalendarWidget; -use OCA\Calendar\Dav\BeforeCreateFilePlugin; use OCA\Calendar\Listener\UserDeletedListener; use OCA\Calendar\Middleware\InvitationMiddleware; use OCA\Calendar\Notification\Notifier; -- GitLab