@@ -38,9 +38,11 @@ def validate_params(self):
3838 )
3939
4040 def exec_main_proc (self ):
41+ # 「いいね」情報登録処理
42+ article_user_id = self .__get_article_user_id (self .event ['pathParameters' ]['article_id' ])
4143 try :
4244 article_liked_user_table = self .dynamodb .Table (os .environ ['ARTICLE_LIKED_USER_TABLE_NAME' ])
43- self .__create_article_liked_user (article_liked_user_table )
45+ self .__create_article_liked_user (article_liked_user_table , article_user_id )
4446 except ClientError as e :
4547 if e .response ['Error' ]['Code' ] == 'ConditionalCheckFailedException' :
4648 return {
@@ -50,14 +52,16 @@ def exec_main_proc(self):
5052 else :
5153 raise
5254
53- try :
54- article_info_table = self .dynamodb .Table (os .environ ['ARTICLE_INFO_TABLE_NAME' ])
55- article_info = article_info_table .get_item (Key = {'article_id' : self .params ['article_id' ]}).get ('Item' )
56- self .__create_like_notification (article_info )
57- self .__update_unread_notification_manager (article_info )
58- except Exception as e :
59- logging .fatal (e )
60- traceback .print_exc ()
55+ # 通知情報登録処理。「セルフいいね」だった場合は通知を行わない
56+ if article_user_id != self .event ['requestContext' ]['authorizer' ]['claims' ]['cognito:username' ]:
57+ try :
58+ article_info_table = self .dynamodb .Table (os .environ ['ARTICLE_INFO_TABLE_NAME' ])
59+ article_info = article_info_table .get_item (Key = {'article_id' : self .params ['article_id' ]}).get ('Item' )
60+ self .__create_like_notification (article_info )
61+ self .__update_unread_notification_manager (article_info )
62+ except Exception as e :
63+ logging .fatal (e )
64+ traceback .print_exc ()
6165
6266 return {
6367 'statusCode' : 200
@@ -104,12 +108,12 @@ def __update_unread_notification_manager(self, article_info):
104108 ExpressionAttributeValues = {':unread' : True }
105109 )
106110
107- def __create_article_liked_user (self , article_liked_user_table ):
111+ def __create_article_liked_user (self , article_liked_user_table , article_user_id ):
108112 epoch = int (time .time ())
109113 article_liked_user = {
110114 'article_id' : self .event ['pathParameters' ]['article_id' ],
111115 'user_id' : self .event ['requestContext' ]['authorizer' ]['claims' ]['cognito:username' ],
112- 'article_user_id' : self . __get_article_user_id ( self . event [ 'pathParameters' ][ 'article_id' ]) ,
116+ 'article_user_id' : article_user_id ,
113117 'created_at' : epoch ,
114118 'target_date' : time .strftime ('%Y-%m-%d' , time .gmtime (epoch )),
115119 'sort_key' : TimeUtil .generate_sort_key ()
0 commit comments