fix: correct audit event names, attachment deletion, redirect safety, and add account deactivation check
- Fix audit event names in CLI prune/clear commands from `cli.seo.*` to `cli.seo_meta.*`
- Refactor `_delete_attachment_file` to accept full attachment dict instead of storage_path string, using directory and stored_name fields with ATTACHMENTS_DIR
- Add `safe_next` validation for referer header in validation error redirect and media redirect
- Add `is_active` check in login router to reject deactivated accounts with "Account is deactivated" error
- Replace raw `request.headers.get("Referer")` with `redirect_back()` utility in bookmarks, polls, reactions, and votes routers
- Move `mark_conversation_read` call from `get_conversation_messages` to `messages_page` to avoid side effects during message retrieval
- Fix poll audit link to use `option.get("label")` instead of `option.get("text")`
- Add `VOTABLE` set validation in votes router to reject invalid target types with 400 response
- Strip control characters (0x00-0x20) from URLs in `_safe_url` instead of simple strip
- Add `__getattr__` fallback in services `__init__.py` for dynamic attribute access
This commit is contained in:
@@ -158,22 +158,23 @@ def sweep(cutoff: str, batch_size: int = 5000, max_batches: int = 100) -> tuple[
|
||||
if not uids:
|
||||
break
|
||||
placeholders, params = _in_clause(uids)
|
||||
if LINKS_TABLE in db.tables:
|
||||
link_rows = list(
|
||||
with db:
|
||||
if LINKS_TABLE in db.tables:
|
||||
link_rows = list(
|
||||
db.query(
|
||||
f"SELECT COUNT(*) AS c FROM {LINKS_TABLE} "
|
||||
f"WHERE audit_uid IN ({placeholders})",
|
||||
**params,
|
||||
)
|
||||
)
|
||||
removed_links += int(link_rows[0]["c"]) if link_rows else 0
|
||||
db.query(
|
||||
f"SELECT COUNT(*) AS c FROM {LINKS_TABLE} "
|
||||
f"WHERE audit_uid IN ({placeholders})",
|
||||
f"DELETE FROM {LINKS_TABLE} WHERE audit_uid IN ({placeholders})",
|
||||
**params,
|
||||
)
|
||||
)
|
||||
removed_links += int(link_rows[0]["c"]) if link_rows else 0
|
||||
db.query(
|
||||
f"DELETE FROM {LINKS_TABLE} WHERE audit_uid IN ({placeholders})",
|
||||
**params,
|
||||
f"DELETE FROM {AUDIT_TABLE} WHERE uid IN ({placeholders})", **params
|
||||
)
|
||||
db.query(
|
||||
f"DELETE FROM {AUDIT_TABLE} WHERE uid IN ({placeholders})", **params
|
||||
)
|
||||
removed_events += len(uids)
|
||||
if len(uids) < batch_size:
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user