Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 16200cfd authored by AVINASH GUSAIN's avatar AVINASH GUSAIN
Browse files

Merge branch 'dev/remove-jitsi' into 'murena-main'

remove jitsi

See merge request !48
parents 5046f486 0d332b12
Loading
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -20,9 +20,6 @@
	<author>Anna Larch</author>
	<author homepage="https://github.com/nextcloud/groupware">Nextcloud Groupware Team</author>
	<namespace>Calendar</namespace>
	<types>
		<dav/>
	</types>
	<documentation>
		<user>https://docs.nextcloud.com/server/latest/user_manual/en/groupware/calendar.html</user>
		<admin>https://docs.nextcloud.com/server/latest/admin_manual/groupware/calendar.html</admin>
+0 −14
Original line number Diff line number Diff line
@@ -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;
@@ -36,7 +35,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 +43,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 +126,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);
			}
		});

	}
}
+0 −109
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace OCA\Calendar\Dav;

use Sabre\DAV\INode;
use Sabre\DAV\Server;
use Sabre\DAV\ServerPlugin;
use Sabre\VObject\Reader;

class BeforeCreateFilePlugin extends ServerPlugin {

	/**
	 * A reference to the main Server class.
	 *
	 * @var \Sabre\DAV\Server
	 */
	protected $server;

	/**
	 * Initialize the plugin.
	 *
	 * This is called automatically be the Server class after this plugin is
	 * added with Sabre\DAV\Server::addPlugin()
	 */
	public function initialize(Server $server) {
		$this->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);
		}
	}
}
+0 −1
Original line number Diff line number Diff line
@@ -184,7 +184,6 @@ export default {
				timezoneId,
				organizer: this.$store.getters.getCurrentUserPrincipal,
			})
			  this.$emit('new-attendee-added', 'added')
		},
		removeAttendee(attendee) {
			this.$store.commit('removeAttendee', {
+0 −39
Original line number Diff line number Diff line
@@ -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())
			}
		},
	},
}
</script>
Loading