JodliDev / calendar

GNU Affero General Public License v3.0
16 stars 12 forks source link

DB Error: [1048] Column 'color' cannot be null (SQL Query: INSERT INTO caldav_calendars #39

Open internethering opened 1 year ago

internethering commented 1 year ago

Hello, the $config['calendar_caldav_preinstalled_sources'] doesn't work:

<fjks17fa> DB Error: [1048] Column 'color' cannot be null (SQL Query: INSERT INTO caldav_calendars
(user_id, source_id, name, color, showalarms, caldav_url, caldav_tag, is_ical)
VALUES ('1', '5', 'Persönlich', NULL, '0', 'https://<private>/personal', NULL, '0')) in /var/www/webmail/htdocs/program/lib/Roundcube/rcube_db.php on line 567 (POST /?_task=calendar&_action=refresh)

I tried also:

$config['calendar_caldav_preinstalled_sources'] = array(
    'personal' => array(
        'caldav_user' => '%u',
        'caldav_pass' => '%p',
        'caldav_url'  => 'https://<private>/personal',
        'color'       => 'cc0000',
        'showAlarms'  => 1
   )
);

The old texxasrulez-calendar worked with color.

Edith: trying to add calendar manuel doesn't work because of Column 'color' cannot be null too

JodliDev commented 1 year ago

What kind of caldav server are you using? Have you checked if it provides a `ical:calendar-color´ tag? I am pretty sure that this is caused by https://github.com/club-1/calendar/blob/f679c616e8764b45179e268b06f4f95430014287/drivers/caldav/caldav_driver.php#L389 which expects a 'color' attribute (which should be sent from the caldav server)

JodliDev commented 1 year ago

I added a quick fix that should prevent the script from crashing when no color information is present. But it will then just display a fallback color instead (which means changing the color will only change it at the source - but still display the wrong color in roundcube)

internethering commented 1 year ago

What kind of caldav server are you using?

Nextcloud 25.0.5

https://datatracker.ietf.org/doc/html/rfc4791 doesn't say something about a key like 'color'? https://datatracker.ietf.org/doc/html/rfc2445 ctrl-f doesn't find 'color'

seems like color or calender-color is not part of common internet standards. so please readd support for $config['calendar_caldav_preinstalled_sources'] = array( 'personal' => array('color' => 'cc0000')) and in the form (see attachment) like in the old texxasrulez-calendar

Screenshot_20230502_185011

n-peugnet commented 1 year ago

This CalDAV driver does not work the same way as texxasrulez-calendar, see https://github.com/JodliDev/calendar#what-is-this-fork-doing-differently.

The "preinstalled" feature is not for a list of calendars but for a list of "sources", which can each have multiple calendars. Thus the color key would not have the same meaning, which is why I decided not to add it. (This is also the reason why I decided not to name it the same way, to prevent people from copying their old configuration and expecting it to work)

JodliDev commented 1 year ago

You are looking at the wrong RFC. calendar-color is in fact part of RFC 7986. https://datatracker.ietf.org/doc/html/rfc7986#section-5.9 But even if it were not part of the RFC, this attribute is widely used, so I dont see any advantage in overwriting common caldav attributes. Also, as n-peugnet mentioned, the setting you are seeing has a slightly different purpose. So there is nothing to "readd" because this was never part of the original calendar caldav implementation that texxasrules and this project are both building on.

But I think the problem is somewhere else: As far as I know, Nextcloud is using sabre/dav as their server, which supports the calendar-color attribute https://sabre.io/dav/clients/ical/

Does your nextcloud calendar display colors? Have you looked at the requests from your server if it has included the calendar-color attribute?

internethering commented 1 year ago

ok, this rfc I didnt know, mea culpa. thanks for explaining

I tested again, when I use the nextcloud-url https://<domain>/remote.php/dav/ it works as expected. But: if you as an user without any knowledge and go into nextcloud, you can copy from a calender a share url, this is like https://<domain>/remote.php/dav/calendars/<user>/personal/ – there is no color attribut. thanks for adding the fix, so this can work too

but I god another problem with nextcloud calenders, but this I going to put in a new issue