# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [2.0.2] - 2025-03-04

(No changes documented; release for version sync.)

## [2.0.0] - 2026-03-03

### Added

- **Group duty pin**: when the pinned duty message is updated on schedule, the bot re-pins it so group members get a Telegram notification. Configurable via `DUTY_PIN_NOTIFY` (default: enabled); set to `0` or `false` to pin without notification. The first pin (e.g. when the bot is added to the group or on `/pin_duty`) is always silent.
- **Command `/refresh_pin`**: in a group, immediately refresh the pinned duty message (send new message, unpin old, pin new).
- **Role-based access and `/set_role`**: Miniapp and admin access are determined by roles stored in the database (`roles` table, `users.role_id`). Roles: `user` (miniapp access), `admin` (miniapp + `/import_duty_schedule`, `/set_role`). Admins assign roles with `/set_role @username user|admin` (or reply to a message with `/set_role user|admin`). `ALLOWED_USERNAMES` and `ALLOWED_PHONES` are no longer used for access (kept for reference).
- **Command `/calendar_link`**: in private chat, send the user their personal ICS subscription URL (and team calendar URL) for calendar apps.
- **Config `MINI_APP_SHORT_NAME`**: when set, the pinned duty message "View contacts" button uses a direct Mini App link (`https://t.me/BotName/ShortName?startapp=duty`) so the app opens on the current-duty view.
- **Config `LOG_LEVEL`**: control backend logging and the Miniapp console logger (`window.__DT_LOG_LEVEL`); one of `DEBUG`, `INFO`, `WARNING`, `ERROR` (default: `INFO`).
- **Mini App**: migrated to Next.js (TypeScript, Tailwind, shadcn/ui) with static export; improved loading states, duty timeline styling, and content readiness handling; configurable loopback host for health checks.

### Changed

- **Group duty pin refresh**: schedule updates now send a new message, unpin the previous one and pin the new one (instead of editing the existing message and re-pinning). Ensures the pinned message is always a fresh post; on pin/unpin errors the stored message_id is not updated so the next run retries.

## [0.1.0] - 2025-02-20

### Added

- Telegram bot with python-telegram-bot v22 (polling, Application API).
- Commands: `/start`, `/help`, `/set_phone`, `/import_duty_schedule`, `/pin_duty`.
- Miniapp (calendar and duty list) served at `/app` with Russian and English (i18n).
- FastAPI HTTP API: `GET /api/duties`, `GET /api/calendar-events`, `GET /api/calendar/ical/{token}.ics`.
- Telegram initData validation for Miniapp; optional phone-based access (`ALLOWED_PHONES` / `ADMIN_PHONES`).
- SQLite (default) / configurable DB; SQLAlchemy models, repository, Alembic migrations.
- Duty-schedule import: two-step flow (handover time + JSON file); parser for meta.start_date and schedule[].duty.
- Group duty pin: pin current duty message in group with time/timezone from `DUTY_DISPLAY_TZ`.
- External calendar ICS URL support; personal ICS calendar by secret token.
- Configuration via environment variables; full reference in docs/configuration.md.
- Docker support (dev and prod compose); entrypoint runs migrations then app.

### Security

- Input validation and initData hash verification for Miniapp access.
- Optional CORS and init_data_max_age; use env for secrets.

[Unreleased]: https://github.com/your-org/duty-teller/compare/v2.0.2...HEAD
[2.0.2]: https://github.com/your-org/duty-teller/releases/tag/v2.0.2  <!-- placeholder: set to your repo URL when publishing -->
[2.0.0]: https://github.com/your-org/duty-teller/releases/tag/v2.0.0  <!-- placeholder: set to your repo URL when publishing -->
[0.1.0]: https://github.com/your-org/duty-teller/releases/tag/v0.1.0  <!-- placeholder: set to your repo URL when publishing -->
