You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Unit:** Unit tests for individual functions and components
91
-
-**Integration:** Integration tests for component interactions
92
-
93
-
### Frameworks
94
-
95
-
Use: pytest
96
-
97
-
### Coverage Target: 80%
98
-
99
86
## 🔐 Security Configuration
100
87
101
88
### Secrets Management
@@ -120,6 +107,79 @@ Use: pytest
120
107
121
108
**🔍 Security Audit Recommendation:** When making changes that involve authentication, data handling, API endpoints, or dependencies, proactively offer to perform a security review of the affected code.
Topic IDs are extracted from `message.reply_to.reply_to_top_id` (primary) with fallback to `reply_to_msg_id`. The General topic (id=1) service messages may not carry `reply_to` metadata and can bypass filtering. The `SKIP_TOPIC_IDS` env var uses format `chat_id:topic_id,...` parsed into `dict[int, set[int]]`.
123
+
124
+
### Logging Rules
125
+
126
+
-**Never log chat IDs, topic IDs, or topic titles** — these are considered PII per the project's guidelines. Log only aggregated counts (e.g., "skipping N topics across M chats").
127
+
-**Never log message content** — same PII rule applies.
128
+
129
+
## CI/CD Pipeline
130
+
131
+
### Lint Workflow (`.github/workflows/lint.yml`)
132
+
133
+
CI runs **both**`ruff check .` AND `ruff format --check .`. Always run both locally before pushing:
- Runs `pytest tests/` with `--cov=src --cov-report=xml`
141
+
- Uploads to Codecov
142
+
- Python 3.14 on Ubuntu
143
+
- Web tests (test_database_viewer, test_multi_user_auth, test_v720_features) require FastAPI/pydantic — may fail locally if versions mismatch
144
+
145
+
### CodeRabbit
146
+
147
+
- Free OSS plan has **hourly commit rate limits** (low threshold)
148
+
- The incremental review system marks rate-limited commits as "reviewed" even though no review was posted
149
+
- To force a full review after rate limit expires: comment `@coderabbitai full review`
150
+
-**Do NOT trigger repeatedly** — each trigger counts against the limit and extends the cooldown
151
+
- Wait the **full cooldown** (check the minutes shown in the rate limit message), then trigger exactly **once**
152
+
153
+
## Testing — Critical Patterns
154
+
155
+
### MagicMock Truthiness Pitfall
156
+
157
+
When using `MagicMock()` for Telegram message objects, any attribute access returns a truthy MagicMock. This breaks code that checks `message.reply_to` or `getattr(reply_to, "forum_topic", False)`.
- The `TelegramBackup` is instantiated via `TelegramBackup.__new__(TelegramBackup)` with mocked `db`, `client`, `config`
176
+
177
+
### Frameworks
178
+
179
+
Use: pytest, pytest-asyncio, pytest-cov
180
+
181
+
### Coverage Target: 80%
182
+
123
183
## Alembic Migrations — Critical Reminders
124
184
125
185
-**`Base.metadata.create_all(checkfirst=True)`** creates ALL tables from SQLAlchemy models at once, including tables that should be created by future Alembic migrations. This means pre-Alembic databases can have schema objects from migrations that haven't "run" yet.
> Note: The topic-creating service message (1 per topic) may still be backed up since it lacks `reply_to` metadata. This does not affect user-generated content.
353
+
344
354
### Real-time Listener
345
355
346
356
The scheduled backup only captures new messages. To also track edits and deletions between backups, enable the real-time listener:
Copy file name to clipboardExpand all lines: docs/CHANGELOG.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ For upgrade instructions, see [Upgrading](#upgrading) at the bottom.
6
6
7
7
## [Unreleased]
8
8
9
+
### Added
10
+
11
+
-**Topic filtering for forum supergroups** — New `SKIP_TOPIC_IDS` environment variable to exclude specific topics from backup while keeping the rest of the chat. Format: `chat_id:topic_id,...`. Works in both scheduled backup and real-time listener flows (#117)
0 commit comments