Skip to content

Commit b7421d4

Browse files
committed
views: comments: Document title parameter and improve error handling for /new API
- Update API documentation to include optional title parameter for new comments. - Change error handling: when creating the first comment for a new thread, return a BadRequest if the URI is inaccessible and no title is provided, prompting the user to supply a title. Fixes #1055
1 parent 14de6b1 commit b7421d4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

isso/views/comments.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ def verify(cls, comment):
293293
The comment’s author’s website’s url. Must be Django-conform, i.e. either `http(s)://example.com/foo` or `example.com/`
294294
@apiBody {Number} [parent]
295295
The parent comment’s id if the new comment is a response to an existing comment.
296+
@apiBody {String} [title]
297+
The title of the thread. Required when creating the first comment for a new thread if the title cannot be automatically fetched from the URI.
296298
297299
@apiExample {curl} Create a reply to comment with id 15:
298300
curl 'https://comments.example.com/new?uri=/thread/' -d '{"text": "Stop saying that! *isso*!", "author": "Max Rant", "email": "rant@example.com", "parent": 15}' -H 'Content-Type: application/json' -c cookie.txt
@@ -350,7 +352,7 @@ def new(self, environ, request, uri):
350352
if resp and resp.status == 200:
351353
uri, title = parse.thread(resp.read(), id=uri)
352354
else:
353-
return NotFound(f'URI {uri} does not exist')
355+
return BadRequest(f'Cannot create new thread: URI {uri} is not accessible and no title was provided. Please provide a title parameter in your request.')
354356
else:
355357
title = data['title']
356358

0 commit comments

Comments
 (0)