Skip to content

Commit bf427e4

Browse files
author
tchapi
committed
add reminder env var
1 parent c541047 commit bf427e4

File tree

6 files changed

+68
-36
lines changed

6 files changed

+68
-36
lines changed

.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ WEBDAV_ENABLED=false
7272
# Do we allow calendars to be public ?
7373
PUBLIC_CALENDARS_ENABLED=true
7474

75+
# For Birthday calendars, what should be the reminder offset ?
76+
# (The default is PT9H, 9am on the day of the event)
77+
BIRTHDAY_REMINDER_OFFSET=PT9H
78+
7579
# What mail is used as the sender for invites ?
7680
INVITE_FROM_ADDRESS=[email protected]
7781

README.md

Lines changed: 47 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ Dependencies
6767

6868
1. Retrieve the dependencies:
6969

70-
```
71-
composer install
72-
```
70+
```
71+
composer install
72+
```
7373
7474
2. At least put the correct credentials to your database (driver and url) in your `.env.local` file so you can easily create the necessary tables.
7575
7676
3. Run the migrations to create all the necessary tables:
7777
78-
```
79-
bin/console doctrine:migrations:migrate
80-
```
78+
```
79+
bin/console doctrine:migrations:migrate
80+
```
8181
8282
**Davis** can also be used with a pre-existing MySQL database (_for instance, one previously managed by Baïkal_). See the paragraph "Migrating from Baikal" for more info.
8383
@@ -93,14 +93,14 @@ Create your own `.env.local` file to change the necessary variables, if you plan
9393
>
9494
> If your installation is behind a web server like Apache or Nginx, you can setup the env vars directly in your Apache or Nginx configuration (see below). Skip this part in this case.
9595
96-
a. The database driver and url (_you should already have it configured since you created the database previously_)
96+
**a. The database driver and url** (_you should already have it configured since you created the database previously_)
9797
9898
```shell
9999
DATABASE_DRIVER=mysql # or postgresql, or sqlite
100100
DATABASE_URL=mysql://db_user:db_pass@host:3306/db_name?serverVersion=10.9.3-MariaDB&charset=utf8mb4
101101
```
102102

103-
b. The admin password for the backend
103+
**b. The admin password for the backend**
104104

105105
```shell
106106
ADMIN_LOGIN=admin
@@ -111,15 +111,15 @@ ADMIN_PASSWORD=test
111111
>
112112
> You can bypass auth entirely if you use a third party authorization provider such as Authelia. In that case, set the `ADMIN_AUTH_BYPASS` env var to `true` (case-sensitive, this is actually the string `true`, not a boolean) to allow full access to the dashboard. This does not change the behaviour of the DAV server.
113113
114-
c. The auth Realm and method for HTTP auth
114+
**c. The auth Realm and method for HTTP auth**
115115

116116
```shell
117117
AUTH_REALM=SabreDAV
118118
AUTH_METHOD=Basic # can be "Basic", "IMAP" or "LDAP"
119119
```
120120
> See [the following paragraph](#specific-environment-variables-for-imap-and-ldap-authentication-methods) for more information if you choose either IMAP or LDAP.
121121
122-
d. The global flags to enable CalDAV, CardDAV and WebDAV. You can also disable the option to have calendars public
122+
**d. The global flags to enable CalDAV, CardDAV and WebDAV**. You can also disable the option to have calendars public
123123

124124
```shell
125125
CALDAV_ENABLED=true
@@ -134,14 +134,34 @@ PUBLIC_CALENDARS_ENABLED=true
134134
> By default, `PUBLIC_CALENDARS_ENABLED` is true. That doesn't mean that all calendars are public by default — it just means that you have an option, upon calendar creation, to set the calendar public (but it's not public by default).
135135
136136

137-
e. The email address that your invites are going to be sent from
137+
**e. The email address that your invites are going to be sent from**
138138

139139
```shell
140140
141141
```
142142

143-
f. The paths for the WebDAV installation
143+
**f. The reminder offset for all birthdays**
144+
145+
You must specify a relative duration, as specified in [the RFC 5545 spec](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.3.6)
146+
147+
```shell
148+
BIRTHDAY_REMINDER_OFFSET=PT9H
149+
```
150+
151+
If you don't want a reminder for birthday events, set it to the `false` value (lowercase):
152+
153+
```shell
154+
BIRTHDAY_REMINDER_OFFSET=false
155+
```
144156

157+
> [!NOTE]
158+
>
159+
> By default, if the env var is not set or empty, we use `PT9H` (9am on the date of the birthday).
160+
161+
**g. The paths for the WebDAV installation**
162+
163+
> [!TIP]
164+
>
145165
> I recommend that you use absolute directories so you know exactly where your files reside.
146166
147167
```shell
@@ -158,15 +178,15 @@ WEBDAV_HOMES_DIR=
158178
>
159179
> By default, home directories are disabled totally (the env var is set to an empty string). If needed, it is recommended to use a folder that is **NOT** a child of the public dir, such as `/webdav/homes` for instance, so that users cannot access other users' homes.
160180
161-
g. The log file path
181+
**h. The log file path**
162182

163183
You can use an absolute file path here, and you can use Symfony's `%kernel.logs_dir%` and `%kernel.environment%` placeholders if needed (as in the default value). Setting it to `/dev/null` will disable logging altogether.
164184

165185
```shell
166186
LOG_FILE_PATH="%kernel.logs_dir%/%kernel.environment%.log"
167187
```
168188

169-
h. The timezone you want for the app
189+
**i. The timezone you want for the app**
170190

171191
This must comply with the [official list](https://www.php.net/manual/en/timezones.php)
172192

@@ -236,29 +256,27 @@ If you're migrating from Baïkal, then you will likely want to do the following
236256
237257
1. Get a backup of your data (without the `CREATE` statements, but with complete `INSERT` statements):
238258
239-
```shell
240-
mysqldump -u root -p --no-create-info --complete-insert baikal > baikal_to_davis.sql # baikal is the actual name of your database
241-
```
242-
259+
```shell
260+
mysqldump -u root -p --no-create-info --complete-insert baikal > baikal_to_davis.sql # baikal is the actual name of your database
261+
```
243262
244263
2. Create a new database for Davis (let's name it `davis`) and create the base schema:
245264
246-
```shell
247-
bin/console doctrine:migrations:migrate 'DoctrineMigrations\Version20191030113307' --no-interaction
248-
```
249-
265+
```shell
266+
bin/console doctrine:migrations:migrate 'DoctrineMigrations\Version20191030113307' --no-interaction
267+
```
250268
251269
3. Reimport the data back:
252270
253-
```
254-
mysql -uroot -p davis < baikal_to_davis.sql
255-
```
271+
```
272+
mysql -uroot -p davis < baikal_to_davis.sql
273+
```
256274
257275
4. Run the necessary remaining migrations:
258276
259-
```
260-
bin/console doctrine:migrations:migrate
261-
```
277+
```
278+
bin/console doctrine:migrations:migrate
279+
```
262280
263281
# 🌐 Access / Webserver
264282
@@ -268,7 +286,7 @@ The administration interface is available at `/dashboard`. You need to login to
268286
269287
The main endpoint for CalDAV, WebDAV or CardDAV is at `/dav`.
270288
271-
> [!NOTE]
289+
> [!TIP]
272290
>
273291
> For shared hosting, the `symfony/apache-pack` is included and provides a standard `.htaccess` file in the public directory so redirections should work out of the box.
274292

config/services.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ parameters:
99
timezone: '%env(APP_TIMEZONE)%'
1010
public_calendars_enabled: '%env(default:default_public_calendars_enabled:bool:PUBLIC_CALENDARS_ENABLED)%'
1111
default_public_calendars_enabled: "true"
12+
birthday_reminder_offset: '%env(default:default_birthday_reminder_offset:BIRTHDAY_REMINDER_OFFSET)%'
13+
default_birthday_reminder_offset: "PT9H"
1214
caldav_enabled: "%env(bool:CALDAV_ENABLED)%"
1315
carddav_enabled: "%env(bool:CARDDAV_ENABLED)%"
1416

@@ -70,6 +72,10 @@ services:
7072
tags:
7173
- { name: monolog.processor }
7274

75+
App\Services\BirthdayService:
76+
arguments:
77+
$birthdayReminderOffset: "%birthday_reminder_offset%"
78+
7379
when@dev:
7480
services:
7581
Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler'

docker/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ CARDDAV_ENABLED=true
66
WEBDAV_ENABLED=false
77
PUBLIC_CALENDARS_ENABLED=true
88

9+
BIRTHDAY_REMINDER_OFFSET=PT9H
10+
911
APP_TIMEZONE=Europe/Paris
1012

1113
LOG_FILE_PATH="%kernel.logs_dir%/%kernel.environment%.log"

src/Constants.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
class Constants
88
{
99
public const BIRTHDAY_CALENDAR_URI = 'birthday-calendar';
10-
public const BIRTHDAY_REMINDER_OFFSET = 'PT9H'; // 9am on the day of the event
1110

1211
public const MAX_DATE = '2222-01-01';
1312
}

src/Services/BirthdayService.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class BirthdayService
3131
{
3232
public function __construct(
3333
private ManagerRegistry $doctrine,
34+
private string $birthdayReminderOffset,
3435
) {
3536
}
3637

@@ -227,12 +228,14 @@ public function buildDataFromContact(string $cardData): ?VCalendar
227228
$vEvent->{'SUMMARY'} = $summary;
228229
$vEvent->{'TRANSP'} = 'TRANSPARENT';
229230

230-
// Set a reminder
231-
$alarm = $vCal->createComponent('VALARM');
232-
$alarm->add($vCal->createProperty('TRIGGER', Constants::BIRTHDAY_REMINDER_OFFSET, ['VALUE' => 'DURATION']));
233-
$alarm->add($vCal->createProperty('ACTION', 'DISPLAY'));
234-
$alarm->add($vCal->createProperty('DESCRIPTION', $vEvent->{'SUMMARY'}));
235-
$vEvent->add($alarm);
231+
// Set a reminder, if needed
232+
if (strtolower($this->birthdayReminderOffset) !== "false") {
233+
$alarm = $vCal->createComponent('VALARM');
234+
$alarm->add($vCal->createProperty('TRIGGER', $this->birthdayReminderOffset, ['VALUE' => 'DURATION']));
235+
$alarm->add($vCal->createProperty('ACTION', 'DISPLAY'));
236+
$alarm->add($vCal->createProperty('DESCRIPTION', $vEvent->{'SUMMARY'}));
237+
$vEvent->add($alarm);
238+
}
236239

237240
$vCal->add($vEvent);
238241

0 commit comments

Comments
 (0)