Skip to content

Commit d9fadd2

Browse files
authored
Merge pull request #1058 from pkvach/fix/new-api-title-parameter
Document title parameter and improve error handling for /new API
2 parents 8deaebc + ca7b15e commit d9fadd2

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Bugfixes & Improvements
5656
- Make 'text' field in 'comments' table NOT NULL and handling data migration (`#1019`_, pkvach)
5757
- Python 3.12 support (`#1015`_, ix5)
5858
- Disable Postbox submit button on click, enable after response (`#993`_, pkvach)
59+
- Document title parameter and improve error handling for /new API (`#1058`_, pkvach)
5960

6061
.. _#951: https://github.com/posativ/isso/pull/951
6162
.. _#967: https://github.com/posativ/isso/pull/967
@@ -70,6 +71,7 @@ Bugfixes & Improvements
7071
.. _#1019: https://github.com/isso-comments/isso/pull/1019
7172
.. _#1015: https://github.com/isso-comments/isso/pull/1015
7273
.. _#993: https://github.com/isso-comments/isso/pull/993
74+
.. _#1058: https://github.com/isso-comments/isso/pull/1058
7375

7476
0.13.1.dev0 (2023-02-05)
7577
------------------------

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)