在 /ticket/reply 移除 reply_to

This commit is contained in:
jysperm
2014-04-26 20:18:53 +08:00
parent 77f9b978e9
commit 120dcf24f1
4 changed files with 7 additions and 30 deletions

View File

@@ -33,7 +33,6 @@ Request:
{
"id": "525284cc2cebb6d0008b4567"
"reply_to": "525284cc2cebb6d0008b4567",
"content": "Reply Content(Markdown)"
}
@@ -46,7 +45,6 @@ Response:
Exception:
* ticket_not_exist
* reply_not_exist
* forbidden
### POST /ticket/update/

View File

@@ -16,7 +16,6 @@ attribute: {
replys: [
{
_id: ObjectID('525284cc2cebb6d0008b4567')
reply_to: ObjectID('525284cc2cebb6d0008b4567')
account_id: ObjectID('525284cc2cebb6d0008b4567')
created_at: ISODate('2013-02-22T03:03:37.312Z')
content: 'Reply Content(Markdown)'

View File

@@ -99,29 +99,13 @@ module.exports =
unless ticket
return res.json 400, error: 'ticket_not_exist'
checkReplyTo = (callback) ->
if req.body.reply_to
mTicket.findOne
'replys._id': req.body.reply_to
, {}, (result) ->
if result
callback null
else
callback true
else
callback null
unless mTicket.getMember ticket, account
unless mAccount.inGroup account, 'root'
return res.json 400, error: 'forbidden'
checkReplyTo (err) ->
if err
return res.json 400, error: 'reply_not_exist'
unless mTicket.getMember ticket, account
unless mAccount.inGroup account, 'root'
return res.json 400, error: 'forbidden'
mTicket.createReply ticket, account, req.body.reply_to, req.body.content, (reply) ->
return res.json
id: reply._id
mTicket.createReply ticket, account, req.body.content, (reply) ->
return res.json
id: reply._id
update: (req, res) ->
mAccount.authenticate req.token, (account) ->

View File

@@ -28,13 +28,9 @@ exports.createTicket = (account, title, content, type, members, attribute, callb
replys: []
, {}, callback
exports.createReply = (ticket, account, reply_to, content, callback) ->
if reply_to and _.isString reply_to
reply_to = new db.ObjectID reply_to
exports.createReply = (ticket, account, content, callback) ->
data =
_id: db.ObjectID()
reply_to: reply_to ? null
account_id: account._id
created_at: new Date()
content: content