mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
feat(calendar): let a feed leave out the per-day summary events (#2602)
Both feed routes and the one-off export.ics take ?days=0, validated by a shared query contract, and then skip the all-day "Day N" event per day; the default is unchanged. The subscribe dialog gets a Day overview events switch that adds the parameter to its links, export_trip_ics takes dayEvents and the feed tools explain the parameter.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// FE-PLANNER-ICS-001 to FE-PLANNER-ICS-016
|
||||
// FE-PLANNER-ICS-001 to FE-PLANNER-ICS-018
|
||||
import { render, screen, fireEvent, waitFor } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { http, HttpResponse } from 'msw';
|
||||
@@ -147,6 +147,33 @@ describe.each([['phone', true], ['desktop', false]] as const)('IcsSubscribeModal
|
||||
await waitFor(() => expect(regenerate).not.toBeDisabled());
|
||||
expect(screen.getByText('https://trek.example/feed/keep.ics')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-ICS-017: the day overview switch is on, and off adds days=0 to every link (#2602)', async () => {
|
||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: 'https://trek.example/feed/tok.ics' })));
|
||||
render(<IcsSubscribeModal {...defaultProps} />);
|
||||
const toggle = await screen.findByRole('button', { name: 'Day overview events' });
|
||||
expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
||||
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
||||
.toHaveAttribute('href', 'webcal://trek.example/feed/tok.ics');
|
||||
|
||||
fireEvent.click(toggle);
|
||||
expect(toggle).toHaveAttribute('aria-pressed', 'false');
|
||||
expect(screen.getByText('https://trek.example/feed/tok.ics?days=0')).toBeInTheDocument();
|
||||
expect(screen.getByRole('link', { name: /Add to Apple Calendar \/ Outlook/i }))
|
||||
.toHaveAttribute('href', 'webcal://trek.example/feed/tok.ics?days=0');
|
||||
expect(screen.getByRole('link', { name: /Add to Google Calendar/i }).getAttribute('href'))
|
||||
.toContain(encodeURIComponent('webcal://trek.example/feed/tok.ics?days=0'));
|
||||
|
||||
fireEvent.click(toggle);
|
||||
expect(screen.getByText('https://trek.example/feed/tok.ics')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-PLANNER-ICS-018: the day overview switch only shows once there is a link to change', async () => {
|
||||
server.use(http.get(TOKEN_URL, () => HttpResponse.json({ feed_url: null })));
|
||||
render(<IcsSubscribeModal {...defaultProps} />);
|
||||
await screen.findByRole('button', { name: /Enable calendar subscription/i });
|
||||
expect(screen.queryByRole('button', { name: 'Day overview events' })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('IcsSubscribeModal on the phone', () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useId, type ReactNode } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { X, RefreshCw, Calendar, Power } from 'lucide-react'
|
||||
import { SubscribeLinks } from './SubscribeLinks'
|
||||
import ToggleSwitch from '../Settings/ToggleSwitch'
|
||||
import { useIsPhone } from '../../mobile/useIsPhone'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs } from '../shared/DialogShell'
|
||||
@@ -24,6 +25,31 @@ function absolutize(url: string): string {
|
||||
return url
|
||||
}
|
||||
|
||||
// The feeds take days=0 to leave out the all-day summary every day with
|
||||
// untimed places or notes gets (#2602). The choice lives in the link itself,
|
||||
// so a calendar keeps what it subscribed to and the token stays one per trip.
|
||||
function withDayEvents(url: string, dayEvents: boolean): string {
|
||||
if (!url || dayEvents) return url
|
||||
return `${url}${url.includes('?') ? '&' : '?'}days=0`
|
||||
}
|
||||
|
||||
/** The switch for those summaries, above the links it changes, on both shells. */
|
||||
function DayEventsSwitch({ on, onToggle }: { on: boolean; onToggle: () => void }) {
|
||||
const { t } = useTranslation()
|
||||
const hintId = useId()
|
||||
return (
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<div className="text-body font-medium text-content">{t('dashboard.ics.dayEvents')}</div>
|
||||
<p id={hintId} className="m-0 mt-0.5 text-caption leading-normal text-content-faint">
|
||||
{t('dashboard.ics.dayEventsHint')}
|
||||
</p>
|
||||
</div>
|
||||
<ToggleSwitch on={on} onToggle={onToggle} label={t('dashboard.ics.dayEvents')} describedBy={hintId} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared subscribe dialog for the per-trip and all-trips ICS feeds. Opening it
|
||||
* only *reads* the current token — it never mints one silently. The user
|
||||
@@ -37,11 +63,13 @@ export function IcsSubscribeModal({ endpoint, title, description, onClose }: Ics
|
||||
const [feedUrl, setFeedUrl] = useState<string | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [dayEvents, setDayEvents] = useState(true)
|
||||
const toggleDayEvents = () => setDayEvents(on => !on)
|
||||
const isPhone = useIsPhone()
|
||||
const { t } = useTranslation()
|
||||
const titleId = useId()
|
||||
|
||||
const httpsUrl = feedUrl ? absolutize(feedUrl) : ''
|
||||
const httpsUrl = feedUrl ? withDayEvents(absolutize(feedUrl), dayEvents) : ''
|
||||
const webcalUrl = httpsUrl ? httpsUrl.replace(/^https?:\/\//, 'webcal://') : ''
|
||||
|
||||
const load = useCallback(async () => {
|
||||
@@ -83,6 +111,8 @@ export function IcsSubscribeModal({ endpoint, title, description, onClose }: Ics
|
||||
httpsUrl={httpsUrl}
|
||||
webcalUrl={webcalUrl}
|
||||
mutate={mutate}
|
||||
dayEvents={dayEvents}
|
||||
onToggleDayEvents={toggleDayEvents}
|
||||
/>
|
||||
)
|
||||
}
|
||||
@@ -158,6 +188,9 @@ export function IcsSubscribeModal({ endpoint, title, description, onClose }: Ics
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div style={{ marginBottom: 16 }}>
|
||||
<DayEventsSwitch on={dayEvents} onToggle={toggleDayEvents} />
|
||||
</div>
|
||||
<SubscribeLinks httpsUrl={httpsUrl} webcalUrl={webcalUrl} />
|
||||
|
||||
<div style={{ marginTop: 16, paddingTop: 12, borderTop: '1px solid var(--border-faint)', display: 'flex', gap: 8 }}>
|
||||
@@ -208,7 +241,7 @@ export function IcsSubscribeModal({ endpoint, title, description, onClose }: Ics
|
||||
// A secondary footer button in the danger colour, for the switch that takes the link away.
|
||||
const TURN_OFF_BTN = 'inline-flex items-center gap-1.5 rounded-[10px] bg-surface-tertiary px-3.5 py-2 font-medium text-danger hover:bg-danger-soft disabled:cursor-default disabled:opacity-50'
|
||||
|
||||
function DesktopSubscribeDialog({ titleId, title, description, onClose, loading, busy, feedUrl, httpsUrl, webcalUrl, mutate }: {
|
||||
function DesktopSubscribeDialog({ titleId, title, description, onClose, loading, busy, feedUrl, httpsUrl, webcalUrl, mutate, dayEvents, onToggleDayEvents }: {
|
||||
titleId: string
|
||||
title: string
|
||||
description: string
|
||||
@@ -219,6 +252,8 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading,
|
||||
httpsUrl: string
|
||||
webcalUrl: string
|
||||
mutate: (method: 'POST' | 'PUT' | 'DELETE') => Promise<void>
|
||||
dayEvents: boolean
|
||||
onToggleDayEvents: () => void
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
const header = (
|
||||
@@ -255,6 +290,7 @@ function DesktopSubscribeDialog({ titleId, title, description, onClose, loading,
|
||||
} else {
|
||||
body = (
|
||||
<>
|
||||
<DayEventsSwitch on={dayEvents} onToggle={onToggleDayEvents} />
|
||||
<SubscribeLinks httpsUrl={httpsUrl} webcalUrl={webcalUrl} />
|
||||
<p className={hint} style={fs(11.5)}>
|
||||
{t('dashboard.ics.manageHint')}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { tripCalendarQuerySchema } from '@trek/shared';
|
||||
|
||||
import { createZodDto } from 'nestjs-zod';
|
||||
|
||||
/**
|
||||
* Query DTO of every route that serves a trip calendar: the download in the
|
||||
* trips controller and the two public feeds. The global ZodValidationPipe
|
||||
* validates it by metatype, like the body DTOs.
|
||||
*/
|
||||
export class TripCalendarQueryDto extends createZodDto(tripCalendarQuerySchema) {}
|
||||
@@ -14,7 +14,7 @@ import { addDays } from '../days/days.service';
|
||||
import { ReservationsService } from '../reservations/reservations.service';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { isTransportReservationType } from '@trek/shared';
|
||||
import { isTransportReservationType, type TripCalendarQuery } from '@trek/shared';
|
||||
|
||||
/** The VCALENDAR preamble every TREK calendar starts with, single-trip or merged. */
|
||||
export const CALENDAR_HEADER =
|
||||
@@ -32,6 +32,17 @@ export interface TripCalendar {
|
||||
events: string[];
|
||||
}
|
||||
|
||||
/** What a trip's calendar holds beyond the trip itself, its timed stops and its bookings. */
|
||||
export interface TripCalendarOptions {
|
||||
/** The all-day summary per day with untimed stops or notes ("Day 1", ...). On unless set to false (#2602). */
|
||||
dayEvents?: boolean;
|
||||
}
|
||||
|
||||
/** The options a calendar request asks for: `days=0` leaves out the per-day summaries. */
|
||||
export function calendarOptionsFromQuery(query: TripCalendarQuery): TripCalendarOptions {
|
||||
return { dayEvents: query.days !== '0' };
|
||||
}
|
||||
|
||||
// ── ICS folding ─────────────────────────────────────────────────────────────
|
||||
|
||||
// RFC 5545 §3.1: content lines longer than 75 octets must be folded with a CRLF
|
||||
@@ -240,7 +251,7 @@ export class CalendarService {
|
||||
* because a user-supplied SUMMARY can legitimately contain the literal
|
||||
* "END:VEVENT". Handing out the parts removes the need to reassemble them.
|
||||
*/
|
||||
async buildTripCalendar(tripId: string | number): Promise<TripCalendar> {
|
||||
async buildTripCalendar(tripId: string | number, options: TripCalendarOptions = {}): Promise<TripCalendar> {
|
||||
const trip = await this.tripsRepo.findRaw(tripId);
|
||||
if (!trip) throw new NotFoundError('Trip not found');
|
||||
|
||||
@@ -363,8 +374,10 @@ export class CalendarService {
|
||||
events.push(ev);
|
||||
}
|
||||
|
||||
// Build all-day summary event if there are untimed activities or notes
|
||||
if (untimed.length > 0 || notes.length > 0) {
|
||||
// Build all-day summary event if there are untimed activities or notes,
|
||||
// unless the subscriber asked for a calendar without them: the summary
|
||||
// sits above every day and can crowd out everything else there (#2602).
|
||||
if (options.dayEvents !== false && (untimed.length > 0 || notes.length > 0)) {
|
||||
const dayTitle = day.title || `Day ${day.day_number}`;
|
||||
const endStr = fmtDate(addDays(day.date, 1));
|
||||
|
||||
@@ -914,8 +927,11 @@ export class CalendarService {
|
||||
}
|
||||
|
||||
/** One trip's calendar as a finished, foldable VCALENDAR document. */
|
||||
async exportICS(tripId: string | number): Promise<{ ics: string; filename: string }> {
|
||||
const cal = await this.buildTripCalendar(tripId);
|
||||
async exportICS(
|
||||
tripId: string | number,
|
||||
options: TripCalendarOptions = {},
|
||||
): Promise<{ ics: string; filename: string }> {
|
||||
const cal = await this.buildTripCalendar(tripId, options);
|
||||
const ics =
|
||||
CALENDAR_HEADER +
|
||||
`X-WR-CALNAME:${cal.calName}\r\n` +
|
||||
|
||||
@@ -4,11 +4,13 @@ import type { User } from '../../types';
|
||||
import { CurrentUser } from '../auth-core/current-user.decorator';
|
||||
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
|
||||
import { Public } from '../auth-core/public.decorator';
|
||||
import { TripCalendarQueryDto } from '../calendar/calendar.dto';
|
||||
import { calendarOptionsFromQuery } from '../calendar/calendar.service';
|
||||
import { contentDisposition } from '../common/content-disposition';
|
||||
import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';
|
||||
import { Trip } from '../permissions/trip.decorator';
|
||||
import { FeedsService } from './feeds.service';
|
||||
import { Controller, Delete, Get, Param, Post, Put, Req, Res, UseGuards } from '@nestjs/common';
|
||||
import { Controller, Delete, Get, Param, Post, Put, Query, Req, Res, UseGuards } from '@nestjs/common';
|
||||
|
||||
import type { Request, Response } from 'express';
|
||||
|
||||
@@ -27,7 +29,8 @@ function resolveFeedBase(req: Request): string {
|
||||
|
||||
/**
|
||||
* Public subscribable ICS feed endpoints — no auth required.
|
||||
* The secret token in the URL acts as the access credential.
|
||||
* The secret token in the URL acts as the access credential. `?days=0` leaves
|
||||
* the per-day summaries out of the feed (#2602); the subscribe dialog adds it.
|
||||
*/
|
||||
@Controller('api/feed')
|
||||
@Public('the secret token in the feed URL is the credential; calendar clients never send a session')
|
||||
@@ -35,8 +38,12 @@ export class FeedsPublicController {
|
||||
constructor(private readonly feeds: FeedsService) {}
|
||||
|
||||
@Get('trip/:token.ics')
|
||||
async tripFeed(@Param('token') token: string, @Res() res: Response): Promise<void> {
|
||||
const result = await this.feeds.buildTripIcs(token);
|
||||
async tripFeed(
|
||||
@Param('token') token: string,
|
||||
@Query() query: TripCalendarQueryDto,
|
||||
@Res() res: Response,
|
||||
): Promise<void> {
|
||||
const result = await this.feeds.buildTripIcs(token, calendarOptionsFromQuery(query));
|
||||
if (!result) {
|
||||
res.status(404).json({ error: 'Feed not found' });
|
||||
return;
|
||||
@@ -49,8 +56,12 @@ export class FeedsPublicController {
|
||||
}
|
||||
|
||||
@Get('user/:token.ics')
|
||||
async userFeed(@Param('token') token: string, @Res() res: Response): Promise<void> {
|
||||
const result = await this.feeds.buildUserIcs(token);
|
||||
async userFeed(
|
||||
@Param('token') token: string,
|
||||
@Query() query: TripCalendarQueryDto,
|
||||
@Res() res: Response,
|
||||
): Promise<void> {
|
||||
const result = await this.feeds.buildUserIcs(token, calendarOptionsFromQuery(query));
|
||||
if (!result) {
|
||||
res.status(404).json({ error: 'Feed not found' });
|
||||
return;
|
||||
|
||||
@@ -18,6 +18,14 @@ import { FeedsService } from './feeds.service';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { idSchema } from '@trek/shared';
|
||||
|
||||
/**
|
||||
* The feed routes take `?days=0` (#2602), which the subscribe dialog appends
|
||||
* on request. The tools hand back the plain URL, so their descriptions say how
|
||||
* to ask for that variant instead of minting a second kind of link.
|
||||
*/
|
||||
const DAY_EVENTS_HINT =
|
||||
' Add ?days=0 to the URL for a calendar without the all-day "Day 1", "Day 2" summaries; the trip itself, timed stops and bookings stay.';
|
||||
|
||||
/**
|
||||
* Calendar-feed MCP surface, mirroring the two authenticated token controllers
|
||||
* in feeds.controller.ts. Not a port of a legacy registrar: the feeds domain
|
||||
@@ -72,7 +80,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'get_trip_calendar_feed',
|
||||
description:
|
||||
'Get the subscribable calendar feed URL of one trip, or null when the feed is switched off. This is a live subscription a calendar app re-reads hourly, so it keeps up with the itinerary. Prefer export_trip_ics when the user wants a one-off .ics file to import once and be done.',
|
||||
'Get the subscribable calendar feed URL of one trip, or null when the feed is switched off. This is a live subscription a calendar app re-reads hourly, so it keeps up with the itinerary. Prefer export_trip_ics when the user wants a one-off .ics file to import once and be done.' +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {
|
||||
tripId: idSchema,
|
||||
},
|
||||
@@ -88,7 +97,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'enable_trip_calendar_feed',
|
||||
description:
|
||||
"Switch on the subscribable calendar feed of one trip and return its URL. Safe to repeat: a trip that already has a feed keeps the URL it has, so subscriptions somebody already set up survive. The URL carries a secret token and asks for no login, so whoever holds it can read the trip's dates.",
|
||||
"Switch on the subscribable calendar feed of one trip and return its URL. Safe to repeat: a trip that already has a feed keeps the URL it has, so subscriptions somebody already set up survive. The URL carries a secret token and asks for no login, so whoever holds it can read the trip's dates." +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {
|
||||
tripId: idSchema,
|
||||
},
|
||||
@@ -104,7 +114,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'rotate_trip_calendar_feed',
|
||||
description:
|
||||
"Issue a fresh URL for one trip's calendar feed. Every calendar subscribed to the old URL silently stops updating, so use this when the old link leaked or the user asked to cut it off, not to switch the feed on: enable_trip_calendar_feed does that without breaking anything.",
|
||||
"Issue a fresh URL for one trip's calendar feed. Every calendar subscribed to the old URL silently stops updating, so use this when the old link leaked or the user asked to cut it off, not to switch the feed on: enable_trip_calendar_feed does that without breaking anything." +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {
|
||||
tripId: idSchema,
|
||||
},
|
||||
@@ -142,7 +153,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'get_all_trips_calendar_feed',
|
||||
description:
|
||||
'Get the subscribable calendar feed URL covering every trip the user can open, or null when it is switched off. One feed for the whole travel calendar; get_trip_calendar_feed is the per-trip one.',
|
||||
'Get the subscribable calendar feed URL covering every trip the user can open, or null when it is switched off. One feed for the whole travel calendar; get_trip_calendar_feed is the per-trip one.' +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {},
|
||||
annotations: TOOL_ANNOTATIONS_READONLY,
|
||||
access: { group: 'trips', mode: 'share' },
|
||||
@@ -154,7 +166,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'enable_all_trips_calendar_feed',
|
||||
description:
|
||||
"Switch on the calendar feed covering every trip the user can open and return its URL. Safe to repeat: an existing feed keeps its URL. The URL needs no login and follows the user's trips as they change, so a trip added later shows up in it without anyone re-subscribing.",
|
||||
"Switch on the calendar feed covering every trip the user can open and return its URL. Safe to repeat: an existing feed keeps its URL. The URL needs no login and follows the user's trips as they change, so a trip added later shows up in it without anyone re-subscribing." +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {},
|
||||
annotations: TOOL_ANNOTATIONS_WRITE,
|
||||
access: { group: 'trips', mode: 'share' },
|
||||
@@ -166,7 +179,8 @@ export class FeedsMcp {
|
||||
@Tool({
|
||||
name: 'rotate_all_trips_calendar_feed',
|
||||
description:
|
||||
'Issue a fresh URL for the all-trips calendar feed. Every calendar subscribed to the old URL stops updating. Use it when that link leaked; enable_all_trips_calendar_feed is the way to switch the feed on without breaking existing subscriptions.',
|
||||
'Issue a fresh URL for the all-trips calendar feed. Every calendar subscribed to the old URL stops updating. Use it when that link leaked; enable_all_trips_calendar_feed is the way to switch the feed on without breaking existing subscriptions.' +
|
||||
DAY_EVENTS_HINT,
|
||||
inputSchema: {},
|
||||
annotations: TOOL_ANNOTATIONS_NON_IDEMPOTENT,
|
||||
access: { group: 'trips', mode: 'share' },
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Trips } from '../../db/entities/Trips.entity';
|
||||
import { Users } from '../../db/entities/Users.entity';
|
||||
import type { TripsRepository } from '../../db/repositories/Trips.repository';
|
||||
import type { UsersRepository } from '../../db/repositories/Users.repository';
|
||||
import { CalendarService, CALENDAR_HEADER, foldICS } from '../calendar/calendar.service';
|
||||
import { CalendarService, CALENDAR_HEADER, foldICS, type TripCalendarOptions } from '../calendar/calendar.service';
|
||||
import { InjectRepository } from '@mikro-orm/nestjs';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@@ -96,11 +96,14 @@ export class FeedsService {
|
||||
|
||||
// ── ICS generation ───────────────────────────────────────────────────────
|
||||
|
||||
async buildTripIcs(token: string): Promise<{ ics: string; filename: string } | null> {
|
||||
async buildTripIcs(
|
||||
token: string,
|
||||
options: TripCalendarOptions = {},
|
||||
): Promise<{ ics: string; filename: string } | null> {
|
||||
const tripId = await this.tripsRepo.findIdByFeedToken(token);
|
||||
if (tripId === undefined) return null;
|
||||
try {
|
||||
const cal = await this.calendar.buildTripCalendar(tripId);
|
||||
const cal = await this.calendar.buildTripCalendar(tripId, options);
|
||||
// Same document as the one-time download, plus the subscription refresh
|
||||
// hints so clients re-fetch hourly. Assembled from the calendar's parts
|
||||
// rather than string-surgeried into the finished text.
|
||||
@@ -118,7 +121,10 @@ export class FeedsService {
|
||||
}
|
||||
}
|
||||
|
||||
async buildUserIcs(token: string): Promise<{ ics: string; calName: string } | null> {
|
||||
async buildUserIcs(
|
||||
token: string,
|
||||
options: TripCalendarOptions = {},
|
||||
): Promise<{ ics: string; calName: string } | null> {
|
||||
const user = await this.usersRepo.findIdAndUsernameByFeedToken(token);
|
||||
if (!user) return null;
|
||||
|
||||
@@ -144,7 +150,7 @@ export class FeedsService {
|
||||
let events = '';
|
||||
for (const id of tripIds) {
|
||||
try {
|
||||
const cal = await this.calendar.buildTripCalendar(id);
|
||||
const cal = await this.calendar.buildTripCalendar(id, options);
|
||||
for (const [tzid, block] of cal.timezones) {
|
||||
if (!zones.has(tzid)) zones.set(tzid, block);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ import { AuditService } from '../audit/audit.service';
|
||||
import { getClientIp } from '../audit/client-ip';
|
||||
import { CurrentUser } from '../auth-core/current-user.decorator';
|
||||
import { JwtAuthGuard } from '../auth-core/jwt-auth.guard';
|
||||
import { CalendarService } from '../calendar/calendar.service';
|
||||
import { TripCalendarQueryDto } from '../calendar/calendar.dto';
|
||||
import { CalendarService, calendarOptionsFromQuery } from '../calendar/calendar.service';
|
||||
import { contentDisposition } from '../common/content-disposition';
|
||||
import { isDemoWriteBlocked, DEMO_WRITE_ERROR } from '../common/demo-write';
|
||||
import { StorageReleaseService } from '../storage/storage-release.service';
|
||||
@@ -340,12 +341,17 @@ export class TripsController {
|
||||
}
|
||||
|
||||
@Get(':id/export.ics')
|
||||
async exportIcs(@CurrentUser() user: User, @Param('id') id: string, @Res() res: Response) {
|
||||
async exportIcs(
|
||||
@CurrentUser() user: User,
|
||||
@Param('id') id: string,
|
||||
@Query() query: TripCalendarQueryDto,
|
||||
@Res() res: Response,
|
||||
) {
|
||||
if (!(await this.trips.canAccessTrip(id, user.id))) {
|
||||
throw new HttpException({ error: 'Trip not found' }, 404);
|
||||
}
|
||||
try {
|
||||
const { ics, filename } = await this.calendar.exportICS(id);
|
||||
const { ics, filename } = await this.calendar.exportICS(id, calendarOptionsFromQuery(query));
|
||||
res.setHeader('Content-Type', 'text/calendar; charset=utf-8');
|
||||
res.setHeader('Content-Disposition', contentDisposition(filename, 'attachment'));
|
||||
res.send(ics);
|
||||
|
||||
@@ -691,14 +691,20 @@ export class TripsMcp {
|
||||
"Export a trip's itinerary and reservations as iCalendar (.ics) format text. Useful for importing into calendar apps.",
|
||||
inputSchema: {
|
||||
tripId: idSchema,
|
||||
dayEvents: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
'false leaves out the all-day summary each day with untimed places or notes gets ("Day 1", ...), the same as days=0 on the download; the trip itself, timed stops and bookings stay. Default true.',
|
||||
),
|
||||
},
|
||||
annotations: TOOL_ANNOTATIONS_READONLY,
|
||||
access: (ctx) => canReadTrips(ctx.scopes),
|
||||
})
|
||||
async exportTripIcs({ tripId }: { tripId: number }, ctx: McpContext) {
|
||||
async exportTripIcs({ tripId, dayEvents }: { tripId: number; dayEvents?: boolean }, ctx: McpContext) {
|
||||
if (!(await this.trips.canAccessTrip(tripId, ctx.userId))) return noAccess();
|
||||
try {
|
||||
const { ics, filename } = await this.calendar.exportICS(tripId);
|
||||
const { ics, filename } = await this.calendar.exportICS(tripId, { dayEvents });
|
||||
return ok({ ics, filename });
|
||||
} catch {
|
||||
return { content: [{ type: 'text' as const, text: 'Trip not found.' }], isError: true };
|
||||
|
||||
@@ -256,7 +256,7 @@ describe('Calendar-feed e2e (real auth guard + temp SQLite)', () => {
|
||||
expect(res.text).toContain('REFRESH-INTERVAL;VALUE=DURATION:PT1H');
|
||||
expect(res.text).toContain('X-PUBLISHED-TTL:PT1H');
|
||||
expect(res.text).toContain('BEGIN:VEVENT');
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id);
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id, { dayEvents: true });
|
||||
});
|
||||
|
||||
// The @Public feed quoted cal.filename straight into Content-Disposition, so
|
||||
@@ -279,6 +279,17 @@ describe('Calendar-feed e2e (real auth guard + temp SQLite)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('public trip feed: days=0 asks the calendar for no per-day summaries (#2602)', async () => {
|
||||
const { user: owner } = createUser(db);
|
||||
const trip = createTrip(db, owner.id, { start_date: '2026-01-01', end_date: '2099-01-01' });
|
||||
const gen = await request(server).post(`/api/trips/${trip.id}/feed/token`).set('Cookie', sessionCookie(owner.id));
|
||||
const token = gen.body.feed_url.match(/trip\/([0-9a-f-]+)\.ics$/)![1];
|
||||
|
||||
const res = await request(server).get(`/api/feed/trip/${token}.ics?days=0`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id, { dayEvents: false });
|
||||
});
|
||||
|
||||
it('public trip feed: 404 for an unknown token', async () => {
|
||||
const res = await request(server).get('/api/feed/trip/00000000-0000-0000-0000-000000000000.ics');
|
||||
expect(res.status).toBe(404);
|
||||
@@ -331,6 +342,20 @@ describe('Calendar-feed e2e (real auth guard + temp SQLite)', () => {
|
||||
expect(calledIds).toEqual([owned.id, shared.id].sort((a, b) => a - b));
|
||||
});
|
||||
|
||||
it('all-trips feed: days=0 reaches the calendar of every trip (#2602)', async () => {
|
||||
const { user: owner } = createUser(db);
|
||||
const first = createTrip(db, owner.id, { start_date: '2026-01-01', end_date: '2099-01-01' });
|
||||
const second = createTrip(db, owner.id, { start_date: '2026-02-01', end_date: '2099-01-01' });
|
||||
|
||||
const gen = await request(server).post('/api/feed/user/token').set('Cookie', sessionCookie(owner.id));
|
||||
const token = gen.body.feed_url.match(/user\/([0-9a-f-]+)\.ics$/)![1];
|
||||
|
||||
const res = await request(server).get(`/api/feed/user/${token}.ics?days=0`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(first.id, { dayEvents: false });
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(second.id, { dayEvents: false });
|
||||
});
|
||||
|
||||
it('public user feed: 404 for an unknown token', async () => {
|
||||
const res = await request(server).get('/api/feed/user/00000000-0000-0000-0000-000000000000.ics');
|
||||
expect(res.status).toBe(404);
|
||||
|
||||
@@ -328,6 +328,25 @@ describe('Tool: disable_all_trips_calendar_feed', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('calendar feed tools, the lean variant (#2602)', () => {
|
||||
it('tell a model how to ask for a feed without the per-day summaries', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
await withHarness(user.id, async (h) => {
|
||||
const { tools } = await h.client.listTools();
|
||||
for (const name of [
|
||||
'get_trip_calendar_feed',
|
||||
'enable_trip_calendar_feed',
|
||||
'rotate_trip_calendar_feed',
|
||||
'get_all_trips_calendar_feed',
|
||||
'enable_all_trips_calendar_feed',
|
||||
'rotate_all_trips_calendar_feed',
|
||||
]) {
|
||||
expect(tools.find((tool) => tool.name === name)?.description).toContain('?days=0');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('all-trips calendar feed gates', () => {
|
||||
it.each(['enable_all_trips_calendar_feed', 'rotate_all_trips_calendar_feed', 'disable_all_trips_calendar_feed'])(
|
||||
'%s refuses a demo account',
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Users } from '../../../src/db/entities/Users.entity';
|
||||
import { GUEST_HAS_PAYMENTS } from '../../../src/nest/budget/budget-departure.helpers';
|
||||
import { NotificationsService } from '../../../src/nest/notifications/notifications.service';
|
||||
import { invalidatePermissionsCache } from '../../../src/nest/permissions/permissions-cache';
|
||||
import { createUser, createAdmin, createTrip, addTripMember } from '../../helpers/factories';
|
||||
import { createUser, createAdmin, createTrip, addTripMember, createDay, createDayNote } from '../../helpers/factories';
|
||||
import { addBudgetItemMember, addBudgetItemPayer, makeBudgetItem } from '../../helpers/factories/budget';
|
||||
import { countRows, findRow, updateRows } from '../../helpers/factories/rows';
|
||||
import { setAppSetting } from '../../helpers/factories/settings';
|
||||
@@ -492,6 +492,25 @@ describe('Tool: export_trip_ics', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('leaves the per-day summaries out with dayEvents false, like days=0 on the route (#2602)', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Paris Trip', start_date: '2025-06-01', end_date: '2025-06-05' });
|
||||
const day = createDay(testDb, trip.id, { date: '2025-06-01', day_number: 1 });
|
||||
createDayNote(testDb, day.id, trip.id, { text: 'Pick up the museum pass' });
|
||||
await withHarness(user.id, async (h) => {
|
||||
const call = async (args: Record<string, unknown>) =>
|
||||
(
|
||||
parseToolResult(
|
||||
await h.client.callTool({ name: 'export_trip_ics', arguments: { tripId: trip.id, ...args } }),
|
||||
) as { ics: string }
|
||||
).ics;
|
||||
expect(await call({})).toContain('SUMMARY:Day 1');
|
||||
const lean = await call({ dayEvents: false });
|
||||
expect(lean).not.toContain('SUMMARY:Day 1');
|
||||
expect(lean).toContain('SUMMARY:Paris Trip');
|
||||
});
|
||||
});
|
||||
|
||||
it('returns access denied for non-member', async () => {
|
||||
const { user } = createUser(testDb);
|
||||
const { user: other } = createUser(testDb);
|
||||
|
||||
@@ -30,7 +30,7 @@ import { ReservationsService } from '../../../src/nest/reservations/reservations
|
||||
import { ReservationsReadService } from '../../../src/nest/reservations/reservations-read.service';
|
||||
import { BudgetService } from '../../../src/nest/budget/budget.service';
|
||||
import { ExchangeRatesService } from '../../../src/nest/budget/exchange-rates.service';
|
||||
import { CalendarService, foldICS } from '../../../src/nest/calendar/calendar.service';
|
||||
import { CalendarService, calendarOptionsFromQuery, foldICS } from '../../../src/nest/calendar/calendar.service';
|
||||
import { CalendarModule } from '../../../src/nest/calendar/calendar.module';
|
||||
import { expectRegisteredProvider } from '../../helpers/module-providers';
|
||||
import { notificationsStub } from '../../helpers/notifications';
|
||||
@@ -1682,6 +1682,57 @@ describe('folded quirk branches', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('per-day summaries (#2602)', () => {
|
||||
async function tripWithEveryKindOfDay() {
|
||||
const { user } = createUser(testDb);
|
||||
const trip = createTrip(testDb, user.id, { title: 'Lisbon', start_date: '2025-06-02', end_date: '2025-06-03' });
|
||||
const day = createDay(testDb, trip.id, { date: '2025-06-02', day_number: 1 });
|
||||
const untimed = createPlace(testDb, trip.id, { name: 'Untimed Spot' });
|
||||
createDayAssignment(testDb, day.id, untimed.id);
|
||||
createDayNote(testDb, day.id, trip.id, { text: 'Buy tram tickets' });
|
||||
const timed = createPlace(testDb, trip.id, { name: 'Castle Visit' });
|
||||
const assignment = createDayAssignment(testDb, day.id, timed.id);
|
||||
await updateRows(orm, DayAssignments, { id: assignment.id }, { assignment_time: '10:00' });
|
||||
return trip;
|
||||
}
|
||||
|
||||
it('CAL-2602-001: are in the calendar by default', async () => {
|
||||
const trip = await tripWithEveryKindOfDay();
|
||||
|
||||
const { ics } = await svc.exportICS(trip.id);
|
||||
|
||||
expect(ics).toContain('SUMMARY:Day 1');
|
||||
});
|
||||
|
||||
it('CAL-2602-002: dayEvents false leaves them out and keeps the trip and its timed stops', async () => {
|
||||
const trip = await tripWithEveryKindOfDay();
|
||||
|
||||
const { ics } = await svc.exportICS(trip.id, { dayEvents: false });
|
||||
|
||||
expect(ics).not.toContain('SUMMARY:Day 1');
|
||||
expect(ics).not.toContain('Untimed Spot');
|
||||
expect(ics).not.toContain('Buy tram tickets');
|
||||
expect(ics).toContain('SUMMARY:Lisbon');
|
||||
expect(ics).toContain('SUMMARY:Castle Visit');
|
||||
});
|
||||
|
||||
it('CAL-2602-003: buildTripCalendar drops the same events for the feeds', async () => {
|
||||
const trip = await tripWithEveryKindOfDay();
|
||||
|
||||
const all = await svc.buildTripCalendar(trip.id);
|
||||
const lean = await svc.buildTripCalendar(trip.id, { dayEvents: false });
|
||||
|
||||
expect(lean.events).toHaveLength(all.events.length - 1);
|
||||
expect(lean.events.some((event) => event.includes('UID:trek-day-'))).toBe(false);
|
||||
});
|
||||
|
||||
it('CAL-2602-004: days=0 in the query turns them off, days=1 or nothing keeps them', () => {
|
||||
expect(calendarOptionsFromQuery({ days: '0' })).toEqual({ dayEvents: false });
|
||||
expect(calendarOptionsFromQuery({ days: '1' })).toEqual({ dayEvents: true });
|
||||
expect(calendarOptionsFromQuery({})).toEqual({ dayEvents: true });
|
||||
});
|
||||
});
|
||||
|
||||
// foldICS is the last thing that touches the bytes of both the download and the
|
||||
// feed, and it is exported, so it is pinned directly instead of through a trip.
|
||||
describe('foldICS', () => {
|
||||
|
||||
@@ -341,7 +341,15 @@ describe('buildTripIcs', () => {
|
||||
);
|
||||
expect(result!.ics.startsWith('BEGIN:VCALENDAR\r\nVERSION:2.0\r\n')).toBe(true);
|
||||
expect(result!.ics.endsWith('END:VEVENT\r\nEND:VCALENDAR\r\n')).toBe(true);
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id);
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id, {});
|
||||
});
|
||||
|
||||
it('FEED-SVC-015b: hands the calendar options on, so the feed can leave the per-day summaries out (#2602)', async () => {
|
||||
const { trip } = await seedTrip('tok-trip');
|
||||
|
||||
await svc.buildTripIcs('tok-trip', { dayEvents: false });
|
||||
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(trip.id, { dayEvents: false });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -422,6 +430,17 @@ describe('buildUserIcs', () => {
|
||||
expect(ics.replace(/\r\n /g, '')).toContain(`SUMMARY:${longSummary}\r\n`);
|
||||
});
|
||||
|
||||
it('FEED-SVC-019b: hands the calendar options to every trip of the feed (#2602)', async () => {
|
||||
const user = await seedUserWithToken('tok-user');
|
||||
const first = createTrip(testDb, user.id, { start_date: '2026-01-01' });
|
||||
const second = createTrip(testDb, user.id, { start_date: '2026-02-01' });
|
||||
|
||||
await svc.buildUserIcs('tok-user', { dayEvents: false });
|
||||
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(first.id, { dayEvents: false });
|
||||
expect(buildTripCalendar).toHaveBeenCalledWith(second.id, { dayEvents: false });
|
||||
});
|
||||
|
||||
it('FEED-SVC-020: the display name is escaped for the header but returned raw', async () => {
|
||||
// An unescaped ; or , ends the property value early, so the calendar shows up
|
||||
// under a truncated name. The returned calName feeds the HTTP layer, not ICS,
|
||||
|
||||
@@ -679,21 +679,28 @@ describe('TripsController (parity with the legacy /api/trips route)', async () =
|
||||
it('404 without access, else sends the calendar with headers', async () => {
|
||||
expect(
|
||||
await thrownAsync(() =>
|
||||
tc(svc({ canAccessTrip: vi.fn().mockResolvedValue(undefined) })).exportIcs(user, '9', makeRes()),
|
||||
tc(svc({ canAccessTrip: vi.fn().mockResolvedValue(undefined) })).exportIcs(user, '9', {}, makeRes()),
|
||||
),
|
||||
).toEqual({ status: 404, body: { error: 'Trip not found' } });
|
||||
const res = { setHeader: vi.fn(), send: vi.fn() };
|
||||
const cal = { exportICS: vi.fn().mockReturnValue({ ics: 'BEGIN:VCALENDAR', filename: 'trip.ics' }) };
|
||||
await tc(svc(), cal).exportIcs(user, '9', res as never);
|
||||
await tc(svc(), cal).exportIcs(user, '9', {}, res as never);
|
||||
expect(res.setHeader).toHaveBeenCalledWith('Content-Type', 'text/calendar; charset=utf-8');
|
||||
expect(res.setHeader).toHaveBeenCalledWith('Content-Disposition', 'attachment; filename="trip.ics"');
|
||||
expect(res.send).toHaveBeenCalledWith('BEGIN:VCALENDAR');
|
||||
expect(cal.exportICS).toHaveBeenCalledWith('9', { dayEvents: true });
|
||||
});
|
||||
|
||||
it('leaves the per-day summaries out for days=0 (#2602)', async () => {
|
||||
const cal = { exportICS: vi.fn().mockReturnValue({ ics: 'BEGIN:VCALENDAR', filename: 'trip.ics' }) };
|
||||
await tc(svc(), cal).exportIcs(user, '9', { days: '0' }, makeRes());
|
||||
expect(cal.exportICS).toHaveBeenCalledWith('9', { dayEvents: false });
|
||||
});
|
||||
|
||||
it('folds a non-ASCII filename into an ASCII header with filename* instead of crashing setHeader (#2165)', async () => {
|
||||
const res = { setHeader: vi.fn(), send: vi.fn() };
|
||||
const cal = { exportICS: vi.fn().mockReturnValue({ ics: 'BEGIN:VCALENDAR', filename: '沖縄.ics' }) };
|
||||
await tc(svc(), cal).exportIcs(user, '9', res as never);
|
||||
await tc(svc(), cal).exportIcs(user, '9', {}, res as never);
|
||||
expect(res.setHeader).toHaveBeenCalledWith(
|
||||
'Content-Disposition',
|
||||
'attachment; filename="download.ics"; filename*=UTF-8\'\'%E6%B2%96%E7%B8%84.ics',
|
||||
@@ -706,7 +713,7 @@ describe('TripsController (parity with the legacy /api/trips route)', async () =
|
||||
throw new NotFoundError('gone');
|
||||
}),
|
||||
};
|
||||
expect(await thrownAsync(() => tc(svc(), nf).exportIcs(user, '9', makeRes()))).toEqual({
|
||||
expect(await thrownAsync(() => tc(svc(), nf).exportIcs(user, '9', {}, makeRes()))).toEqual({
|
||||
status: 404,
|
||||
body: { error: 'gone' },
|
||||
});
|
||||
@@ -715,7 +722,7 @@ describe('TripsController (parity with the legacy /api/trips route)', async () =
|
||||
throw new Error('boom');
|
||||
}),
|
||||
};
|
||||
await expect(tc(svc(), other).exportIcs(user, '9', makeRes())).rejects.toThrow('boom');
|
||||
await expect(tc(svc(), other).exportIcs(user, '9', {}, makeRes())).rejects.toThrow('boom');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -304,5 +304,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'أضف إلى تقويم Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'أو انسخ الرابط يدويًا',
|
||||
'dashboard.ics.pasteFromUrl': 'الصقه في «من عنوان URL»',
|
||||
'dashboard.ics.dayEvents': 'أحداث ملخص اليوم',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'حدث يستمر طوال اليوم لكل يوم يضم الأماكن والملاحظات التي ليس لها وقت. تغيير هذا الخيار يغيّر الرابط، لذا اشترك مجددًا بالرابط الجديد.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -238,5 +238,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Apple Təqvimə / Outlook-a əlavə et',
|
||||
'dashboard.ics.copyManually': 'Və ya keçidi əllə kopyalayın',
|
||||
'dashboard.ics.pasteFromUrl': '“URL-dən” sahəsinə yapışdırın',
|
||||
'dashboard.ics.dayEvents': 'Günün icmalı tədbirləri',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Hər gün üçün vaxtı olmayan məkanları və qeydləri göstərən bütün günlük tədbir. Bunu dəyişmək linki dəyişir, ona görə yeni linklə yenidən abunə olun.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -235,5 +235,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Adicionar ao Calendário da Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Ou copie um link manualmente',
|
||||
'dashboard.ics.pasteFromUrl': 'cole em “Do URL”',
|
||||
'dashboard.ics.dayEvents': 'Eventos de resumo do dia',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Um evento de dia inteiro para cada dia com os lugares e notas sem horário. Mudar isso muda o link, então assine de novo com o novo link.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -238,5 +238,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Afegeix a Calendari d’Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'O copia un enllaç manualment',
|
||||
'dashboard.ics.pasteFromUrl': 'enganxa’l a «Des d’URL»',
|
||||
'dashboard.ics.dayEvents': 'Esdeveniments de resum del dia',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Un esdeveniment de dia sencer per a cada dia amb els llocs i les notes sense hora. Canviar-ho canvia l’enllaç, així que torna a subscriure’t amb el nou.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -252,5 +252,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Přidat do Kalendáře Apple / Outlooku',
|
||||
'dashboard.ics.copyManually': 'Nebo odkaz zkopírujte ručně',
|
||||
'dashboard.ics.pasteFromUrl': 'vložte do „Z adresy URL“',
|
||||
'dashboard.ics.dayEvents': 'Události s přehledem dne',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Celodenní událost pro každý den s místy a poznámkami bez času. Změna tohoto nastavení změní odkaz, proto se přihlaste k odběru znovu s novým odkazem.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -239,5 +239,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Zu Apple Kalender / Outlook hinzufügen',
|
||||
'dashboard.ics.copyManually': 'Oder Link manuell kopieren',
|
||||
'dashboard.ics.pasteFromUrl': 'in „Per URL“ einfügen',
|
||||
'dashboard.ics.dayEvents': 'Tagesübersicht als Termine',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Ein ganztägiger Termin pro Tag mit den Orten und Notizen ohne Uhrzeit. Beim Umstellen entsteht ein neuer Link, mit dem neu abonniert werden muss.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -236,5 +236,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Add to Apple Calendar / Outlook',
|
||||
'dashboard.ics.copyManually': 'Or copy a link manually',
|
||||
'dashboard.ics.pasteFromUrl': 'paste into “From URL”',
|
||||
'dashboard.ics.dayEvents': 'Day overview events',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'An all-day event per day with its places and notes that have no time. Switching this changes the link, so subscribe again with the new one.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -237,5 +237,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Añadir a Calendario de Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'O copia un enlace manualmente',
|
||||
'dashboard.ics.pasteFromUrl': 'pégalo en «Desde URL»',
|
||||
'dashboard.ics.dayEvents': 'Eventos de resumen del día',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Un evento de día completo por cada día con los lugares y notas sin hora. Cambiar esto cambia el enlace, así que vuelve a suscribirte con el nuevo.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -235,5 +235,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Lisa Apple’i kalendrisse / Outlooki',
|
||||
'dashboard.ics.copyManually': 'Või kopeeri link käsitsi',
|
||||
'dashboard.ics.pasteFromUrl': 'kleebi väljale „URL-ist“',
|
||||
'dashboard.ics.dayEvents': 'Päeva ülevaate sündmused',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Iga päeva kohta terve päeva sündmus kellaajata kohtade ja märkmetega. Selle muutmine muudab linki, seega telli uuesti uue lingiga.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -239,5 +239,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Ajouter à Calendrier Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Ou copier un lien manuellement',
|
||||
'dashboard.ics.pasteFromUrl': 'à coller dans « À partir de l’URL »',
|
||||
'dashboard.ics.dayEvents': 'Événements de résumé du jour',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Un événement sur la journée entière pour chaque jour, avec les lieux et notes sans heure. Modifier ce réglage change le lien, abonnez-vous à nouveau avec le nouveau lien.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -240,5 +240,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Προσθήκη στο Ημερολόγιο Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Ή αντιγράψτε έναν σύνδεσμο χειροκίνητα',
|
||||
'dashboard.ics.pasteFromUrl': 'επικολλήστε στο «Από URL»',
|
||||
'dashboard.ics.dayEvents': 'Συμβάντα σύνοψης ημέρας',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Ένα ολοήμερο συμβάν για κάθε ημέρα με τα μέρη και τις σημειώσεις χωρίς ώρα. Η αλλαγή αυτής της ρύθμισης αλλάζει τον σύνδεσμο, οπότε εγγραφείτε ξανά με τον νέο.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -250,6 +250,9 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'הוספה ל-Apple Calendar / Outlook',
|
||||
'dashboard.ics.copyManually': 'או העתיקו קישור ידנית',
|
||||
'dashboard.ics.pasteFromUrl': 'הדביקו ב-„From URL”',
|
||||
'dashboard.ics.dayEvents': 'אירועי סיכום יום',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'אירוע של יום שלם לכל יום עם המקומות וההערות ללא שעה. שינוי ההגדרה משנה את הקישור, לכן יש להירשם שוב עם הקישור החדש.',
|
||||
};
|
||||
|
||||
export default dashboard;
|
||||
|
||||
@@ -239,5 +239,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Hozzáadás az Apple Naptárhoz / Outlookhoz',
|
||||
'dashboard.ics.copyManually': 'Vagy másold ki kézzel a hivatkozást',
|
||||
'dashboard.ics.pasteFromUrl': 'illeszd be a „URL-ből” mezőbe',
|
||||
'dashboard.ics.dayEvents': 'Napi összefoglaló események',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Egész napos esemény minden naphoz az időpont nélküli helyekkel és jegyzetekkel. A beállítás módosítása megváltoztatja a linket, ezért iratkozz fel újra az új linkkel.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -219,5 +219,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Tambahkan ke Kalender Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Atau salin tautan secara manual',
|
||||
'dashboard.ics.pasteFromUrl': 'tempel di “Dari URL”',
|
||||
'dashboard.ics.dayEvents': 'Acara ringkasan hari',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Acara sepanjang hari untuk setiap hari berisi tempat dan catatan tanpa waktu. Mengubah ini akan mengubah tautan, jadi berlangganan lagi dengan tautan baru.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -239,5 +239,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Aggiungi a Calendario Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Oppure copia un link manualmente',
|
||||
'dashboard.ics.pasteFromUrl': 'incolla in «Da URL»',
|
||||
'dashboard.ics.dayEvents': 'Eventi di riepilogo del giorno',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Un evento di tutto il giorno per ogni giorno con i luoghi e le note senza orario. Cambiare questa opzione cambia il link, quindi iscriviti di nuovo con quello nuovo.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -217,5 +217,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Apple カレンダー / Outlook に追加',
|
||||
'dashboard.ics.copyManually': 'またはリンクを手動でコピー',
|
||||
'dashboard.ics.pasteFromUrl': '「URL から」に貼り付け',
|
||||
'dashboard.ics.dayEvents': '日ごとの概要イベント',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'時刻のない場所とメモをまとめた終日イベントを1日ごとに追加します。切り替えるとリンクが変わるため、新しいリンクで登録し直してください。',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -217,5 +217,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Apple 캘린더 / Outlook에 추가',
|
||||
'dashboard.ics.copyManually': '또는 링크를 직접 복사',
|
||||
'dashboard.ics.pasteFromUrl': '“URL에서”에 붙여넣기',
|
||||
'dashboard.ics.dayEvents': '일별 개요 일정',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'시간이 없는 장소와 메모를 담은 종일 일정을 하루마다 추가합니다. 이 설정을 바꾸면 링크가 바뀌므로 새 링크로 다시 구독하세요.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -238,5 +238,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Toevoegen aan Apple Agenda / Outlook',
|
||||
'dashboard.ics.copyManually': 'Of kopieer een link handmatig',
|
||||
'dashboard.ics.pasteFromUrl': 'plak in “Vanaf URL”',
|
||||
'dashboard.ics.dayEvents': 'Dagoverzicht als afspraken',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Een afspraak van een hele dag per dag met de plekken en notities zonder tijd. Als je dit wijzigt verandert de link, dus abonneer je opnieuw met de nieuwe link.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -273,5 +273,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Dodaj do Kalendarza Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Lub skopiuj link ręcznie',
|
||||
'dashboard.ics.pasteFromUrl': 'wklej w „Z adresu URL”',
|
||||
'dashboard.ics.dayEvents': 'Wydarzenia z podsumowaniem dnia',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Całodniowe wydarzenie na każdy dzień z miejscami i notatkami bez godziny. Zmiana tego ustawienia zmienia link, więc zasubskrybuj ponownie nowy link.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -271,5 +271,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Добавить в Календарь Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Или скопируйте ссылку вручную',
|
||||
'dashboard.ics.pasteFromUrl': 'вставьте в поле «По URL»',
|
||||
'dashboard.ics.dayEvents': 'События с обзором дня',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Событие на весь день для каждого дня с местами и заметками без времени. При изменении этой настройки меняется ссылка, поэтому подпишитесь заново по новой ссылке.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -252,5 +252,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Pridať do Kalendára Apple / Outlooku',
|
||||
'dashboard.ics.copyManually': 'Alebo skopírujte odkaz ručne',
|
||||
'dashboard.ics.pasteFromUrl': 'vložte do „Z adresy URL“',
|
||||
'dashboard.ics.dayEvents': 'Udalosti s prehľadom dňa',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Celodenná udalosť pre každý deň s miestami a poznámkami bez času. Zmena tohto nastavenia zmení odkaz, preto sa prihláste na odber znova s novým odkazom.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -235,5 +235,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Lägg till i Apple Kalender / Outlook',
|
||||
'dashboard.ics.copyManually': 'Eller kopiera en länk manuellt',
|
||||
'dashboard.ics.pasteFromUrl': 'klistra in i “Från URL”',
|
||||
'dashboard.ics.dayEvents': 'Dagsöversikt som händelser',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'En heldagshändelse per dag med platserna och anteckningarna utan tid. Om du ändrar detta ändras länken, så prenumerera igen med den nya länken.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -214,5 +214,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'เพิ่มใน Apple Calendar / Outlook',
|
||||
'dashboard.ics.copyManually': 'หรือคัดลอกลิงก์ด้วยตนเอง',
|
||||
'dashboard.ics.pasteFromUrl': 'วางใน “จาก URL”',
|
||||
'dashboard.ics.dayEvents': 'กิจกรรมสรุปรายวัน',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'กิจกรรมทั้งวันสำหรับแต่ละวัน พร้อมสถานที่และบันทึกที่ไม่มีเวลา การเปลี่ยนตัวเลือกนี้จะเปลี่ยนลิงก์ จึงต้องสมัครรับใหม่ด้วยลิงก์ใหม่',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -236,5 +236,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Apple Takvim / Outlook’a ekle',
|
||||
'dashboard.ics.copyManually': 'Veya bağlantıyı elle kopyalayın',
|
||||
'dashboard.ics.pasteFromUrl': '“URL’den” alanına yapıştırın',
|
||||
'dashboard.ics.dayEvents': 'Gün özeti etkinlikleri',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Her gün için saati olmayan yerleri ve notları içeren tüm gün süren bir etkinlik. Bunu değiştirmek bağlantıyı değiştirir, bu yüzden yeni bağlantıyla yeniden abone ol.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -273,5 +273,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Додати до Календаря Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Або скопіюйте посилання вручну',
|
||||
'dashboard.ics.pasteFromUrl': 'вставте в поле «За URL»',
|
||||
'dashboard.ics.dayEvents': 'Події з оглядом дня',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Подія на весь день для кожного дня з місцями та нотатками без часу. Зміна цього налаштування змінює посилання, тож підпишіться знову за новим посиланням.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -219,5 +219,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': 'Thêm vào Lịch Apple / Outlook',
|
||||
'dashboard.ics.copyManually': 'Hoặc sao chép liên kết thủ công',
|
||||
'dashboard.ics.pasteFromUrl': 'dán vào “Từ URL”',
|
||||
'dashboard.ics.dayEvents': 'Sự kiện tóm tắt ngày',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'Một sự kiện cả ngày cho mỗi ngày với các địa điểm và ghi chú không có giờ. Thay đổi tùy chọn này sẽ đổi liên kết, vì vậy hãy đăng ký lại bằng liên kết mới.',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -212,5 +212,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': '加入 Apple 日曆 / Outlook',
|
||||
'dashboard.ics.copyManually': '或手動複製連結',
|
||||
'dashboard.ics.pasteFromUrl': '貼到「從 URL」',
|
||||
'dashboard.ics.dayEvents': '每日概覽事件',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'為每一天新增一個全天事件,列出沒有時間的地點和備註。變更此項會改變連結,請用新連結重新訂閱。',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -212,5 +212,8 @@ const dashboard: TranslationStrings = {
|
||||
'dashboard.ics.addApple': '添加到 Apple 日历 / Outlook',
|
||||
'dashboard.ics.copyManually': '或手动复制链接',
|
||||
'dashboard.ics.pasteFromUrl': '粘贴到“通过 URL”',
|
||||
'dashboard.ics.dayEvents': '每日概览事件',
|
||||
'dashboard.ics.dayEventsHint':
|
||||
'为每一天添加一个全天事件,列出没有时间的地点和备注。更改此项会改变链接,请用新链接重新订阅。',
|
||||
};
|
||||
export default dashboard;
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
tripUpdateRequestSchema,
|
||||
tripAddMemberRequestSchema,
|
||||
activeTripResponseSchema,
|
||||
tripCalendarQuerySchema,
|
||||
tripSchema,
|
||||
} from './trip.schema';
|
||||
|
||||
@@ -96,3 +97,21 @@ describe('activeTripResponseSchema', () => {
|
||||
expect(activeTripResponseSchema.safeParse({ trip: { title: 'Japan' } }).success).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tripCalendarQuerySchema', () => {
|
||||
it('takes days=0 or days=1, or nothing (#2602)', () => {
|
||||
expect(tripCalendarQuerySchema.parse({})).toEqual({});
|
||||
expect(tripCalendarQuerySchema.parse({ days: '0' })).toEqual({ days: '0' });
|
||||
expect(tripCalendarQuerySchema.parse({ days: '1' })).toEqual({ days: '1' });
|
||||
});
|
||||
|
||||
it('refuses any other days value', () => {
|
||||
for (const days of ['false', '2', '', 0]) {
|
||||
expect(tripCalendarQuerySchema.safeParse({ days }).success).toBe(false);
|
||||
}
|
||||
});
|
||||
|
||||
it('drops keys a calendar app adds of its own', () => {
|
||||
expect(tripCalendarQuerySchema.parse({ days: '0', client: 'ios' })).toEqual({ days: '0' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -193,3 +193,16 @@ export const tripSearchResponseSchema = z.object({
|
||||
),
|
||||
});
|
||||
export type TripSearchResponse = z.infer<typeof tripSearchResponseSchema>;
|
||||
|
||||
/**
|
||||
* Query of the trip calendars: the one-time download (GET
|
||||
* /api/trips/:id/export.ics) and both subscribable feeds (GET
|
||||
* /api/feed/{trip,user}/:token.ics). `days=0` leaves out the all-day summary
|
||||
* each day with untimed stops or notes gets (#2602); `days=1` or no value keeps
|
||||
* it. Other keys are dropped rather than refused, so a calendar app that adds
|
||||
* its own still gets the feed.
|
||||
*/
|
||||
export const tripCalendarQuerySchema = z.object({
|
||||
days: z.enum(['0', '1']).optional(),
|
||||
});
|
||||
export type TripCalendarQuery = z.infer<typeof tripCalendarQuerySchema>;
|
||||
|
||||
@@ -39,6 +39,8 @@ The all-trips feed merges every trip that qualifies into one calendar, sorted by
|
||||
- **Add to Apple Calendar / Outlook** is a `webcal://` link that your system passes to its default calendar app.
|
||||
- **Or copy a link manually** unfolds both addresses with a copy button each: the `https://` one for a *From URL* field, and the `webcal://` one.
|
||||
|
||||
Above the buttons sits the **Day overview events** switch. It is on by default. Switched off, the links end in `?days=0`, and a calendar subscribed to such a link gets the trip, its timed stops and its bookings, but no all-day summary per day. The choice lives in the link, so a calendar you already subscribed keeps what it has: to change it, subscribe again with the new link and remove the old subscription. The one-off download takes the same parameter, `/api/trips/{id}/export.ics?days=0`.
|
||||
|
||||

|
||||
|
||||
The address is built from `APP_URL` when it is set; otherwise TREK uses the host you are browsing from. Behind a reverse proxy, set `APP_URL` so the link is one your calendar app can reach. See [Environment-Variables](Environment-Variables) and [Reverse-Proxy](Reverse-Proxy).
|
||||
@@ -64,7 +66,7 @@ The feed carries the same events as the `.ics` download:
|
||||
|
||||
- **The trip itself**: an all-day event from the trip's start to its end date, with the trip description.
|
||||
- **Timed stops**: one event per place in the day plan that has a time, titled with the place name, with its address as the location and its notes as the description. Times follow the place's own time zone. A stop with a start time but no end time lasts as long as the place's duration, when one is set; without a duration your calendar app picks its own default length. An end time you set always wins.
|
||||
- **A summary per day**: an all-day event for every day with untimed places or notes, titled with the day's title (or *Day N*), listing those places and notes.
|
||||
- **A summary per day**: an all-day event for every day with untimed places or notes, titled with the day's title (or *Day N*), listing those places and notes. Switch off **Day overview events** in the subscribe dialog to leave these out (see below).
|
||||
- **Bookings** of every type, transport included. Flights and other rides take their start and end from the departure and arrival points, each in its own time zone. A booking with no date that can be placed is left out.
|
||||
- **Connections**: a flight, train or cruise with several legs becomes one event per leg, titled *{title}: FRA → BER*, with each leg's own departure, arrival and segment reference, each in the time zone of its own stops, so the layover (or the stay in a port of call) shows as the gap between them. This needs a departure date and time on every leg; otherwise the booking stays one event.
|
||||
- **Accommodations**: an all-day event covering every night of the stay, from the arrival day to the departure day, so the hotel sits above those days rather than showing up once on the day you check in. The dates come from the trip days the stay is attached to, so reordering days moves the event with them.
|
||||
|
||||
@@ -45,7 +45,7 @@ Requires `trips:read` or `trips:write` scope.
|
||||
| `rename_trip_guest` | Rename a guest on a trip. Owner only. |
|
||||
| `delete_trip_guest` | Delete a guest and hand their share of each expense to the others in its split. Refused while the guest paid for an expense or is part of a recorded payment. Owner only. |
|
||||
| `copy_trip` | Duplicate a trip (days, places, itinerary, packing, budget, reservations). Packing items reset to unchecked. |
|
||||
| `export_trip_ics` | Export the trip itinerary and reservations as iCalendar (`.ics`) text. |
|
||||
| `export_trip_ics` | Export the trip itinerary and reservations as iCalendar (`.ics`) text. `dayEvents: false` leaves out the all-day summary per day. |
|
||||
| `get_share_link` | Get the current public share link for a trip and its permission flags. Requires `trips:share`. |
|
||||
| `create_share_link` | Create or update the public share link with configurable visibility flags, including the travel-only and without-photos options. Requires `trips:share`. |
|
||||
| `delete_share_link` | Revoke the public share link for a trip. Requires `trips:share`. |
|
||||
@@ -250,6 +250,8 @@ Requires `trips:share`, the same scope that manages public share links.
|
||||
| `rotate_all_trips_calendar_feed` | |
|
||||
| `disable_all_trips_calendar_feed` | |
|
||||
|
||||
A feed URL with `?days=0` appended leaves out the all-day summary per day; the tools hand back the plain URL and say so in their descriptions.
|
||||
|
||||
### Invite links
|
||||
|
||||
Requires `trips:share` together with `trips:write`; a client holding only `trips:share` does not see these three tools. This is the link that grants **membership**, not the read-only public view link that `create_share_link` makes.
|
||||
|
||||
Reference in New Issue
Block a user