Allow Hermes callback endpoint to accept revision prompts
/api/prompt/<rid> previously rejected any request not in 'pending' status. This blocked the revision workflow from using the callback. Now the endpoint accepts 'pending' (sets status to 'prompt_ready') and 'revisions_requested' (keeps status as 'revisions_requested' so the operator still sees it needs new song uploads).
This commit is contained in:
parent
51f7ffd5ab
commit
7ab8388741
2 changed files with 9 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,4 +1,5 @@
|
||||||
.env
|
.env
|
||||||
|
.env.local
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
.venv/
|
.venv/
|
||||||
|
|
|
||||||
12
app.py
12
app.py
|
|
@ -549,8 +549,9 @@ def api_update_prompt(rid):
|
||||||
req = get_request_by_id(rid)
|
req = get_request_by_id(rid)
|
||||||
if not req:
|
if not req:
|
||||||
abort(404)
|
abort(404)
|
||||||
if req['status'] != 'pending':
|
# Allow updates when the request is pending or when a revision has been requested.
|
||||||
abort(409, description='Request is no longer pending')
|
if req['status'] not in ('pending', 'revisions_requested'):
|
||||||
|
abort(409, description='Request is no longer pending or awaiting revision')
|
||||||
|
|
||||||
data = request.get_json(silent=True) or {}
|
data = request.get_json(silent=True) or {}
|
||||||
|
|
||||||
|
|
@ -559,14 +560,17 @@ def api_update_prompt(rid):
|
||||||
if provided_email and provided_email != req['email'].lower():
|
if provided_email and provided_email != req['email'].lower():
|
||||||
abort(400, description='Email mismatch')
|
abort(400, description='Email mismatch')
|
||||||
|
|
||||||
|
# When this is a revision, keep the revision note and status as revisions_requested
|
||||||
|
# so the operator still sees it as "needs new songs", and preserve customer_approved.
|
||||||
|
new_status = 'revisions_requested' if req['status'] == 'revisions_requested' else 'prompt_ready'
|
||||||
update_request(rid,
|
update_request(rid,
|
||||||
suno_title=data.get('suno_title', '').strip(),
|
suno_title=data.get('suno_title', '').strip(),
|
||||||
suno_style=data.get('suno_style', '').strip(),
|
suno_style=data.get('suno_style', '').strip(),
|
||||||
suno_lyrics=data.get('suno_lyrics', '').strip(),
|
suno_lyrics=data.get('suno_lyrics', '').strip(),
|
||||||
status='prompt_ready'
|
status=new_status
|
||||||
)
|
)
|
||||||
|
|
||||||
return jsonify({'ok': True, 'request_id': rid, 'status': 'prompt_ready'}), 200
|
return jsonify({'ok': True, 'request_id': rid, 'status': new_status}), 200
|
||||||
|
|
||||||
|
|
||||||
@app.route('/thanks/<int:rid>')
|
@app.route('/thanks/<int:rid>')
|
||||||
|
|
|
||||||
Reference in a new issue