|
@@ -7,8 +7,8 @@ from tracim.lib.content import ContentApi
|
7
|
7
|
from tracim.lib.user import UserApi
|
8
|
8
|
from tracim.model.data import ContentType
|
9
|
9
|
|
10
|
|
-class EventsRestController(RestController):
|
11
|
10
|
|
|
11
|
+class EventsRestController(RestController):
|
12
|
12
|
|
13
|
13
|
@tg.expose('json')
|
14
|
14
|
def post(self):
|
|
@@ -20,22 +20,22 @@ class EventsRestController(RestController):
|
20
|
20
|
if 'token' in json and json['token'] == cfg.EMAIL_REPLY_TOKEN:
|
21
|
21
|
if 'user_mail' not in json or 'content_id' not in json:
|
22
|
22
|
return {'status': 'error',
|
23
|
|
- 'error': 'bad json',}
|
|
23
|
+ 'error': 'bad json', }
|
24
|
24
|
uapi = UserApi(None)
|
25
|
25
|
# TODO support Empty result error
|
26
|
26
|
try:
|
27
|
27
|
user = uapi.get_one_by_email(json['user_mail'])
|
28
|
|
- except NoResultFound :
|
|
28
|
+ except NoResultFound:
|
29
|
29
|
return {'status': 'error',
|
30
|
|
- 'error': 'bad user mail',}
|
|
30
|
+ 'error': 'bad user mail', }
|
31
|
31
|
api = ContentApi(user)
|
32
|
32
|
|
33
|
33
|
try:
|
34
|
34
|
thread = api.get_one(json['content_id'],
|
35
|
35
|
content_type=ContentType.Any)
|
36
|
|
- except NoResultFound :
|
|
36
|
+ except NoResultFound:
|
37
|
37
|
return {'status': 'error',
|
38
|
|
- 'error': 'bad content id',}
|
|
38
|
+ 'error': 'bad content id', }
|
39
|
39
|
# INFO - G.M - 2017-11-17
|
40
|
40
|
# When content_id is a sub-elem of a main content like Comment,
|
41
|
41
|
# Attach the thread to the main content.
|
|
@@ -43,10 +43,10 @@ class EventsRestController(RestController):
|
43
|
43
|
thread = thread.parent
|
44
|
44
|
if thread.type == ContentType.Folder:
|
45
|
45
|
return {'status': 'error',
|
46
|
|
- 'error': 'comment for folder not allowed',}
|
|
46
|
+ 'error': 'comment for folder not allowed', }
|
47
|
47
|
api.create_comment(thread.workspace, thread,
|
48
|
48
|
json['payload']['content'], True)
|
49
|
|
- return {'status': 'ok',}
|
|
49
|
+ return {'status': 'ok', }
|
50
|
50
|
else:
|
51
|
51
|
return {'status': 'error',
|
52
|
|
- 'error': 'invalid token',}
|
|
52
|
+ 'error': 'invalid token', }
|