Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CalDAV event syncing problems with server that have obfuscated calendar URLs #1574

Open
sandro-byte32 opened this issue Jul 23, 2024 · 5 comments

Comments

@sandro-byte32
Copy link

sandro-byte32 commented Jul 23, 2024

Hello Alex,

I am currently trying to get CalDAV syncing to work, but so far, I have not had any success. I am using a CalDAV server integrated with Namecheap Mail.

When I enter my credentials to enable CalDAV syncing, it indicates success. I can successfully synchronize between my phone and Thunderbird on the PC. However, EasyAppointment does not show the appointments made on my phone, and vice versa—I cannot see the appointments made through EasyAppointment on my phone or Thunderbird.

Is Baikal as a CalDAV server a necessity for EasyAppointment to work? The link to my CalDAV server looks something like this (obfuscated):

https://example.com:2080/calendars/__uids__/fafafadnasdnjandono384732897438293/calendar

Edit:
I also tried it with a local Baikal server with Nginx Proxy Manager, where WebDAV authentication is Basic. The same behavior occurs—no appointments get created on the server with EasyAppointment. When I create an appointment in Thunderbird, which is also connected to the local Baikal server, it instantly creates an event that can be seen on the Baikal web interface.

In conclusion, there seems to be a problem with EasyAppointment, as it cannot sync with either of the two completely different servers.

Edit2:
I managed to get some Error Logs:

ERROR - 2024-07-25 23:59:22 --> Failed to save CalDAV event (Status Code: 405):

<title>405 Method Not Allowed</title>

Method Not Allowed

The requested method PUT is not allowed for this URL.


Apache/2.4.59 (Debian) Server at traefik.geeknest.stream Port 80

The Thing is with this Curl command the PUT is allowed, i also allow it on my Server:

curl -X PUT -u obfuscaed:obfuscated -T calendar.ics -H "Content-Type: text/calendar" -H "User-Agent: GuzzleHttp/7" https://ocfuscated/dav.php/calendars/bla/default/some-event.ics

What can I do to resolve this issue? I have already contacted Namecheap, and they confirmed that everything is functioning correctly on their end.

Thank you for your assistance.

@alextselegidis
Copy link
Owner

Hello!

This is strange indeed, but I would need to do some research on that and get back to you.

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

@sandro-byte32
Copy link
Author

If you need my login credentials, just let me know.

@sandro-byte32
Copy link
Author

The issue seems to be with how the get_caldav_event_uri method constructs the URI. The current implementation of the method does not take the base URL into account. Instead, it only appends the event ID to a root path.

Here's the current implementation of the get_caldav_event_uri method:

/**
 * Generate the event URI, used in various requests.
 *
 * @param string|null $caldav_event_id
 *
 * @return string
 */
private function get_caldav_event_uri(?string $caldav_event_id = null): string
{
    return $caldav_event_id ? '/' . $caldav_event_id . '.ics' : '';
}

This method only appends the event ID to a root path, which is why you are seeing incorrect URIs being generated.

To fix this, you need to modify the method to include the base URL (calendar URL) when constructing the URI. Here is a revised version of the method:

/**
 * Generate the event URI, used in various requests.
 *
 * @param string $caldav_calendar The base CalDAV calendar URL.
 * @param string|null $caldav_event_id The CalDAV event ID.
 *
 * @return string
 */
private function get_caldav_event_uri(string $caldav_calendar, ?string $caldav_event_id = null): string
{
    return rtrim($caldav_calendar, '/') . ($caldav_event_id ? '/' . $caldav_event_id . '.ics' : '');
}

This should resolve the issue and generate the correct URIs.

So, either no one is using CalDav at all, because it shouldn't have worked for anyone in the first place. I'm surprised that no one else has complained about it yet.

@alextselegidis
Copy link
Owner

Hello!

Thanks for looking into this and sharing the solution.

I will give it a try and integrate as needed.

Alex Tselegidis, Easy!Appointments Creator
Need a customization? Get a free quote!

@alextselegidis alextselegidis changed the title Successful Caldav Login but no Syncing Fix CalDAV event syncing problems with server that have obfuscated calendar URLs Aug 12, 2024
@sandro-byte32
Copy link
Author

FYI:

I obfuscated it for privcacy reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants