changeset 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 9be057e23ce6
children e30a4b7eff09
files src/pages/common/blog/page_meta.py
diffstat 1 files changed, 16 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/pages/common/blog/page_meta.py	Thu Apr 27 01:15:24 2017 +0200
+++ b/src/pages/common/blog/page_meta.py	Thu Apr 27 01:15:54 2017 +0200
@@ -103,14 +103,19 @@
     profile = self.getProfile(request)
     if profile is None:
         self.pageError(request, C.HTTP_UNAUTHORIZED)
-    service, node, body = self.getPostedData(request, (u'service', u'node', u'body'))
-    if not body:
-        self.pageError(request, C.HTTP_BAD_REQUEST)
-    comment_data = {u"content": body}
-    try:
-        yield self.host.bridge.mbSend(service, node, comment_data, profile)
-    except Exception as e:
-        if u"forbidden" in unicode(e):
-            self.pageError(request, 401)
-        else:
-            raise e
+    type_ = self.getPostedData(request, u'type')
+    if type_ == u'comment':
+        service, node, body = self.getPostedData(request, (u'service', u'node', u'body'))
+
+        if not body:
+            self.pageError(request, C.HTTP_BAD_REQUEST)
+        comment_data = {u"content": body}
+        try:
+            yield self.host.bridge.mbSend(service, node, comment_data, profile)
+        except Exception as e:
+            if u"forbidden" in unicode(e):
+                self.pageError(request, 401)
+            else:
+                raise e
+    else:
+        log.warning(_(u"Unhandled data type: {}").format(type_))