comparison src/pages/common/blog/page_meta.py @ 939:1375b96f4309

pages (common/blog): check posted data type for comments
author Goffi <goffi@goffi.org>
date Thu, 27 Apr 2017 01:15:54 +0200
parents e4c13a995e0b
children 92f0eeb6dc72
comparison
equal deleted inserted replaced
938:9be057e23ce6 939:1375b96f4309
101 @defer.inlineCallbacks 101 @defer.inlineCallbacks
102 def on_data_post(self, request): 102 def on_data_post(self, request):
103 profile = self.getProfile(request) 103 profile = self.getProfile(request)
104 if profile is None: 104 if profile is None:
105 self.pageError(request, C.HTTP_UNAUTHORIZED) 105 self.pageError(request, C.HTTP_UNAUTHORIZED)
106 service, node, body = self.getPostedData(request, (u'service', u'node', u'body')) 106 type_ = self.getPostedData(request, u'type')
107 if not body: 107 if type_ == u'comment':
108 self.pageError(request, C.HTTP_BAD_REQUEST) 108 service, node, body = self.getPostedData(request, (u'service', u'node', u'body'))
109 comment_data = {u"content": body} 109
110 try: 110 if not body:
111 yield self.host.bridge.mbSend(service, node, comment_data, profile) 111 self.pageError(request, C.HTTP_BAD_REQUEST)
112 except Exception as e: 112 comment_data = {u"content": body}
113 if u"forbidden" in unicode(e): 113 try:
114 self.pageError(request, 401) 114 yield self.host.bridge.mbSend(service, node, comment_data, profile)
115 else: 115 except Exception as e:
116 raise e 116 if u"forbidden" in unicode(e):
117 self.pageError(request, 401)
118 else:
119 raise e
120 else:
121 log.warning(_(u"Unhandled data type: {}").format(type_))