def comment_toggle_dislike(self, request): user = endpoints.get_current_user() comment = Comment.get_Comment(request.value) if not (user and comment): return API.BooleanMessage(value=False) comment.toggle_dislike(user.email()) return API.BooleanMessage(value=True)
def comment_delete(self, request): user = endpoints.get_current_user() comment = Comment.get_Comment(request.value) if not (user and comment and user.email() == comment.author_email): return API.BooleanMessage(value=False) comment.delete() return API.BooleanMessage(value=True)
def comment_get_replies(self, request): comment = Comment.get_Comment(request.value) if not comment: return comment_reply_api.MultiCommentReplyResponse(comment_replies=[]) replies = [comment_reply_api.createCommentReplyMessage(reply) for reply in comment.get_replies()] return comment_reply_api.MultiCommentReplyResponse(comment_replies=replies)
def comment_get(self, request): comment = Comment.get_Comment(request.value) if not comment: return CommentResponse() return CommentResponse(comment=createCommentMessage(comment))
def comment_reply(self, request): user = endpoints.get_current_user() comment = Comment.get_Comment(request.id) if not (user and comment): return API.IntegerMessage(value=-1) return API.IntegerMessage(value=comment.reply(user.email(), request.content))