Properly fix initial contacts setup

Partially reverts 263cdf544a because it wasn't necessary.
This commit is contained in:
Bruno Bernardino
2025-08-27 16:44:01 +01:00
parent 263cdf544a
commit 02d1d3e6fa
5 changed files with 9 additions and 34 deletions

View File

@@ -33,7 +33,7 @@ Now, download/copy the following configuration files (and tweak their contents a
- [`docker-compose.yml`](/docker-compose.yml) - [`docker-compose.yml`](/docker-compose.yml)
- [`.env.sample`](/.env.sample) and save it as `.env` - [`.env.sample`](/.env.sample) and save it as `.env`
- [`bewcloud.config.sample.ts`](/bewcloud.config.sample.ts) and save it as `bewcloud.config.ts` - [`bewcloud.config.sample.ts`](/bewcloud.config.sample.ts) and save it as `bewcloud.config.ts`
- [`radicale-config/config`](/radicale-config/config) and save it as `radicale-config/config` (if you're using CalDav/CardDav) - [`radicale-config/config`](/radicale-config/config) and save it as `radicale-config/config` (if you're using CalDav/CardDav/Contacts)
Finally, run these commands: Finally, run these commands:

View File

@@ -34,11 +34,11 @@ const config: PartialDeep<Config> = {
// }, // },
// contacts: { // contacts: {
// enableCardDavServer: true, // enableCardDavServer: true,
// cardDavUrl: 'http://127.0.0.1:5232', // cardDavUrl: 'http://radicale:5232',
// }, // },
// calendar: { // calendar: {
// enableCalDavServer: true, // enableCalDavServer: true,
// calDavUrl: 'http://127.0.0.1:5232', // calDavUrl: 'http://radicale:5232',
// }, // },
}; };

View File

@@ -1,6 +1,6 @@
services: services:
website: website:
image: ghcr.io/bewcloud/bewcloud:v2.4.4 image: ghcr.io/bewcloud/bewcloud:v2.4.5
restart: always restart: always
ports: ports:
- 127.0.0.1:8000:8000 - 127.0.0.1:8000:8000
@@ -32,8 +32,8 @@ services:
# NOTE: If you don't want to use the CardDav/CalDav servers, you can comment/remove this service. # NOTE: If you don't want to use the CardDav/CalDav servers, you can comment/remove this service.
radicale: radicale:
image: tomsquest/docker-radicale:3.5.4.0 image: tomsquest/docker-radicale:3.5.4.0
ports: # ports:
- 127.0.0.1:5232:5232 # - 127.0.0.1:5232:5232
init: true init: true
read_only: true read_only: true
security_opt: security_opt:

View File

@@ -38,11 +38,11 @@ export class AppConfig {
}, },
contacts: { contacts: {
enableCardDavServer: true, enableCardDavServer: true,
cardDavUrl: 'http://127.0.0.1:5232', cardDavUrl: 'http://radicale:5232',
}, },
calendar: { calendar: {
enableCalDavServer: true, enableCalDavServer: true,
calDavUrl: 'http://127.0.0.1:5232', calDavUrl: 'http://radicale:5232',
}, },
}; };
} }

View File

@@ -135,32 +135,7 @@ export class ContactModel {
): Promise<AddressBook[]> { ): Promise<AddressBook[]> {
const client = await getClient(userId); const client = await getClient(userId);
let davAddressBooks: DAVObject[] = []; const davAddressBooks: DAVObject[] = await client.fetchAddressBooks();
try {
davAddressBooks = await client.fetchAddressBooks();
} catch (_error) {
// It's possible the user doesn't exist in Radicale yet, so try creating it by doing a simple PROPFIND request for the main addressbook's address (Radicale will automatically create the user)
const userUrl = `${contactsConfig.cardDavUrl}/${userId}/`;
const xmlBody = `<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:" xmlns:card="urn:ietf:params:xml:ns:carddav">
<prop>
<card:addressbook-home-set/>
</prop>
</propfind>`;
await fetch(userUrl, {
method: 'PROPFIND',
headers: {
'Content-Type': 'application/xml; charset=utf-8',
'X-Remote-User': userId,
},
body: xmlBody,
});
davAddressBooks = await client.fetchAddressBooks();
}
const addressBooks: AddressBook[] = davAddressBooks.map((davAddressBook) => { const addressBooks: AddressBook[] = davAddressBooks.map((davAddressBook) => {
const uid = davAddressBook.url.split('/').filter(Boolean).pop()!; const uid = davAddressBook.url.split('/').filter(Boolean).pop()!;