Send user data in /threads dat

This commit is contained in:
James Allen 2017-01-09 17:25:06 +01:00
parent 1a100b77df
commit 4e128b6ab7
3 changed files with 10 additions and 10 deletions

View file

@ -28,7 +28,7 @@ module.exports =
logger.log project_id:project_id, query:query, "getting messages"
ChatApiHandler.getGlobalMessages project_id, query.limit, query.before, (err, messages) ->
return next(err) if err?
CommentsController._injectUserInfoIntoThreads [{ messages: messages }], (err) ->
CommentsController._injectUserInfoIntoThreads {global: { messages: messages }}, (err) ->
return next(err) if err?
logger.log length: messages?.length, "sending messages to client"
res.json messages

View file

@ -62,7 +62,7 @@ module.exports = CommentsController =
callback null, user
jobs = []
for thread in threads
for thread_id, thread of threads
do (thread) ->
if thread.resolved
jobs.push (cb) ->

View file

@ -151,8 +151,8 @@ describe "CommentsController", ->
return { "formatted": user["mock"] }
it "should inject a user object into messaged and resolved data", (done) ->
@CommentsController._injectUserInfoIntoThreads [
{
@CommentsController._injectUserInfoIntoThreads {
thread1: {
resolved: true
resolved_by_user_id: "user_id_1"
messages: [{
@ -163,15 +163,15 @@ describe "CommentsController", ->
content: "bar"
}]
},
{
thread2: {
messages: [{
user_id: "user_id_1"
content: "baz"
}]
}
], (error, threads) ->
expect(threads).to.deep.equal [
{
}, (error, threads) ->
expect(threads).to.deep.equal {
thread1: {
resolved: true
resolved_by_user_id: "user_id_1"
resolved_by_user: { "formatted": "user_1" }
@ -185,14 +185,14 @@ describe "CommentsController", ->
content: "bar"
}]
},
{
thread2: {
messages: [{
user_id: "user_id_1"
user: { "formatted": "user_1" }
content: "baz"
}]
}
]
}
done()
it "should only need to look up each user once", (done) ->