Browse Source

Reply-to Mail : Correct support for all Content

Guénaël Muller 7 years ago
parent
commit
ee5adff536
1 changed files with 12 additions and 4 deletions
  1. 12 4
      tracim/tracim/controllers/events.py

+ 12 - 4
tracim/tracim/controllers/events.py View File

14
     def post(self):
14
     def post(self):
15
         json = request.json_body
15
         json = request.json_body
16
         if 'token' in json and json['token'] == VALID_TOKEN_VALUE:
16
         if 'token' in json and json['token'] == VALID_TOKEN_VALUE:
17
-            ## TODO check json content
17
+            # TODO check json content
18
             uapi = UserApi(None)
18
             uapi = UserApi(None)
19
-            ## TODO support Empty result error
19
+            # TODO support Empty result error
20
             user = uapi.get_one_by_email(json['user_mail'])
20
             user = uapi.get_one_by_email(json['user_mail'])
21
             api = ContentApi(user)
21
             api = ContentApi(user)
22
 
22
 
23
             thread = api.get_one(json['content_id'],content_type=ContentType.Any)
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
         else:
34
         else:
27
             return {'status': 'error',
35
             return {'status': 'error',
28
                     'error': 'invalid token'}
36
                     'error': 'invalid token'}