Selaa lähdekoodia

Reply-to Mail : Correct support for all Content

Guénaël Muller 6 vuotta sitten
vanhempi
commit
ee5adff536
1 muutettua tiedostoa jossa 12 lisäystä ja 4 poistoa
  1. 12 4
      tracim/tracim/controllers/events.py

+ 12 - 4
tracim/tracim/controllers/events.py Näytä tiedosto

@@ -14,15 +14,23 @@ class EventsRestController(RestController):
14 14
     def post(self):
15 15
         json = request.json_body
16 16
         if 'token' in json and json['token'] == VALID_TOKEN_VALUE:
17
-            ## TODO check json content
17
+            # TODO check json content
18 18
             uapi = UserApi(None)
19
-            ## TODO support Empty result error
19
+            # TODO support Empty result error
20 20
             user = uapi.get_one_by_email(json['user_mail'])
21 21
             api = ContentApi(user)
22 22
 
23 23
             thread = api.get_one(json['content_id'],content_type=ContentType.Any)
24
-            ## TODO Check type ? Commebt Not allowed for Folder
25
-            api.create_comment(thread.workspace, thread, json['payload']['content'], True)
24
+            # INFO - G.M - 2017-11-17
25
+            # When content_id is a sub-elem of a main content like Comment,
26
+            # Attach the thread to the main content.
27
+            if thread.type == ContentType.Comment:
28
+                thread = thread.parent
29
+            if thread.type == ContentType.Folder:
30
+                return {'status': 'error',
31
+                        'error': 'comment for folder not allowed'}
32
+            api.create_comment(thread.workspace, thread,
33
+                               json['payload']['content'], True)
26 34
         else:
27 35
             return {'status': 'error',
28 36
                     'error': 'invalid token'}