Feature/single letters - #49
Conversation
Eight files had been committed with CRLF line endings, which made their diffs unreviewable (send_post.py showed 896 changed lines with no actual content change). Renormalized with `git add --renormalize`; this commit changes line endings only. Root cause was core.autocrlf=false locally, which commits worktree bytes verbatim. Now set to `input` globally so CRLF is normalized on commit while nothing is converted on checkout. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
jekuaitk
left a comment
There was a problem hiding this comment.
A couple suggestions and questions otherwise good!
| def check_bearer_token(credentials: HTTPAuthorizationCredentials = Depends(security_scheme)) -> dict[str, str]: | ||
| """Check the validity of an incoming bearer JWT token.""" | ||
| try: | ||
| payload = jwt.decode(credentials.credentials, config.API_JWT_SECRET, algorithms=["HS256"]) | ||
| return payload | ||
| except jwt.ExpiredSignatureError: | ||
| raise HTTPException(401, "Token expired") # pylint: disable=raise-missing-from | ||
| except jwt.InvalidTokenError: | ||
| raise HTTPException(401, "Invalid token") # pylint: disable=raise-missing-from |
There was a problem hiding this comment.
Should we also check whether the api user is active? Seems like a deactivated API-user can keep using an already issued JWT until it expires, that is worst case up to api_token_lifetime_seconds.
|
|
||
|
|
||
| @router.get("/letter/{letter_id}", tags=["Letters"]) | ||
| def get_letter(letter_id: str, get_pdf: bool = True) -> LetterDetail: |
There was a problem hiding this comment.
Seems like any API-user can fetch any letter (provided they know their id). Is this on purpose?
| for letter in letters: | ||
| document_storage.delete_single_letter_doc(letter.id) | ||
| session.delete(letter) | ||
|
|
||
| session.commit() |
There was a problem hiding this comment.
Would it make sense to re-order this such that the actual document are only deleted after committing? Perhaps even collecting the letter ids in a list and then deleting them after a single commit?
| for letter in letters: | |
| document_storage.delete_single_letter_doc(letter.id) | |
| session.delete(letter) | |
| session.commit() | |
| for letter in letters: | |
| session.delete(letter) | |
| session.commit() | |
| document_storage.delete_single_letter_doc(letter.id) |
| return tuple(result) | ||
|
|
||
|
|
||
| def get_api_user(id: str) -> ApiUser: |
There was a problem hiding this comment.
Should this not be
| def get_api_user(id: str) -> ApiUser: | |
| def get_api_user(id: str) -> ApiUser | None: |
Added
Changed