mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 04:53:01 +00:00
save track logs to logged in user
+ rewrite migration collection + prevent logging invalid track logs + add jsoni
This commit is contained in:
+3
-1
@@ -68,7 +68,9 @@ def create_api():
|
||||
app.config["JWT_TOKEN_LOCATION"] = ["cookies"]
|
||||
app.config["JWT_COOKIE_CSRF_PROTECT"] = False
|
||||
app.config["JWT_SESSION_COOKIE"] = False
|
||||
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = int(datetime.timedelta(days=30).total_seconds())
|
||||
|
||||
jwt_expiry = int(datetime.timedelta(days=30).total_seconds())
|
||||
app.config["JWT_ACCESS_TOKEN_EXPIRES"] = jwt_expiry
|
||||
|
||||
# CORS
|
||||
CORS(app, origins="*", supports_credentials=True)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from flask_jwt_extended import current_user
|
||||
from flask_openapi3 import Tag
|
||||
from flask_openapi3 import APIBlueprint
|
||||
from pydantic import Field
|
||||
@@ -31,8 +32,15 @@ def log_track(body: LogTrackBody):
|
||||
duration = body.duration
|
||||
source = body.source
|
||||
|
||||
if not timestamp or duration < 5:
|
||||
return {"msg": "Invalid entry."}, 400
|
||||
|
||||
last_row = db.insert_track(
|
||||
trackhash=trackhash, timestamp=timestamp, duration=duration, source=source
|
||||
trackhash=trackhash,
|
||||
timestamp=timestamp,
|
||||
duration=duration,
|
||||
source=source,
|
||||
userid=current_user["id"],
|
||||
)
|
||||
|
||||
return {"last_row": last_row}
|
||||
return {"total entries": last_row}
|
||||
|
||||
Reference in New Issue
Block a user