own_comments.main
This module contains the REST api routes.
Module Contents
Functions
|
Get a thread by its path (ie, location). |
|
Get a thread by its path, given by the referer HTTP header. |
|
Get all threads for this own-comments instance. |
|
Get a thread by its thread ID. |
|
Deletes a thread and all associated comments |
|
Prevent new comments from being posted to a thread |
|
Post a new comment to a specific thread |
|
Post a new comment using form data. |
|
Get a specific comment by its ID |
|
Mark a comment as deleted. |
|
Mark a comment as not deleted. |
|
Modify a comment. |
|
Approve a comment (admin only). |
|
Unapprove, ie moderate, a comment (admin only). |
Verify that admin HTTP basic credentials are valid |
Attributes
- own_comments.main.app
- own_comments.main.get_thread_by_path(path: str, db: sqlalchemy.orm.Session = Depends(get_db), credentials=Depends(get_basic_auth)) own_comments.schemas.Thread
Get a thread by its path (ie, location).
If the thread does not exist yet, it will be created.
- own_comments.main.get_thread_by_referer(request: fastapi.Request)
Get a thread by its path, given by the referer HTTP header.
Used to redirect to the commentable page after no-JS comment post.
- own_comments.main.get_threads(skip: int = 0, limit: int = 100, db: sqlalchemy.orm.Session = Depends(get_db))
Get all threads for this own-comments instance.
Requires admin auth via HTTP Basic auth.
- own_comments.main.get_thread(thread_id: int, db: sqlalchemy.orm.Session = Depends(get_db), credentials=Depends(get_basic_auth))
Get a thread by its thread ID.
Comment update keys are removed unless valid admin credentials are provided via HTTP Basic auth
- own_comments.main.delete_thread(thread_id: int, db: sqlalchemy.orm.Session = Depends(get_db))
Deletes a thread and all associated comments
Requires admin auth via HTTP Basic auth
- own_comments.main.lock_thread(thread_id: int, lock: bool = True, db: sqlalchemy.orm.Session = Depends(get_db))
Prevent new comments from being posted to a thread
Requires admin auth via HTTP Basic auth
- async own_comments.main.create_comment(comment_create: own_comments.schemas.CommentCreateRequest, db: sqlalchemy.orm.Session = Depends(get_db))
Post a new comment to a specific thread
Returns the comment with its update key, that should be stored on the author’s device for further update or deletion
- async own_comments.main.create_comment_form(request: fastapi.Request, author_name: str = Form(), text: str = Form(), db: sqlalchemy.orm.Session = Depends(get_db))
Post a new comment using form data.
The thread is determined by the path part of the referer HTTP header value. Redirects to the commentable page in case of success.
- async own_comments.main.get_comment(comment_id: int, db: sqlalchemy.orm.Session = Depends(get_db), credentials: Optional[fastapi.security.HTTPBasicCredentials] = Depends(get_basic_auth))
Get a specific comment by its ID
The update key is stripped unless admin is authenticated via HTTP Basic auth
- async own_comments.main.delete_comment(comment_id: int, purge: bool = False, comment_delete: Optional[own_comments.schemas.CommentDelete] = None, db: sqlalchemy.orm.Session = Depends(get_db), credentials: Optional[fastapi.security.HTTPBasicCredentials] = Depends(get_basic_auth))
Mark a comment as deleted.
Requires either valid admin (HTTP basic) auth or an update key.
- async own_comments.main.undelete_comment(comment_id: int, comment_delete: Optional[own_comments.schemas.CommentDelete] = None, db: sqlalchemy.orm.Session = Depends(get_db), credentials: Optional[fastapi.security.HTTPBasicCredentials] = Depends(get_basic_auth))
Mark a comment as not deleted.
Requires either valid admin (HTTP basic) auth or an update key.
- async own_comments.main.patch_comment(comment_id: int, comment_patch: own_comments.schemas.CommentPatch, db: sqlalchemy.orm.Session = Depends(get_db), credentials: Optional[fastapi.security.HTTPBasicCredentials] = Depends(get_basic_auth))
Modify a comment.
Requires either valid admin (HTTP basic) auth or an update key.
- async own_comments.main.approve_comment(comment_id: int, db: sqlalchemy.orm.Session = Depends(get_db))
Approve a comment (admin only).
- async own_comments.main.unapprove_comment(comment_id: int, db: sqlalchemy.orm.Session = Depends(get_db))
Unapprove, ie moderate, a comment (admin only).
- own_comments.main.check_auth()
Verify that admin HTTP basic credentials are valid