Fix ics escaping and IDs

This commit is contained in:
Igor Scheller 2023-06-04 23:10:56 +02:00 committed by Michael Weimann
parent ab5f6a270c
commit fc8d335ea2
2 changed files with 9 additions and 7 deletions

View File

@ -1,8 +1,8 @@
{% set dateFormat = 'Ymd\\THis\\Z' %} {% set dateFormat = 'Ymd\\THis\\Z' %}
{% set replacement = {'\n': '\\n'} %} {% set replacement = {'\\': '\\\\', ';': '\\;', ',': '\\,', '\n': '\\n'} %}
BEGIN:VCALENDAR BEGIN:VCALENDAR
VERSION:2.0 VERSION:2.0
PRODID:-//-/{{ config('app_name') }}//DE PRODID:-//-/{{ config('app_name') | replace(replacement) | raw }}//DE
CALSCALE:GREGORIAN CALSCALE:GREGORIAN
{% for entry in shiftEntries %} {% for entry in shiftEntries %}
BEGIN:VEVENT BEGIN:VEVENT
@ -12,12 +12,14 @@ DTSTART:{{ entry.shift.start.utc().format(dateFormat) }}
DTEND:{{ entry.shift.end.utc().format(dateFormat) }} DTEND:{{ entry.shift.end.utc().format(dateFormat) }}
STATUS:CONFIRMED STATUS:CONFIRMED
TRANSP:OPAQUE TRANSP:OPAQUE
SUMMARY:{{ entry.shift.shiftType.name ~ ' (' ~ entry.shift.title ~ ')' | replace(replacement) | raw }} SUMMARY:{{ (entry.shift.shiftType.name ~ ' (' ~ entry.shift.title ~ ')') | replace(replacement) | raw }}
LOCATION:{{ entry.shift.room.name | replace(replacement) | raw }} LOCATION:{{ entry.shift.room.name | replace(replacement) | raw }}
DESCRIPTION:{{ DESCRIPTION:{{
(
entry.shift.shiftType.description entry.shift.shiftType.description
~ '\\n' ~ entry.shift.description ~ '\n' ~ entry.shift.description
~ '\\n' ~ entry.user_comment ~ '\n' ~ entry.user_comment
)
| replace(replacement) | raw | replace(replacement) | raw
}} }}
URL:{{ url('/shifts', {'action': 'view', 'shift_id': entry.shift.id}) | raw }} URL:{{ url('/shifts', {'action': 'view', 'shift_id': entry.shift.id}) | raw }}

View File

@ -152,6 +152,6 @@ class FeedController extends BaseController
->leftJoin('shifts', 'shifts.id', 'shift_entries.shift_id') ->leftJoin('shifts', 'shifts.id', 'shift_entries.shift_id')
->orderBy('shifts.start') ->orderBy('shifts.start')
->with(['shift', 'shift.room', 'shift.shiftType']) ->with(['shift', 'shift.room', 'shift.shiftType'])
->get(); ->get(['*', 'shift_entries.id']);
} }
} }