Merge branch 'master' into dev/sync-nextcloud-addressbook

This commit is contained in:
Fahim Salam Chowdhury 2024-09-24 16:17:16 +00:00 committed by GitHub
commit 2b8f49fe39
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
189 changed files with 16593 additions and 4813 deletions

View file

@ -124,11 +124,20 @@ $Plugin->addHook('hook.name', 'functionName');
params:
string &$sEmail
Happens in resolveLoginCredentials($sEmail) BEFORE resolving domain name.
This is the pure text from the login screen (DoLogin) or the SSO feature (ServiceSso) received by LoginProcess().
- DoLogin() -> LoginProcess() -> resolveLoginCredentials($sEmail)
- ServiceSso() -> LoginProcess() -> resolveLoginCredentials($sEmail)
So $sEmail can just have the value `test` without a domain.
### login.credentials.step-2
params:
string &$sEmail
string &$sPassword
Happens in resolveLoginCredentials($sEmail) AFTER resolving domain name.
So $sEmail always has a domain (for example `test` is now `test@example.com`).
### login.credentials
params:
string &$sEmail
@ -136,6 +145,10 @@ $Plugin->addHook('hook.name', 'functionName');
string &$sPassword
string &$sSmtpUser
$sEmail is the domain imap->fixUsername() without shortening.
$sImapUser is the domain imap->fixUsername() for login into IMAP.
$sSmtpUser is the domain smtp->fixUsername() for login into SMTP.
### login.success
params:
\RainLoop\Model\MainAccount $oAccount

View file

@ -47,7 +47,10 @@ class Memcache implements \MailSo\Cache\DriverInterface
public function Set(string $sKey, string $sValue) : bool
{
return $this->oMem ? $this->oMem->set($this->generateCachedKey($sKey), $sValue, 0, $this->iExpire) : false;
if ($this->oMem instanceof \Memcache) {
return $this->oMem->set($this->generateCachedKey($sKey), $sValue, 0, $this->iExpire);
}
return $this->oMem ? $this->oMem->set($this->generateCachedKey($sKey), $sValue, $this->iExpire) : false;
}
public function Exists(string $sKey) : bool

View file

@ -4,8 +4,8 @@ class CacheMemcachePlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Cache Memcache',
VERSION = '2.36',
RELEASE = '2024-03-22',
VERSION = '2.37',
RELEASE = '2024-09-15',
REQUIRED = '2.36.0',
CATEGORY = 'Cache',
DESCRIPTION = 'Cache handler using PHP Memcache or PHP Memcached';

View file

@ -472,7 +472,7 @@ class Client implements ClientInterface, IteratorAggregate
*
* @return Pipeline|array
*/
protected function createPipeline(array $options = null, $callable = null)
protected function createPipeline(?array $options = null, $callable = null)
{
if (isset($options['atomic']) && $options['atomic']) {
$class = Atomic::class;
@ -525,7 +525,7 @@ class Client implements ClientInterface, IteratorAggregate
*
* @return MultiExecTransaction|array
*/
protected function createTransaction(array $options = null, $callable = null)
protected function createTransaction(?array $options = null, $callable = null)
{
$transaction = new MultiExecTransaction($this, $options);
@ -557,7 +557,7 @@ class Client implements ClientInterface, IteratorAggregate
*
* @return PubSubConsumer|null
*/
protected function createPubSub(array $options = null, $callable = null)
protected function createPubSub(?array $options = null, $callable = null)
{
if ($this->connection instanceof RelayConnection) {
$pubsub = new RelayPubSubConsumer($this, $options);

View file

@ -30,7 +30,7 @@ class Consumer extends AbstractConsumer
* @param ClientInterface $client Client instance used by the consumer.
* @param array $options Options for the consumer initialization.
*/
public function __construct(ClientInterface $client, array $options = null)
public function __construct(ClientInterface $client, ?array $options = null)
{
$this->checkCapabilities($client);

View file

@ -51,7 +51,7 @@ class MultiExec implements ClientContextInterface
* @param ClientInterface $client Client instance used by the transaction.
* @param array $options Initialization options.
*/
public function __construct(ClientInterface $client, array $options = null)
public function __construct(ClientInterface $client, ?array $options = null)
{
$this->assertClient($client);

View file

@ -4,9 +4,9 @@ class CustomLoginMappingPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Custom Login Mapping',
VERSION = '2.1',
RELEASE = '2021-04-21',
REQUIRED = '2.5.0',
VERSION = '2.3',
RELEASE = '2024-09-21',
REQUIRED = '2.36.1',
CATEGORY = 'Login',
DESCRIPTION = 'Enables custom usernames by email address.';
@ -17,23 +17,29 @@ class CustomLoginMappingPlugin extends \RainLoop\Plugins\AbstractPlugin
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sImapUser
* @param string $sPassword
* @param string $sSmtpUser
*
* @throws \RainLoop\Exceptions\ClientException
*/
public function FilterLoginCredentials(&$sEmail, &$sLogin, &$sPassword)
public function FilterLoginCredentials(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$sMapping = \trim($this->Config()->Get('plugin', 'mapping', ''));
if (!empty($sMapping)) {
$aLines = \explode("\n", \preg_replace('/[\r\n\t\s]+/', "\n", $sMapping));
foreach ($aLines as $sLine) {
if (false !== \strpos($sLine, ':')) {
$aData = \explode(':', $sLine, 2);
$aData = \explode(':', $sLine, 3);
if (\is_array($aData) && !empty($aData[0]) && isset($aData[1])) {
$aData = \array_map('trim', $aData);
if ($sEmail === $aData[0] && \strlen($aData[1])) {
$sLogin = $aData[1];
if ($sEmail === $aData[0]) {
if (\strlen($aData[1])) {
$sImapUser = $aData[1];
}
if (isset($aData[2]) && \strlen($aData[2])) {
$sSmtpUser = $aData[2];
}
}
}
}
@ -46,8 +52,8 @@ class CustomLoginMappingPlugin extends \RainLoop\Plugins\AbstractPlugin
return array(
\RainLoop\Plugins\Property::NewInstance('mapping')->SetLabel('Mapping')
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING_TEXT)
->SetDescription('email:login mapping')
->SetDefaultValue("user@domain.com:user.bob\nadmin@domain.com:user.john")
->SetDescription('email:imap-login:smtp-login mapping')
->SetDefaultValue("user@domain.com:imapuser.bob:smtpuser.bob\nadmin@domain.com:imapuser.john")
);
}
}

View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2022 SnappyMail
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

9526
plugins/ics-viewer/ical.js Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,22 @@
<?php
class ICSViewerPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'ICS Viewer',
AUTHOR = 'PhieF',
VERSION = '1.0',
RELEASE = '2024-09-17',
CATEGORY = 'Messages',
DESCRIPTION = 'Display ICS attachment using ical lib, or JSON-LD details, based on viewICS',
REQUIRED = '2.34.0';
public function Init() : void
{
// $this->UseLangs(true);
$this->addJs('message.js');
$this->addJs('windowsZones.js');
// Load https://github.com/kewisch/ical.js/releases
$this->addJs('ical.js');
}
}

View file

@ -0,0 +1,136 @@
(rl => {
const templateId = 'MailMessageView';
addEventListener('rl-view-model.create', e => {
if (templateId === e.detail.viewModelTemplateID) {
const
template = document.getElementById(templateId),
view = e.detail,
attachmentsPlace = template.content.querySelector('.attachmentsPlace'),
dateRegEx = /(TZID=(?<tz>[^:]+):)?(?<year>[0-9]{4})(?<month>[0-9]{2})(?<day>[0-9]{2})T(?<hour>[0-9]{2})(?<minute>[0-9]{2})(?<second>[0-9]{2})(?<utc>Z?)/,
parseDate = str => {
let parts = dateRegEx.exec(str)?.groups,
options = {dateStyle: 'long', timeStyle: 'short'},
date = (parts ? new Date(
parseInt(parts.year, 10),
parseInt(parts.month, 10) - 1,
parseInt(parts.day, 10),
parseInt(parts.hour, 10),
parseInt(parts.minute, 10),
parseInt(parts.second, 10)
) : new Date(str));
parts?.tz && (options.timeZone = windowsVTIMEZONEs[parts.tz] || parts.tz);
try {
return date.format(options);
} catch (e) {
console.error(e);
if (options.timeZone) {
options.timeZone = undefined;
return date.format(options);
}
}
};
attachmentsPlace.after(Element.fromHTML(`
<details data-bind="if: ICSViewer, visible: ICSViewer">
<summary data-icon="📅" data-bind="text: ICSViewer().SUMMARY"></summary>
<table><tbody style="white-space:pre">
<tr data-bind="visible: ICSViewer().ORGANIZER_TXT"><td>Organizer: </td><td><a data-bind="text: ICSViewer().ORGANIZER_TXT, attr: { href: ICSViewer().ORGANIZER_MAIL }"></a></td></tr>
<tr><td>Start: </td><td data-bind="text: ICSViewer().DTSTART"></td></tr>
<tr><td>End: </td><td data-bind="text: ICSViewer().DTEND"></td></tr>
<tr data-bind="visible: ICSViewer().LOCATION"><td>Location: </td><td data-bind="text: ICSViewer().LOCATION"></td></tr>
<!-- <tr><td>Transparency</td><td data-bind="text: ICSViewer().TRANSP"></td></tr>-->
<tr><td>Attendees: </td><td data-bind="foreach: ICSViewer().ATTENDEE"><span data-bind="text: $data.replace(/;/g,';\\n')"></span> </td>
</tbody></table>
</details>`));
view.ICSViewer = ko.observable(null);
view.saveICS = () => {
let VEVENT = view.VEVENT();
if (VEVENT) {
if (rl.nextcloud && VEVENT.rawText) {
rl.nextcloud.selectCalendar()
.then(href => href && rl.nextcloud.calendarPut(href, VEVENT));
} else {
// TODO
}
}
}
/**
* TODO
*/
view.message.subscribe(msg => {
view.ICSViewer(null);
if (msg) {
// JSON-LD after parsing HTML
// See http://schema.org/
msg.linkedData.subscribe(data => {
if (!view.ICSViewer()) {
data.forEach(item => {
if (item["ical:summary"]) {
let VEVENT = {
SUMMARY: item["ical:summary"],
DTSTART: parseDate(item["ical:dtstart"]),
// DTEND: parseDate(item["ical:dtend"]),
// TRANSP: item["ical:transp"],
// LOCATION: item["ical:location"],
ATTENDEE: []
}
view.ICSViewer(VEVENT);
return;
}
});
}
});
// ICS attachment
// let ics = msg.attachments.find(attachment => 'application/ics' == attachment.mimeType);
let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType);
if (ics && ics.download) {
// fetch it and parse the VEVENT
rl.fetch(ics.linkDownload())
.then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response })))
.then(text => {
let jcalData = ICAL.parse(text)
var comp = new ICAL.Component(jcalData);
var vevent = comp.getFirstSubcomponent("vevent");
var event = new ICAL.Event(vevent);
let VEVENT = {};
if (event.organizer && event.organizer.startsWith("mailto:")) {
VEVENT.ORGANIZER_TXT = event.organizer.substr(7)
VEVENT.ORGANIZER_MAIL = event.organizer
} else
VEVENT.ORGANIZER_TXT = event.organizer
VEVENT.SUMMARY = event.summary;
VEVENT.DTSTART = parseDate(vevent.getFirstPropertyValue("dtstart"));
VEVENT.DTEND = parseDate(vevent.getFirstPropertyValue("dtend"));
VEVENT.LOCATION = event.location;
VEVENT.ATTENDEE = []
for (let attendee of event.attendees) {
VEVENT.ATTENDEE.push(attendee.getFirstParameter("cn"));
}
if (VEVENT) {
VEVENT.rawText = text;
VEVENT.isCancelled = () => VEVENT.STATUS?.includes('CANCELLED');
VEVENT.isConfirmed = () => VEVENT.STATUS?.includes('CONFIRMED');
VEVENT.shouldReply = () => VEVENT.METHOD?.includes('REPLY');
console.dir({
isCancelled: VEVENT.isCancelled(),
shouldReply: VEVENT.shouldReply()
});
view.ICSViewer(VEVENT);
}
});
}
}
});
}
});
})(window.rl);

View file

@ -0,0 +1,44 @@
/**
* .SML-@type where @type is the value of the JSON-LD "@type":
* See http://schema.org/
*/
.SML-FlightReservation {
}
.SML-Airline {
}
.SML-Airport {
}
.SML-Flight {
}
.SML-FoodEstablishmentReservation {
}
.SML-FoodEstablishment {
}
.SML-ParcelDelivery {
}
.SML-Order {
}
.SML-Organization {
}
.SML-Product {
}
.SML-PostalAddress {
}
.SML-Person {
}
.SML-PromotionCard {
}

View file

@ -8,10 +8,10 @@ class LDAPLoginMappingPlugin extends AbstractPlugin
{
const
NAME = 'LDAP login mapping',
VERSION = '2.2',
VERSION = '2.3',
AUTHOR = 'RainLoop Team, Ludovic Pouzenc<ludovic@pouzenc.fr>, ZephOne<zephone@protonmail.com>',
RELEASE = '2024-03-12',
REQUIRED = '2.35.3',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Login',
DESCRIPTION = 'Enable custom mapping using ldap field';
/**
@ -79,12 +79,13 @@ class LDAPLoginMappingPlugin extends AbstractPlugin
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sImapUser
* @param string $sPassword
* @param string $sSmtpUser
*
* @throws \RainLoop\Exceptions\ClientException
*/
public function FilterLoginСredentials(&$sEmail, &$sLogin, &$sPassword)
public function FilterLoginСredentials(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$this->oLogger = \RainLoop\Api::Logger();
@ -102,10 +103,10 @@ class LDAPLoginMappingPlugin extends AbstractPlugin
$sIP = $_SERVER['REMOTE_ADDR'];
$sResult = $this->ldapSearch($sEmail);
if ( is_array($sResult) ) {
$sLogin = $sResult['login'];
$sImapUser = $sResult['login'];
$sEmail = $sResult['email'];
}
syslog(LOG_WARNING, "plugins/ldap-login-mapping/index.php:FilterLoginСredentials() auth try: $sIP/$sEmail, resolved as $sLogin/$sEmail");
syslog(LOG_WARNING, "plugins/ldap-login-mapping/index.php:FilterLoginСredentials() auth try: $sIP/$sEmail, resolved as $sImapUser/$sEmail");
}
}

View file

@ -12,10 +12,10 @@ class LdapMailAccountsPlugin extends AbstractPlugin
{
const
NAME = 'LDAP Mail Accounts',
VERSION = '2.2.0',
VERSION = '2.2.1',
AUTHOR = 'cm-schl',
URL = 'https://github.com/cm-sch',
RELEASE = '2024-05-28',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Accounts',
DESCRIPTION = 'Add additional mail accounts the SnappyMail user has access to by a LDAP query. Basing on the work of FWest98 (https://github.com/FWest98).';
@ -44,7 +44,7 @@ class LdapMailAccountsPlugin extends AbstractPlugin
* @param string &$sPassword
* @param string &$sSmtpUser
*/
public function overwriteMainAccountEmail(&$sEmail, &$sImapUser, &$sPassword, &$sSmtpUser)
public function overwriteMainAccountEmail(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$this->Manager()->Actions()->Logger()->Write("Login DATA: login: $sImapUser email: $sEmail", \LOG_WARNING, "LDAP MAIL ACCOUNTS PLUGIN");
@ -100,7 +100,7 @@ class LdapMailAccountsPlugin extends AbstractPlugin
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
->SetDescription("SnappyMail saves the passwords of the additional accounts by encrypting them using a cryptkey that is saved in the file \".cryptkey\". When the password of the main account changes, SnappyMail asks the user for the old password to reencrypt the keys with the new userpassword.
\nOn a password change using ldap (or when the password has been forgotten by the user) this makes problems and asks the user to insert the old password. Therefore activating this option overwrites the .cryptkey file on login in order to always accept the actual ldap password of the user.
\nATTENTION: This has side effects on pgp keys because these are also secured by the cryptkey and could therefore not be accessible anymore!
\nATTENTION: This has side effects on pgp keys because these are also secured by the cryptkey and could therefore not be accessible anymore!
\nSee https://github.com/the-djmaze/snappymail/issues/1570#issuecomment-2085528061")
->SetDefaultValue(false),
]);

View file

@ -401,7 +401,7 @@ class Client
* @param int $form_content_type HTTP form content type to use
* @return array
*/
private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
private function executeRequest($url, $parameters = array(), $http_method = self::HTTP_METHOD_GET, ?array $http_headers = null, $form_content_type = self::HTTP_FORM_CONTENT_TYPE_MULTIPART)
{
$curl_options = array(
CURLOPT_RETURNTRANSFER => true,

View file

@ -4,9 +4,9 @@ class LoginOverridePlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Login Override',
VERSION = '2.3',
RELEASE = '2024-03-12',
REQUIRED = '2.35.3',
VERSION = '2.4',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Filters',
DESCRIPTION = 'Override IMAP/SMTP login credentials for specific users.';
@ -17,7 +17,7 @@ class LoginOverridePlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addHook('smtp.before-login', 'MapSmtpCredentials');
}
public function MapEmailAddress(string &$sEmail, string &$sLogin, string &$sPassword)
public function MapEmailAddress(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$sMapping = \trim($this->Config()->Get('plugin', 'email_mapping', ''));
if (!empty($sMapping)) {

View file

@ -6,8 +6,8 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Login Remote',
AUTHOR = 'SnappyMail',
URL = 'https://snappymail.eu/',
VERSION = '1.4',
RELEASE = '2024-03-27',
VERSION = '1.5',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Login',
LICENSE = 'MIT',
@ -56,7 +56,7 @@ class LoginRemotePlugin extends \RainLoop\Plugins\AbstractPlugin
return true;
}
public function FilterLoginCredentials(&$sEmail, &$sImapUser, &$sPassword, &$sSmtpUser)
public function FilterLoginCredentials(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
// cPanel https://github.com/the-djmaze/snappymail/issues/697
// && !empty($_ENV['CPANEL'])

View file

@ -6,9 +6,9 @@ class LoginVirtuserPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Virtuser Login',
AUTHOR = 'v20z',
URL = 'https://github.com/the-djmaze/snappymail/issues/1691',
VERSION = '0.1',
RELEASE = '2024-06-01',
REQUIRED = '2.5.0',
VERSION = '0.2',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Login',
DESCRIPTION = 'File based Email-to-User lookup.';
@ -19,12 +19,13 @@ class LoginVirtuserPlugin extends \RainLoop\Plugins\AbstractPlugin
/**
* @param string $sEmail
* @param string $sLogin
* @param string $sImapUser
* @param string $sPassword
* @param string $sSmtpUser
*
* @throws \RainLoop\Exceptions\ClientException
*/
public function ParseVirtuserFiles(&$sEmail, &$sLogin, &$sPassword)
public function ParseVirtuserFiles(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$sFiles = \trim($this->Config()->Get('plugin', 'virtuser_files', ''));
if (!empty($sFiles))
@ -46,7 +47,7 @@ class LoginVirtuserPlugin extends \RainLoop\Plugins\AbstractPlugin
$aData = preg_split( '/[[:blank:]]+/', $sLine, 3, PREG_SPLIT_NO_EMPTY);
if (is_array($aData) && !empty($aData[0]) && isset($aData[1])) {
if ($sEmail === $aData[0] && 0 < strlen($aData[1])) {
$sLogin = $aData[1];
$sImapUser = $aData[1];
return;
}
}

View file

@ -4,11 +4,11 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Nextcloud',
VERSION = '2.37.0',
RELEASE = '2024-08-11',
VERSION = '2.38.0',
RELEASE = '2024-09-16',
CATEGORY = 'Integrations',
DESCRIPTION = 'Integrate with Nextcloud v20+',
REQUIRED = '2.36.2';
REQUIRED = '2.38.0';
private const IGNORE_SYSTEM_ADDRESSBOOK_KEY = 'ignoreSystemAddressbook';
private const IGNORE_SYSTEM_ADDRESSBOOK_DEFAULT_VALUE = true;
@ -55,6 +55,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addTemplate('templates/PopupsNextcloudFiles.html');
$this->addTemplate('templates/PopupsNextcloudCalendars.html');
$this->addTemplate('templates/PopupsNextcloudInvites.html');
// $this->addHook('login.credentials.step-2', 'loginCredentials2');
// $this->addHook('login.credentials', 'loginCredentials');
@ -163,32 +164,17 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
{
// https://apps.nextcloud.com/apps/oidc_login
$config = \OC::$server->getConfig();
$oUser = \OC::$server->getUserSession()->getUser();
$sUID = $oUser->getUID();
$sEmail = $config->getUserValue($sUID, 'snappymail', 'snappymail-email');
$sPassword = $config->getUserValue($sUID, 'snappymail', 'passphrase')
?: $config->getUserValue($sUID, 'snappymail', 'snappymail-password');
$bAccountDefinedExplicitly = ($sEmail && $sPassword) && $sEmail === $oSettings->username;
$sNcEmail = $oUser->getEMailAddress() ?: $oUser->getPrimaryEMailAddress();
// Only login with OIDC access token if
// it is enabled in config, the user is currently logged in with OIDC,
// the current snappymail account is the OIDC account and no account defined explicitly
if (\OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-autologin-oidc', false)
&& \OC::$server->getSession()->get('is_oidc')
&& $sNcEmail === $oSettings->username
&& !$bAccountDefinedExplicitly
if ($oAccount instanceof \RainLoop\Model\MainAccount
&& \OCA\SnappyMail\Util\SnappyMailHelper::isOIDCLogin()
// && $oClient->supportsAuthType('OAUTHBEARER') // v2.28
&& \str_starts_with($oSettings->passphrase, 'oidc_login|')
) {
$sAccessToken = \OC::$server->getSession()->get('oidc_access_token');
if ($sAccessToken) {
$oSettings->passphrase = $sAccessToken;
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
}
// $oSettings->passphrase = \OC::$server->getSession()->get('snappymail-passphrase');
$oSettings->passphrase = \OC::$server->getSession()->get('oidc_access_token');
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
}
}

View file

@ -21,9 +21,18 @@
// https://github.com/nextcloud/calendar/issues/4684
if (cfg.CalDAV) {
attachmentsControls.append(Element.fromHTML(`<span data-bind="visible: nextcloudICS" data-icon="📅">
attachmentsControls.append(Element.fromHTML(`<span data-bind="visible: nextcloudICSShow" data-icon="📅">
<span class="g-ui-link" data-bind="click: nextcloudSaveICS" data-i18n="NEXTCLOUD/SAVE_ICS"></span>
</span>`));
attachmentsControls.append(Element.fromHTML(`<span data-bind="visible: nextcloudICSOldInvitation" data-icon="📅">
<span data-i18n="NEXTCLOUD/OLD_INVITATION"></span>
</span>`))
attachmentsControls.append(Element.fromHTML(`<span data-bind="visible: nextcloudICSNewInvitation" data-icon="📅">
<span class="g-ui-link" data-bind="click: nextcloudSaveICS" data-i18n="NEXTCLOUD/UPDATE_ON_MY_CALENDAR"></span>
</span>`))
attachmentsControls.append(Element.fromHTML(`<span data-bind="visible: nextcloudICSLastInvitation" data-icon="📅">
<span data-i18n="NEXTCLOUD/LAST_INVITATION"></span>
</span>`))
}
}
/*
@ -107,18 +116,169 @@
};
view.nextcloudICS = ko.observable(null);
view.nextcloudICSOldInvitation = ko.observable(null);
view.nextcloudICSNewInvitation = ko.observable(null);
view.nextcloudICSLastInvitation = ko.observable(null);
view.nextcloudSaveICS = () => {
view.nextcloudICSShow = ko.observable(null);
view.nextcloudICSCalendar = ko.observable(null);
view.filteredEventsUrls = ko.observable([]);
view.nextcloudSaveICS = async () => {
let VEVENT = view.nextcloudICS();
VEVENT && rl.nextcloud.selectCalendar()
.then(href => href && rl.nextcloud.calendarPut(href, VEVENT));
VEVENT = await view.handleUpdatedRecurrentEvents(VEVENT)
VEVENT && rl.nextcloud.selectCalendar(VEVENT)
}
view.handleUpdatedRecurrentEvents = async (VEVENT) => {
const uid = VEVENT.UID
let makePUTRequest = false
const filteredEventUrls = view.filteredEventUrls
if (filteredEventUrls.length > 1) {
// console.warn('filteredEventUrls.length > 1')
}
else if (filteredEventUrls.length == 1) {
const eventUrl = filteredEventUrls[0]
const eventText = await fetchEvent(eventUrl)
// don't do anything for equal cards
if (VEVENT.rawText == eventText) {
return VEVENT
}
const newVeventsText = extractVEVENTs(VEVENT.rawText)
const oldVeventsText = extractVEVENTs(eventText)
// if there's only one event in the old card, it can't be an edit of the exception card
if (oldVeventsText.length == 1) {
const newRecurrenceId = extractProperties('RECURRENCE-ID', newVeventsText[0])
// if there's a property RECURRENCE-ID in the new card, it's an recurrence exception event
if (newRecurrenceId.length > 0) {
const updatedVEVENT = {
'SUMMARY' : VEVENT.SUMMARY,
'UID' : VEVENT.UID,
'rawText' : mergeEventTexts(eventText, newVeventsText[0])
}
VEVENT = updatedVEVENT
makePUTRequest = true
}
else {
return VEVENT
}
}
// if there's more than one event in the old card, it's possible to be an inclusion of a new exception card
// or update of old exception card
else {
let recurrenceIdMatch = false
let isUpdate = false
const updateData = {
'oldEventIndex': null,
'newEventIndex': null,
}
// check if it's an update
for (let i = 0; i < oldVeventsText.length; i++) {
let oldVeventText = oldVeventsText[i]
for (let j = 0; j < newVeventsText.length; j++) {
let newVeventText = newVeventsText[j]
let oldRecurrenceId = extractProperties('RECURRENCE-ID', oldVeventText)
let newRecurrenceId = extractProperties('RECURRENCE-ID', newVeventText)
let oldSequence = extractProperties('SEQUENCE', oldVeventText)
let newSequence = extractProperties('SEQUENCE', newVeventText)
if (oldRecurrenceId.length == 0 || newRecurrenceId.length == 0 || oldSequence.length == 0 || newSequence.length == 0) {
continue
}
if (oldRecurrenceId[0] == newRecurrenceId[0]) {
if (newSequence[0] > oldSequence[0]) {
isUpdate = true
updateData.oldEventIndex = i
updateData.newEventIndex = j
i = oldVeventsText.length
j = newVeventsText.length
}
}
}
}
// if it's an update...
if (isUpdate) {
// substitute old event text for new event text
const oldEventStart = eventText.indexOf(oldVeventsText[updateData.oldEventIndex])
const oldEventEnd = oldEventStart + oldVeventsText[updateData.oldEventIndex].length
const newEvent = eventText.substring(0, oldEventStart) + newVeventsText[updateData.newEventIndex] + eventText.substring(oldEventEnd)
const updatedVEVENT = {
'SUMMARY' : VEVENT.SUMMARY,
'UID': VEVENT.UID,
'rawText' : newEvent
}
VEVENT = updatedVEVENT
makePUTRequest = true
}
// if it's not an update, it's an inclusion, as there's no match of RECURRENCE-ID
else {
const updatedVEVENT = {
'SUMMARY' : VEVENT.SUMMARY,
'UID' : VEVENT.UID,
'rawText' : mergeEventTexts(eventText, newVeventsText[0])
}
VEVENT = updatedVEVENT
makePUTRequest = true
}
}
}
if (makePUTRequest) {
let href = "/" + (filteredEventUrls[0].split('/').slice(5, -1)[0])
rl.nextcloud.calendarPut(href, VEVENT, (response) => {
if (response.status != 201 && response.status != 204) {
InvitesPopupView.showModal([
rl.i18n('NEXTCLOUD/EVENT_UPDATE_FAILURE_TITLE'),
rl.i18n('NEXTCLOUD/EVENT_UPDATE_FAILURE_BODY', {eventName: VEVENT.SUMMARY})
])
return
}
InvitesPopupView.showModal([
rl.i18n('NEXTCLOUD/EVENT_UPDATED_TITLE'),
rl.i18n('NEXTCLOUD/EVENT_UPDATED_BODY', {eventName: VEVENT.SUMMARY})
])
})
return null
}
return VEVENT
}
/**
* TODO
*/
view.message.subscribe(msg => {
view.nextcloudICS(null);
view.nextcloudICSOldInvitation(null);
view.nextcloudICSNewInvitation(null);
view.nextcloudICSLastInvitation(null);
view.nextcloudICSShow(view.nextcloudICS())
if (msg && cfg.CalDAV) {
// let ics = msg.attachments.find(attachment => 'application/ics' == attachment.mimeType);
let ics = msg.attachments.find(attachment => 'text/calendar' == attachment.mimeType);
@ -126,7 +286,7 @@
// fetch it and parse the VEVENT
rl.fetch(ics.linkDownload())
.then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response })))
.then(text => {
.then(async (text) => {
let VEVENT,
VALARM,
multiple = ['ATTACH','ATTENDEE','CATEGORIES','COMMENT','CONTACT','EXDATE',
@ -177,6 +337,158 @@
shouldReply: VEVENT.shouldReply()
});
view.nextcloudICS(VEVENT);
view.nextcloudICSShow(true);
// try to get calendars, save
const calendarUrls = await fetchCalendarUrls()
const filteredEventUrls = []
for (let i = 0; i < calendarUrls.length; i++) {
let calendarUrl = calendarUrls[i]
const skipCalendars = ['/inbox/', '/outbox/', '/trashbin/']
let skip = false
for (let j = 0; j < skipCalendars.length; j++) {
if (calendarUrl.includes(skipCalendars[j])) {
skip = true
break
}
}
if (skip) {
continue
}
// try to get event
const eventUrls = await fetchEventUrl(calendarUrl, VEVENT.UID)
if (eventUrls.length == 0) {
continue
}
eventUrls.forEach((url) => {
filteredEventUrls.push(url)
})
}
view.filteredEventUrls = filteredEventUrls
// if there's none, save in view.nextcloudICS
if (filteredEventUrls.length == 0) {
view.nextcloudICS(VEVENT);
view.nextcloudICSShow(true)
}
// if there's some...
else {
const savedEvent = await fetchEvent(filteredEventUrls[0])
const newVeventsText = extractVEVENTs(VEVENT.rawText)
const oldVeventsText = extractVEVENTs(savedEvent)
// if there's more than one event in the old card, it's possible to be inclusion of new exception card
// or updated of old exception card
if (oldVeventsText.length > 1) {
let recurrenceIdMatch = false
let oldNewestCreated = null
let newNewestCreated = null
// check if it's an update
for (let i = 0; i < oldVeventsText.length; i++) {
let oldVeventText = oldVeventsText[i]
for (let j = 0; j < newVeventsText.length; j++) {
let newVeventText = newVeventsText[j]
let oldRecurrenceId = extractProperties('RECURRENCE-ID', oldVeventText)
let newRecurrenceId = extractProperties('RECURRENCE-ID', newVeventText)
let oldSequence = extractProperties('SEQUENCE', oldVeventText)
let newSequence = extractProperties('SEQUENCE', newVeventText)
if (newRecurrenceId.length == 0 && oldRecurrenceId.length == 1) {
view.nextcloudICSShow(false)
view.nextcloudICSOldInvitation(true)
}
if (oldRecurrenceId.length > 0 && newRecurrenceId.length > 0 && oldSequence.length > 0 && newSequence.length > 0) {
if (oldRecurrenceId[0] == newRecurrenceId[0]) {
if (newSequence[0] < oldSequence[0]) {
view.nextcloudICSOldInvitation(true)
view.nextcloudICSShow(false)
}
else if (newSequence[0] == oldSequence[0]) {
view.nextcloudICSLastInvitation(true)
view.nextcloudICSShow(false)
}
else if (newSequence[0] > oldSequence[0]) {
view.nextcloudICSNewInvitation(true)
view.nextcloudICSShow(false)
}
// exit for loops
j = newVeventsText.length
i = oldVeventsText.length
}
}
let oldCreated = extractProperties('CREATED', oldVeventText)
let newCreated = extractProperties('CREATED', newVeventText)
if (oldCreated.length == 0 || newCreated.length == 0) {
continue
}
const formattedOldDate = oldCreated[0].replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/, '$1-$2-$3T$4:$5:$6Z');
const formattedNewDate = newCreated[0].replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/, '$1-$2-$3T$4:$5:$6Z');
const oldDate = new Date(formattedOldDate)
const newDate = new Date(formattedNewDate)
if (oldNewestCreated == null || oldDate > oldNewestCreated) {
oldNewestCreated = oldDate
}
if (newNewestCreated == null || newDate > newNewestCreated) {
newNewestCreated = newDate
}
}
}
if (newNewestCreated != null && oldNewestCreated != null) {
if (newNewestCreated < oldNewestCreated) {
view.nextcloudICSOldInvitation(true)
view.nextcloudICSShow(false)
}
else if (newNewestCreated == oldNewestCreated) {
view.nextcloudICSLastInvitation(true)
view.nextcloudICSShow(false)
}
}
}
else {
const oldLastModified = extractProperties('LAST-MODIFIED', oldVeventsText[0])
const newLastModified = extractProperties('LAST-MODIFIED', newVeventsText[0])
if (oldLastModified.length == 1 && newLastModified.length == 1) {
const formattedOldDate = oldLastModified[0].replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/, '$1-$2-$3T$4:$5:$6Z');
const formattedNewDate = newLastModified[0].replace(/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})Z/, '$1-$2-$3T$4:$5:$6Z');
const oldDate = new Date(formattedOldDate)
const newDate = new Date(formattedNewDate)
if (newDate > oldDate) {
view.nextcloudICSNewInvitation(true)
view.nextcloudICSShow(false)
}
else if (newDate < oldDate) {
view.nextcloudICSOldInvitation(true)
view.nextcloudICSShow(false)
}
else {
view.nextcloudICSLastInvitation(true)
view.nextcloudICSShow(false)
}
}
}
}
}
});
}
@ -186,3 +498,148 @@
});
})(window.rl);
async function fetchCalendarUrls () {
const username = OC.currentUser
const requestToken = OC.requestToken
const url = '/remote.php/dav/calendars/' + username
const response = await fetch(url, {
'method': 'PROPFIND',
'headers': {
'Depth': '1',
'Content-Type': 'application/xml',
'requesttoken' : requestToken
}
})
if (!response.ok) {
throw new Error('Error fetching calendars', response)
}
const responseText = await response.text()
const parser = new DOMParser()
const xmlDoc = parser.parseFromString(responseText, 'application/xml')
const calendarUrls = []
const hrefElements = xmlDoc.getElementsByTagName('d:href')
for (let i = 1; i < hrefElements.length; i++) {
let calendarUrl = hrefElements[i].textContent.trim()
calendarUrls.push(calendarUrl)
}
return calendarUrls
}
async function fetchEventUrl (calendarUrl, uid) {
const requestToken = OC.requestToken
const xmlRequestBody = `<?xml version="1.0" encoding="UTF-8" ?>
<C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav">
<C:prop>
<C:calendar-data/>
</C:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:prop-filter name="UID">
<C:text-match collation="i;unicode-casemap" match-type="equals">${uid}</C:text-match>
</C:prop-filter>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>`
const response = await fetch(calendarUrl, {
'method': 'REPORT',
'headers': {
'Content-Type': 'application/xml',
'Depth': 1,
'requesttoken': requestToken
},
'body': xmlRequestBody
})
const responseText = await response.text()
const parser = new DOMParser()
const xmlDoc = parser.parseFromString(responseText, 'application/xml')
const hrefElements = xmlDoc.getElementsByTagName('d:href')
const hrefValues = Array.from(hrefElements).map(element => element.textContent)
return hrefValues
}
async function fetchEvent (eventUrl) {
const requestToken = OC.requestToken
const response = await fetch(eventUrl, {
'method': 'GET',
'headers': {
'requesttoken': requestToken
}
})
const responseText = await response.text()
return responseText
}
function extractVEVENTs(text) {
let lastEndIndex = 0
const vEvents = []
let textToSearch = ""
let beginIndex = 0
let endIndex = 0
let foundVevent = false
while (true) {
textToSearch = text.substring(lastEndIndex)
beginIndex = textToSearch.indexOf('BEGIN:VEVENT')
if (beginIndex == -1) {
break
}
endIndex = textToSearch.substring(beginIndex).indexOf('END:VEVENT')
if (endIndex == -1) {
break
}
endIndex += beginIndex
lastEndIndex = lastEndIndex + endIndex + 'END:VEVENT'.length
foundVevent = textToSearch.substring(beginIndex + 'BEGIN:VEVENT'.length, endIndex)
vEvents.push(foundVevent)
}
return vEvents
}
function extractProperties (property, text) {
const matches = text.match(`${property}.*`)
if (matches == null) {
return []
}
const separatedMatches = matches.map((match) => {
return match.substring(property.length + 1)
})
return separatedMatches
}
function mergeEventTexts (oldEventText, newEventText) {
const appendIndex = oldEventText.indexOf('END:VEVENT') + 'END:VEVENT'.length
const updatedEventText = oldEventText.substring(0, appendIndex) + "\nBEGIN:VEVENT" + newEventText + "END:VEVENT" + oldEventText.substring(appendIndex)
return updatedEventText
}

View file

@ -320,12 +320,28 @@ class NextcloudCalendarsPopupView extends rl.pluginPopupView {
}
onBuild(dom) {
let modalObj = this
this.tree = dom.querySelector('#sm-nc-calendars');
this.tree.addEventListener('click', event => {
let el = event.target;
if (el.matches('button')) {
this.select = el.href;
this.close();
let VEVENT = this.VEVENT
rl.nextcloud.calendarPut(this.select, this.VEVENT, (response) => {
if (response.status != 201 && response.status != 204) {
InvitesPopupView.showModal([
rl.i18n('MESSAGE/EVENT_ADDITION_FAILURE_TITLE'),
rl.i18n('MESSAGE/EVENT_ADDITION_FAILURE_BODY', {eventName: VEVENT.SUMMARY}),
() => {modalObj.close()}
])
}
InvitesPopupView.showModal([
rl.i18n('MESSAGE/EVENT_ADDED_TITLE'),
rl.i18n('MESSAGE/EVENT_ADDED_BODY', {eventName: VEVENT.SUMMARY}),
() => {modalObj.close()}
])
})
}
});
}
@ -375,9 +391,10 @@ class NextcloudCalendarsPopupView extends rl.pluginPopupView {
treeElement.appendChild(li);
}
// Happens after showModal()
beforeShow(fResolve) {
beforeShow(fResolve, VEVENT) {
this.select = '';
this.fResolve = fResolve;
this.VEVENT = VEVENT
this.tree.innerHTML = '';
davFetch('calendars', '/', {
method: 'PROPFIND',
@ -432,14 +449,15 @@ close() {}
}
rl.nextcloud = {
selectCalendar: () =>
selectCalendar: (VEVENT) =>
new Promise(resolve => {
NextcloudCalendarsPopupView.showModal([
href => resolve(href),
VEVENT
]);
}),
calendarPut: (path, event) => {
calendarPut: (path, event, callback) => {
davFetch('calendars', path + '/' + event.UID + '.ics', {
method: 'PUT',
headers: {
@ -463,6 +481,8 @@ rl.nextcloud = {
// response.text().then(text => console.error({status:response.status, body:text}));
Promise.reject(new Error({ response }));
}
callback && callback(response)
});
},
@ -500,3 +520,27 @@ function getElementsInNamespaces(xmlDocument, tagName) {
}
return results;
}
class InvitesPopupView extends rl.pluginPopupView {
constructor() {
super('NextcloudInvites')
}
onBuild(dom) {
this.title = dom.querySelector('#sm-invites-popup-title')
this.body = dom.querySelector('#sm-invites-popup-body')
}
beforeShow(title, body, onHide_) {
this.title.innerHTML = title
this.body.innerHTML = body
this.onHide_ = onHide_
}
onHide() {
if (this.onHide_) {
this.onHide_()
}
}
}

View file

@ -2,14 +2,21 @@
"NEXTCLOUD": {
"SAVE_ATTACHMENTS": "Save in Nextcloud",
"SAVE_EML": "Save as .eml in Nextcloud",
"SAVE_ICS": "Add to calendar",
"SELECT_FOLDER": "Select folder",
"SELECT_FILES": "Select file(s)",
"ATTACH_FILES": "Attach Nextcloud files",
"SELECT_CALENDAR": "Select calendar",
"FILE_ATTACH": "attach",
"FILE_INTERNAL": "internal",
"FILE_PUBLIC": "public",
"ADDRESS_BOOK": "Address Book"
"ADDRESS_BOOK": "Address Book",
"SELECT_CALENDAR": "Select calendar",
"SAVE_ICS": "Add to calendar",
"OLD_INVITATION": "Old invitation",
"UPDATE_ON_MY_CALENDAR": "Update invitation",
"LAST_INVITATION": "Last invitation",
"EVENT_UPDATE_FAILURE_TITLE": "Update failed",
"EVENT_UPDATE_FAILURE_BODY": "Why, i have no clue",
"EVENT_UPDATED_TITLE": "Updated",
"EVENT_UPDATED_BODY": "Why, i have no clue"
}
}

View file

@ -0,0 +1,8 @@
<header>
<a class="close" href="#" data-bind="click: close">×</a>
<h3 id="sm-invites-popup-title"></h3>
</header>
<div class="modal-body form-horizontal" id="sm-invites-popup-body">
</div>
<footer>
</footer>

View file

@ -6,8 +6,8 @@ class ProxyAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
NAME = 'Proxy Auth',
AUTHOR = 'Philipp',
URL = 'https://www.mundhenk.org/',
VERSION = '0.4',
RELEASE = '2024-05-26',
VERSION = '0.5',
RELEASE = '2024-09-20',
REQUIRED = '2.36.1',
CATEGORY = 'Login',
LICENSE = 'MIT',
@ -41,7 +41,7 @@ class ProxyAuthPlugin extends \RainLoop\Plugins\AbstractPlugin
return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) );
}
public function MapEmailAddress(string &$sEmail, string &$sLogin, string &$sPassword)
public function MapEmailAddress(string &$sEmail, string &$sImapUser, string &$sPassword, string &$sSmtpUser)
{
$oActions = \RainLoop\Api::Actions();
$oLogger = $oActions->Logger();

869
plugins/view-ics/ical.js Normal file
View file

@ -0,0 +1,869 @@
// https://www.rfc-editor.org/rfc/rfc5545
(rl => {
const
paramRegEx = /;([a-zA-Z0-9-]+)=([^";:,]*|"[^"]*")/g,
// eslint-disable-next-line max-len
dateRegEx = /(?<year>[0-9]{4})(?<month>[0-9]{2})(?<day>[0-9]{2})T(?<hour>[0-9]{2})(?<minute>[0-9]{2})(?<second>[0-9]{2})(?<utc>Z?)/,
parseDate = (str, tz) => {
let parts = dateRegEx.exec(str)?.groups,
options = {dateStyle: 'long', timeStyle: 'short'},
date = (parts ? new Date(
parseInt(parts.year, 10),
parseInt(parts.month, 10) - 1,
parseInt(parts.day, 10),
parseInt(parts.hour, 10),
parseInt(parts.minute, 10),
parseInt(parts.second, 10)
) : new Date(str));
tz && (options.timeZone = windowsVTIMEZONEs[tz] || tz);
try {
return date.format(options);
} catch (e) {
console.error(e);
if (options.timeZone) {
options.timeZone = undefined;
return date.format(options);
}
}
};
class Property extends String
{
constructor(name, value, params) {
super(value);
this.name = name;
// this.value = value;
this.params = {};
if (params) {
for (const param of params.matchAll(paramRegEx)) {
if (param[2]) {
this.params[param[1]] = param[2].replace(/^"|"$/);
}
}
}
}
/*
includes(...params) {
return this.value.includes(...params);
}
replace(...params) {
return this.value.replace(...params);
}
toString() {
return this.value;
}
*/
static fromString(data) {
// Parse component property 'name *(";" param ) ":" value'
const match = data.match(/^([a-zA-Z0-9-]+)((?:;[a-zA-Z0-9-]+=(?:[^";:,]*|"[^"]*"))*):(.+)$/);
return match && new Property(match[1], match[3], match[2]);
}
}
rl.ICS = {
parseDate: parseDate,
parseEvent(text) {
let VEVENT,
VALARM,
multiple = ['ATTACH','ATTENDEE','CATEGORIES','COMMENT','CONTACT','EXDATE',
'EXRULE','RSTATUS','RELATED','RESOURCES','RDATE','RRULE'],
lines = text.split(/\r?\n/),
i = lines.length;
while (i--) {
let line = lines[i], prop;
if (VEVENT) {
while (line.startsWith(' ') && i--) {
line = lines[i] + line.slice(1);
}
if (line.startsWith('END:VALARM')) {
// Start parsing Alarm Component
VALARM = {};
continue;
} else if (line.startsWith('BEGIN:VALARM')) {
// End parsing Alarm Component
VEVENT.VALARM || (VEVENT.VALARM = []);
VEVENT.VALARM.push(VALARM);
VALARM = null;
continue;
} else if (line.startsWith('BEGIN:VEVENT')) {
// End parsing
break;
}
prop = Property.fromString(line);
if (prop) {
if (VALARM) {
VALARM[prop.name] = prop;
} else if (multiple.includes(prop.name) || 'X-' == prop.name.slice(0,2)) {
VEVENT[prop.name] || (VEVENT[prop.name] = []);
VEVENT[prop.name].push(prop);
} else {
if ('DTSTART' === prop.name || 'DTEND' === prop.name) {
prop = parseDate(prop, prop.params.TZID);
}
VEVENT[prop.name] = prop;
}
}
} else if (line.startsWith('END:VEVENT')) {
// Start parsing Event Component
VEVENT = {};
}
}
// METHOD:REPLY || METHOD:REQUEST
if (VEVENT) {
VEVENT.rawText = text;
VEVENT.isCancelled = () => VEVENT.STATUS?.includes('CANCELLED');
VEVENT.isConfirmed = () => VEVENT.STATUS?.includes('CONFIRMED');
VEVENT.shouldReply = () => VEVENT.METHOD?.includes('REPLY');
console.dir({
VEVENT,
isCancelled: VEVENT.isCancelled(),
shouldReply: VEVENT.shouldReply()
});
}
return VEVENT;
}
};
// Microsoft Windows timezones
// Subset from https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/windowsZones.json
const windowsVTIMEZONEs = {
// Windows : [IANA...]
"Afghanistan Standard Time": [
"Asia/Kabul"
],
"Alaskan Standard Time": [
"America/Anchorage"/*,
"America/Juneau",
"America/Metlakatla",
"America/Nome",
"America/Sitka",
"America/Yakutat"*/
],
"Aleutian Standard Time": [
"America/Adak"
],
"Altai Standard Time": [
"Asia/Barnaul"
],
"Arab Standard Time": [
"Asia/Aden"/*,
"Asia/Bahrain",
"Asia/Kuwait",
"Asia/Qatar",
"Asia/Riyadh"
*/],
"Arabian Standard Time": [
"Asia/Dubai"/*,
"Asia/Muscat",
"Etc/GMT-4"
*/],
"Arabic Standard Time": [
"Asia/Baghdad"
],
"Argentina Standard Time": [
"America/Argentina/La_Rioja"/*,
"America/Argentina/Rio_Gallegos",
"America/Argentina/Salta",
"America/Argentina/San_Juan",
"America/Argentina/San_Luis",
"America/Argentina/Tucuman",
"America/Argentina/Ushuaia",
"America/Buenos_Aires",
"America/Catamarca",
"America/Cordoba",
"America/Jujuy",
"America/Mendoza"
*/],
"Astrakhan Standard Time": [
"Europe/Astrakhan"/*,
"Europe/Ulyanovsk"
*/],
"Atlantic Standard Time": [
"America/Glace_Bay"/*,
"America/Goose_Bay",
"America/Halifax",
"America/Moncton",
"America/Thule",
"Atlantic/Bermuda"
*/],
"AUS Central Standard Time": [
"Australia/Darwin"
],
"Aus Central W. Standard Time": [
"Australia/Eucla"
],
"AUS Eastern Standard Time": [
"Australia/Melbourne"/*,
"Australia/Sydney"
*/],
"Azerbaijan Standard Time": [
"Asia/Baku"
],
"Azores Standard Time": [
"America/Scoresbysund"/*,
"Atlantic/Azores"
*/],
"Bahia Standard Time": [
"America/Bahia"
],
"Bangladesh Standard Time": [
"Asia/Dhaka"/*,
"Asia/Thimphu"
*/],
"Belarus Standard Time": [
"Europe/Minsk"
],
"Bougainville Standard Time": [
"Pacific/Bougainville"
],
"Canada Central Standard Time": [
"America/Regina"/*,
"America/Swift_Current"
*/],
"Cape Verde Standard Time": [
"Atlantic/Cape_Verde"/*,
"Etc/GMT+1"
*/],
"Caucasus Standard Time": [
"Asia/Yerevan"
],
"Cen. Australia Standard Time": [
"Australia/Adelaide"/*,
"Australia/Broken_Hill"
*/],
"Central America Standard Time": [
"America/Belize"/*,
"America/Costa_Rica",
"America/El_Salvador",
"America/Guatemala",
"America/Managua",
"America/Tegucigalpa",
"Pacific/Galapagos",
"Etc/GMT+6"
*/],
"Central Asia Standard Time": [
"Asia/Almaty"/*,
"Asia/Bishkek",
"Asia/Qostanay",
"Asia/Urumqi",
"Indian/Chagos",
"Antarctica/Vostok",
"Etc/GMT-6"
*/],
"Central Brazilian Standard Time": [
"America/Campo_Grande"/*,
"America/Cuiaba"
*/],
"Central Europe Standard Time": [
"Europe/Belgrade"/*,
"Europe/Bratislava",
"Europe/Budapest",
"Europe/Ljubljana",
"Europe/Podgorica",
"Europe/Prague",
"Europe/Tirane"
*/],
"Central European Standard Time": [
"Europe/Sarajevo"/*,
"Europe/Skopje",
"Europe/Warsaw",
"Europe/Zagreb"
*/],
"Central Pacific Standard Time": [
"Pacific/Efate"/*,
"Pacific/Guadalcanal",
"Pacific/Noumea",
"Pacific/Ponape Pacific/Kosrae",
"Antarctica/Macquarie",
"Etc/GMT-11"
*/],
"Central Standard Time": [
"America/Chicago"/*,
"America/Indiana/Knox",
"America/Indiana/Tell_City",
"America/Matamoros",
"America/Menominee",
"America/North_Dakota/Beulah",
"America/North_Dakota/Center",
"America/North_Dakota/New_Salem",
"America/Rainy_River",
"America/Rankin_Inlet",
"America/Resolute",
"America/Winnipeg",
"CST6CDT"
*/],
"Central Standard Time (Mexico)": [
"America/Bahia_Banderas"/*,
"America/Merida",
"America/Mexico_City",
"America/Monterrey"
*/],
"Chatham Islands Standard Time": [
"Pacific/Chatham"
],
"China Standard Time": [
"Asia/Hong_Kong"/*,
"Asia/Macau",
"Asia/Shanghai"
*/],
"Cuba Standard Time": [
"America/Havana"
],
"Dateline Standard Time": [
"Etc/GMT+12"
],
"E. Africa Standard Time": [
"Africa/Addis_Ababa"/*,
"Africa/Asmera",
"Africa/Dar_es_Salaam",
"Africa/Djibouti",
"Africa/Juba",
"Africa/Kampala",
"Africa/Mogadishu",
"Africa/Nairobi",
"Indian/Antananarivo",
"Indian/Comoro",
"Indian/Mayotte",
"Antarctica/Syowa",
"Etc/GMT-3"
*/],
"E. Australia Standard Time": [
"Australia/Brisbane"/*,
"Australia/Lindeman"
*/],
"E. Europe Standard Time": [
"Europe/Chisinau"
],
"E. South America Standard Time": [
"America/Sao_Paulo"
],
"Easter Island Standard Time": [
"Pacific/Easter"
],
"Eastern Standard Time": [
"America/Detroit"/*,
"America/Indiana/Petersburg",
"America/Indiana/Vincennes",
"America/Indiana/Winamac",
"America/Iqaluit",
"America/Kentucky/Monticello",
"America/Louisville",
"America/Montreal",
"America/Nassau",
"America/New_York",
"America/Nipigon",
"America/Pangnirtung",
"America/Thunder_Bay",
"America/Toronto",
"EST5EDT"
*/],
"Eastern Standard Time (Mexico)": [
"America/Cancun"
],
"Egypt Standard Time": [
"Africa/Cairo"
],
"Ekaterinburg Standard Time": [
"Asia/Yekaterinburg"
],
"Fiji Standard Time": [
"Pacific/Fiji"
],
"FLE Standard Time": [
"Europe/Helsinki"/*,
"Europe/Kiev",
"Europe/Mariehamn",
"Europe/Riga",
"Europe/Sofia",
"Europe/Tallinn",
"Europe/Uzhgorod",
"Europe/Vilnius",
"Europe/Zaporozhye"
*/],
"Georgian Standard Time": [
"Asia/Tbilisi"
],
"GMT Standard Time": [
"Atlantic/Canary"/*,
"Atlantic/Faeroe",
"Atlantic/Madeira",
"Europe/Dublin",
"Europe/Guernsey",
"Europe/Isle_of_Man",
"Europe/Jersey",
"Europe/Lisbon",
"Europe/London"
*/],
"Greenland Standard Time": [
"America/Godthab"
],
"Greenwich Standard Time": [
"Africa/Abidjan"/*,
"Africa/Accra",
"Africa/Bamako",
"Africa/Banjul",
"Africa/Bissau",
"Africa/Conakry",
"Africa/Dakar",
"Africa/Freetown",
"Africa/Lome",
"Africa/Monrovia",
"Africa/Nouakchott",
"Africa/Ouagadougou",
"Atlantic/Reykjavik",
"Atlantic/St_Helena"
*/],
"GTB Standard Time": [
"Asia/Nicosia"/*,
"Asia/Famagusta",
"Europe/Athens",
"Europe/Bucharest"
*/],
"Haiti Standard Time": [
"America/Port-au-Prince"
],
"Hawaiian Standard Time": [
"Pacific/Honolulu"/*,
"Pacific/Johnston",
"Pacific/Rarotonga",
"Pacific/Tahiti",
"Etc/GMT+10"
*/],
"India Standard Time": [
"Asia/Calcutta"
],
"Iran Standard Time": [
"Asia/Tehran"
],
"Israel Standard Time": [
"Asia/Jerusalem"
],
"Jordan Standard Time": [
"Asia/Amman"
],
"Kaliningrad Standard Time": [
"Europe/Kaliningrad"
],
"Korea Standard Time": [
"Asia/Seoul"
],
"Libya Standard Time": [
"Africa/Tripoli"
],
"Line Islands Standard Time": [
"Pacific/Kiritimati"/*,
"Etc/GMT-14"
*/],
"Lord Howe Standard Time": [
"Australia/Lord_Howe"
],
"Magadan Standard Time": [
"Asia/Magadan"
],
"Magallanes Standard Time": [
"America/Punta_Arenas"
],
"Marquesas Standard Time": [
"Pacific/Marquesas"
],
"Mauritius Standard Time": [
"Indian/Mauritius"/*,
"Indian/Mahe",
"Indian/Reunion"
*/],
"Middle East Standard Time": [
"Asia/Beirut"
],
"Montevideo Standard Time": [
"America/Montevideo"
],
"Morocco Standard Time": [
"Africa/Casablanca"/*,
"Africa/El_Aaiun"
*/],
"Mountain Standard Time": [
"America/Boise"/*,
"America/Cambridge_Bay",
"America/Denver",
"America/Edmonton",
"America/Inuvik",
"America/Ojinaga",
"America/Yellowknife",
"MST7MDT"
*/],
"Mountain Standard Time (Mexico)": [
"America/Chihuahua"/*,
"America/Mazatlan"
*/],
"Myanmar Standard Time": [
"Asia/Rangoon"/*,
"Indian/Cocos"
*/],
"N. Central Asia Standard Time": [
"Asia/Novosibirsk"
],
"Namibia Standard Time": [
"Africa/Windhoek"
],
"Nepal Standard Time": [
"Asia/Katmandu"
],
"New Zealand Standard Time": [
"Pacific/Auckland"/*,
"Antarctica/McMurdo"
*/],
"Newfoundland Standard Time": [
"America/St_Johns"
],
"Norfolk Standard Time": [
"Pacific/Norfolk"
],
"North Asia East Standard Time": [
"Asia/Irkutsk"
],
"North Asia Standard Time": [
"Asia/Krasnoyarsk"/*,
"Asia/Novokuznetsk"
*/],
"North Korea Standard Time": [
"Asia/Pyongyang"
],
"Omsk Standard Time": [
"Asia/Omsk"
],
"Pacific SA Standard Time": [
"America/Santiago"
],
"Pacific Standard Time": [
"America/Los_Angeles"/*,
"America/Dawson",
"America/Vancouver",
"America/Whitehorse",
"PST8PDT"
*/],
"Pacific Standard Time (Mexico)": [
"America/Tijuana"/*,
"America/Santa_Isabel"
*/],
"Pakistan Standard Time": [
"Asia/Karachi"
],
"Paraguay Standard Time": [
"America/Asuncion"
],
"Qyzylorda Standard Time": [
"Asia/Qyzylorda"
],
"Romance Standard Time": [
"Europe/Paris"/*,
"Europe/Brussels",
"Europe/Copenhagen",
"Europe/Madrid",
"Africa/Ceuta"
*/],
"Russia Time Zone 3": [
"Europe/Samara"
],
"Russia Time Zone 10": [
"Asia/Srednekolymsk"
],
"Russia Time Zone 11": [
"Asia/Kamchatka"/*,
"Asia/Anadyr"
*/],
"Russian Standard Time": [
"Europe/Moscow"/*,
"Europe/Kirov",
"Europe/Simferopol"
*/],
"SA Eastern Standard Time": [
"America/Belem"/*,
"America/Cayenne",
"America/Fortaleza",
"America/Maceio",
"America/Paramaribo",
"America/Recife",
"America/Santarem",
"Atlantic/Stanley",
"Antarctica/Palmer",
"Antarctica/Rothera",
"Etc/GMT+3"
*/],
"SA Pacific Standard Time": [
"America/Bogota"/*,
"America/Cayman",
"America/Coral_Harbour",
"America/Eirunepe",
"America/Guayaquil",
"America/Jamaica",
"America/Lima",
"America/Panama",
"America/Rio_Branco",
"Etc/GMT+5"
*/],
"SA Western Standard Time": [
"America/Anguilla"/*,
"America/Antigua",
"America/Aruba",
"America/Barbados",
"America/Blanc-Sablon",
"America/Boa_Vista",
"America/Curacao",
"America/Dominica",
"America/Grenada",
"America/Guadeloupe",
"America/Guyana",
"America/Kralendijk",
"America/La_Paz",
"America/Lower_Princes",
"America/Manaus",
"America/Marigot",
"America/Martinique",
"America/Montserrat",
"America/Port_of_Spain",
"America/Porto_Velho",
"America/Puerto_Rico",
"America/Santo_Domingo",
"America/St_Barthelemy",
"America/St_Kitts",
"America/St_Lucia",
"America/St_Thomas",
"America/St_Vincent",
"America/Tortola",
"Etc/GMT+4"
*/],
"Saint Pierre Standard Time": [
"America/Miquelon"
],
"Sakhalin Standard Time": [
"Asia/Sakhalin"
],
"Samoa Standard Time": [
"Pacific/Apia"
],
"Sao Tome Standard Time": [
"Africa/Sao_Tome"
],
"Saratov Standard Time": [
"Europe/Saratov"
],
"SE Asia Standard Time": [
"Asia/Bangkok"/*,
"Asia/Jakarta",
"Asia/Phnom_Penh",
"Asia/Pontianak",
"Asia/Saigon",
"Asia/Vientiane",
"Indian/Christmas",
"Antarctica/Davis",
"Etc/GMT-7"
*/],
"Singapore Standard Time": [
"Asia/Singapore"/*,
"Asia/Brunei",
"Asia/Kuala_Lumpur",
"Asia/Kuching",
"Asia/Makassar",
"Asia/Manila",
"Antarctica/Casey",
"Etc/GMT-8"
*/],
"South Africa Standard Time": [
"Africa/Johannesburg"/*,
"Africa/Blantyre",
"Africa/Bujumbura",
"Africa/Gaborone",
"Africa/Harare",
"Africa/Kigali",
"Africa/Lubumbashi",
"Africa/Lusaka",
"Africa/Maputo",
"Africa/Maseru",
"Africa/Mbabane",
"Etc/GMT-2"
*/],
"Sri Lanka Standard Time": [
"Asia/Colombo"
],
"Sudan Standard Time": [
"Africa/Khartoum"
],
"Syria Standard Time": [
"Asia/Damascus"
],
"Taipei Standard Time": [
"Asia/Taipei"
],
"Tasmania Standard Time": [
"Australia/Currie"/*,
"Australia/Hobart"
*/],
"Tocantins Standard Time": [
"America/Araguaina"
],
"Tokyo Standard Time": [
"Asia/Tokyo"/*,
"Asia/Dili",
"Asia/Jayapura",
"Pacific/Palau",
"Etc/GMT-9"
*/],
"Tomsk Standard Time": [
"Asia/Tomsk"
],
"Tonga Standard Time": [
"Pacific/Tongatapu"
],
"Transbaikal Standard Time": [
"Asia/Chita"
],
"Turkey Standard Time": [
"Europe/Istanbul"
],
"Turks And Caicos Standard Time": [
"America/Grand_Turk"
],
"Ulaanbaatar Standard Time": [
"Asia/Ulaanbaatar"/*,
"Asia/Choibalsan"
*/],
"US Eastern Standard Time": [
"America/Indianapolis"/*,
"America/Indiana/Marengo",
"America/Indiana/Vevay"
*/],
"US Mountain Standard Time": [
"America/Phoenix"/*,
"America/Creston",
"America/Dawson_Creek",
"America/Fort_Nelson",
"America/Hermosillo",
"Etc/GMT+7"
*/],
"UTC": [
"Etc/GMT"/*,
"America/Danmarkshavn",
"Etc/UTC"
*/],
"UTC-02": [
"Etc/GMT+2"/*,
"America/Noronha",
"Atlantic/South_Georgia"
*/],
"UTC-08": [
"Etc/GMT+8"/*,
"Pacific/Pitcairn"
*/],
"UTC-09": [
"Etc/GMT+9"/*,
"Pacific/Gambier"
*/],
"UTC-11": [
"Etc/GMT+11"/*,
"Pacific/Midway",
"Pacific/Niue",
"Pacific/Pago_Pago"
*/],
"UTC+12": [
"Etc/GMT-12"/*,
"Pacific/Funafuti",
"Pacific/Kwajalein",
"Pacific/Majuro",
"Pacific/Nauru",
"Pacific/Tarawa",
"Pacific/Wake",
"Pacific/Wallis"
*/],
"UTC+13": [
"Etc/GMT-13"/*,
"Pacific/Enderbury",
"Pacific/Fakaofo"
*/],
"Venezuela Standard Time": [
"America/Caracas"
],
"Vladivostok Standard Time": [
"Asia/Vladivostok"/*,
"Asia/Ust-Nera"
*/],
"Volgograd Standard Time": [
"Europe/Volgograd"
],
"W. Australia Standard Time": [
"Australia/Perth"
],
"W. Central Africa Standard Time": [
"Africa/Algiers"/*,
"Africa/Bangui",
"Africa/Brazzaville",
"Africa/Douala",
"Africa/Kinshasa",
"Africa/Lagos",
"Africa/Libreville",
"Africa/Luanda",
"Africa/Malabo",
"Africa/Ndjamena",
"Africa/Niamey",
"Africa/Porto-Novo",
"Africa/Tunis",
"Etc/GMT-1"
*/],
"W. Europe Standard Time": [
"Europe/Amsterdam"/*,
"Europe/Andorra",
"Europe/Berlin",
"Europe/Busingen",
"Europe/Gibraltar",
"Europe/Luxembourg",
"Europe/Malta",
"Europe/Monaco",
"Europe/Oslo",
"Europe/Rome",
"Europe/San_Marino",
"Europe/Stockholm",
"Europe/Vaduz",
"Europe/Vatican",
"Europe/Vienna",
"Europe/Zurich",
"Arctic/Longyearbyen"
*/],
"W. Mongolia Standard Time": [
"Asia/Hovd"
],
"West Asia Standard Time": [
"Asia/Aqtau"/*,
"Asia/Aqtobe",
"Asia/Ashgabat",
"Asia/Atyrau",
"Asia/Dushanbe",
"Asia/Oral",
"Asia/Samarkand",
"Asia/Tashkent",
"Indian/Kerguelen",
"Indian/Maldives",
"Antarctica/Mawson",
"Etc/GMT-5"
*/],
"West Bank Standard Time": [
"Asia/Gaza"/*,
"Asia/Hebron"
*/],
"West Pacific Standard Time": [
"Pacific/Guam"/*,
"Pacific/Port_Moresby",
"Pacific/Saipan",
"Pacific/Truk",
"Antarctica/DumontDUrville",
"Etc/GMT-10"
*/],
"Yakutsk Standard Time": [
"Asia/Khandyga"/*,
"Asia/Yakutsk"
*/],
};
})(window.rl);

View file

@ -13,7 +13,7 @@ class ViewICSPlugin extends \RainLoop\Plugins\AbstractPlugin
public function Init() : void
{
// $this->UseLangs(true);
$this->addJs('ical.js');
$this->addJs('message.js');
$this->addJs('windowsZones.js');
}
}

View file

@ -7,30 +7,7 @@
const
template = document.getElementById(templateId),
view = e.detail,
attachmentsPlace = template.content.querySelector('.attachmentsPlace'),
dateRegEx = /(TZID=(?<tz>[^:]+):)?(?<year>[0-9]{4})(?<month>[0-9]{2})(?<day>[0-9]{2})T(?<hour>[0-9]{2})(?<minute>[0-9]{2})(?<second>[0-9]{2})(?<utc>Z?)/,
parseDate = str => {
let parts = dateRegEx.exec(str)?.groups,
options = {dateStyle: 'long', timeStyle: 'short'},
date = (parts ? new Date(
parseInt(parts.year, 10),
parseInt(parts.month, 10) - 1,
parseInt(parts.day, 10),
parseInt(parts.hour, 10),
parseInt(parts.minute, 10),
parseInt(parts.second, 10)
) : new Date(str));
parts?.tz && (options.timeZone = windowsVTIMEZONEs[parts.tz] || parts.tz);
try {
return date.format(options);
} catch (e) {
console.error(e);
if (options.timeZone) {
options.timeZone = undefined;
return date.format(options);
}
}
};
attachmentsPlace = template.content.querySelector('.attachmentsPlace');
attachmentsPlace.after(Element.fromHTML(`
<details data-bind="if: viewICS, visible: viewICS">
@ -74,8 +51,8 @@
if (item["ical:summary"]) {
let VEVENT = {
SUMMARY: item["ical:summary"],
DTSTART: parseDate(item["ical:dtstart"]),
// DTEND: parseDate(item["ical:dtend"]),
DTSTART: rl.ICS.parseDate(item["ical:dtstart"]),
// DTEND: rl.ICS.parseDate(item["ical:dtend"]),
// TRANSP: item["ical:transp"],
// LOCATION: item["ical:location"],
ATTENDEE: []
@ -94,58 +71,8 @@
rl.fetch(ics.linkDownload())
.then(response => (response.status < 400) ? response.text() : Promise.reject(new Error({ response })))
.then(text => {
let VEVENT,
VALARM,
multiple = ['ATTACH','ATTENDEE','CATEGORIES','COMMENT','CONTACT','EXDATE',
'EXRULE','RSTATUS','RELATED','RESOURCES','RDATE','RRULE'],
lines = text.split(/\r?\n/),
i = lines.length;
while (i--) {
let line = lines[i];
if (VEVENT) {
while (line.startsWith(' ') && i--) {
line = lines[i] + line.slice(1);
}
if (line.startsWith('END:VALARM')) {
VALARM = {};
continue;
} else if (line.startsWith('BEGIN:VALARM')) {
VEVENT.VALARM || (VEVENT.VALARM = []);
VEVENT.VALARM.push(VALARM);
VALARM = null;
continue;
} else if (line.startsWith('BEGIN:VEVENT')) {
break;
}
line = line.match(/^([^:;]+)[:;](.+)$/);
if (line) {
if (VALARM) {
VALARM[line[1]] = line[2];
} else if (multiple.includes(line[1]) || 'X-' == line[1].slice(0,2)) {
VEVENT[line[1]] || (VEVENT[line[1]] = []);
VEVENT[line[1]].push(line[2]);
} else {
if ('DTSTART' === line[1] || 'DTEND' === line[1]) {
line[2] = parseDate(line[2]);
}
VEVENT[line[1]] = line[2];
}
}
} else if (line.startsWith('END:VEVENT')) {
VEVENT = {};
}
}
// METHOD:REPLY || METHOD:REQUEST
// console.dir({VEVENT:VEVENT});
let VEVENT = rl.ICS.parseEvent(text);
if (VEVENT) {
VEVENT.rawText = text;
VEVENT.isCancelled = () => VEVENT.STATUS?.includes('CANCELLED');
VEVENT.isConfirmed = () => VEVENT.STATUS?.includes('CONFIRMED');
VEVENT.shouldReply = () => VEVENT.METHOD?.includes('REPLY');
console.dir({
isCancelled: VEVENT.isCancelled(),
shouldReply: VEVENT.shouldReply()
});
view.viewICS(VEVENT);
}
});