From ded4927ae40ceb49ef9b994737d796da43487fcd Mon Sep 17 00:00:00 2001 From: Joshua Gleitze Date: Fri, 3 Jun 2016 14:08:57 +0200 Subject: [PATCH] apidoc for moderate --- isso/views/comments.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/isso/views/comments.py b/isso/views/comments.py index 5f2bac7..2ad90e2 100644 --- a/isso/views/comments.py +++ b/isso/views/comments.py @@ -463,6 +463,40 @@ class API(object): resp.headers.add("X-Set-Cookie", cookie("isso-%i" % id)) return resp + """ + @api {post} /id/:id/:action/key moderate + @apiGroup Comment + @apiDescription + Publish or delete a comment that is in the moderation queue (mode `2`). In order to use this endpoint, the requestor needs a `key` that is usually obtained from an email sent out by isso. + + This endpoint can also be used with a `GET` request. In that case, a html page is returned that asks the user whether they are sure to perform the selected action. If they select “yes”, the query is repeated using `POST`. + + @apiParam {number} id + The id of the comment to moderate. + @apiParam {string=activate,delete} action + `activate` to publish the comment (change its mode to `1`). + `delete` to delete the comment + @apiParam {string} key + The moderation key to authenticate the moderation. + + @apiExample {curl} delete comment with id 13: + curl -X POST 'https://comments.example.com/id/13/delete/MTM.CjL6Fg.REIdVXa-whJS_x8ojQL4RrXnuF4' + + @apiSuccessExample {html} Using GET: + <!DOCTYPE html> + <html> + <head> + <script> + if (confirm('Delete: Are you sure?')) { + xhr = new XMLHttpRequest; + xhr.open('POST', window.location.href); + xhr.send(null); + } + </script> + + @apiSuccessExample Using POST: + Yo + """ def moderate(self, environ, request, id, action, key): try: