feat: add personal ics feeds for assigned tasks

This commit is contained in:
2026-04-13 11:34:14 +02:00
parent 96b979a878
commit 07ab0461e9
8 changed files with 129 additions and 2 deletions

View File

@@ -3,9 +3,11 @@ from __future__ import annotations
from functools import lru_cache
from pathlib import Path
from flask import Blueprint, current_app, redirect, send_from_directory, url_for
from flask import Blueprint, Response, current_app, redirect, send_from_directory, url_for
from flask_login import current_user
from ..models import User
from ..services.calendar_feeds import build_calendar_feed
bp = Blueprint("main", __name__)
@@ -39,6 +41,16 @@ def uploads(filename: str):
return send_from_directory(current_app.config["UPLOAD_FOLDER"], filename)
@bp.route("/calendar-feed/<token>.ics")
def calendar_feed(token: str):
user = User.query.filter_by(calendar_feed_token=token).first_or_404()
body = build_calendar_feed(user, url_for("tasks.my_tasks", _external=True))
response = Response(body, content_type="text/calendar; charset=utf-8")
response.headers["Content-Disposition"] = 'inline; filename="putzliga.ics"'
response.headers["Cache-Control"] = "private, max-age=300"
return response
@lru_cache(maxsize=64)
def load_icon_svg(name: str, static_folder: str) -> str:
path = Path(static_folder) / "icons" / f"{name}.svg"