Skip to content

Commit d1cc155

Browse files
authored
Merge pull request #131 from matsumatsu20/feature/return-comment-id
Return comment_id when comment created
2 parents 05a0ba0 + 9ef7dc2 commit d1cc155

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

api-template.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,11 @@ Resources:
713713
responses:
714714
'200':
715715
description: 'コメント登録の完了'
716+
schema:
717+
type: object
718+
properties:
719+
comment_id:
720+
type: 'string'
716721
security:
717722
- cognitoUserPool: []
718723
x-amazon-apigateway-integration:

src/handlers/me/articles/comments/create/me_articles_comments_create.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# -*- coding: utf-8 -*-
2+
import json
23
import logging
34
import os
45
import traceback
@@ -66,7 +67,10 @@ def exec_main_proc(self):
6667
logging.fatal(err)
6768
traceback.print_exc()
6869
finally:
69-
return {'statusCode': 200}
70+
return {
71+
'statusCode': 200,
72+
'body': json.dumps({'comment_id': comment_id})
73+
}
7074

7175
def __create_comment_notification(self, article_info, comment_id, user_id):
7276
notification_table = self.dynamodb.Table(os.environ['NOTIFICATION_TABLE_NAME'])

tests/handlers/me/articles/comments/create/test_me_articles_comments_create.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def test_main_ok(self):
101101
unread_manager = self.unread_notification_manager_table.get_item(Key={'user_id': 'article_user01'}).get('Item')
102102

103103
self.assertEqual(response['statusCode'], 200)
104+
self.assertEqual(json.loads(response['body'])['comment_id'], 'HOGEHOGEHOGE')
104105
self.assertEqual(len(comment_after) - len(comment_before), 1)
105106
self.assertEqual(len(notification_after) - len(notification_before), 1)
106107
self.assertEqual(len(unread_notification_manager_after) - len(unread_notification_manager_before), 1)

0 commit comments

Comments
 (0)