Skip to content

Commit 0a9449c

Browse files
committed
0.2.9 - added /:appid/:userid/archived_conversations/:conversWith endpoint
1 parent d3d696e commit 0a9449c

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
## v0.2.9
3+
- added /:appid/:userid/archived_conversations/:conversWith endpoint
4+
25
## v0.2.8
36
- chat21Api.joinGroupMessages(): forced message.status = 150 in history messages after a join
47

chatdb/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ class ChatDB {
146146
});
147147
}
148148

149-
conversationDetail(appid, userid, conversWith, callback) {
149+
conversationDetail(appid, userid, conversWith, archived, callback) {
150150
winston.info("DB. app: "+ appid+ " user: " + userid + " conversWith: "+ conversWith);
151-
this.db.collection(this.conversations_collection).find( { timelineOf: userid, app_id: appid, conversWith: conversWith } ).limit(1).toArray(function(err, docs) {
151+
this.db.collection(this.conversations_collection).find( { timelineOf: userid, app_id: appid, conversWith: conversWith, archived: archived } ).limit(1).toArray(function(err, docs) {
152152
if (err) {
153153
if (callback) {
154154
callback(err, null)

index.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ app.get(BASEURL + "/:appid/:userid/conversations/:conversWith", (req, res) => {
172172
if (!authorize(req, res)) {
173173
return
174174
}
175-
conversationDetail(req, function(err, docs) {
175+
conversationDetail(req, false, function(err, docs) {
176176
if (err) {
177177
const reply = {
178178
success: false,
@@ -190,12 +190,35 @@ app.get(BASEURL + "/:appid/:userid/conversations/:conversWith", (req, res) => {
190190
})
191191
})
192192

193-
function conversationDetail(req, callback) {
193+
app.get(BASEURL + "/:appid/:userid/archived_conversations/:conversWith", (req, res) => {
194+
logger.debug("HTTP: GET /:appid/:userid/conversations/:conversWith");
195+
if (!authorize(req, res)) {
196+
return
197+
}
198+
conversationDetail(req, true, function(err, docs) {
199+
if (err) {
200+
const reply = {
201+
success: false,
202+
err: err.message()
203+
}
204+
res.status(501).send(reply)
205+
}
206+
else {
207+
const reply = {
208+
success: true,
209+
result: docs
210+
}
211+
res.status(200).json(reply)
212+
}
213+
})
214+
})
215+
216+
function conversationDetail(req, archived, callback) {
194217
// logger.debug("getting /:appid/:userid/archived_conversations")
195218
const appid = req.params.appid
196219
const userid = req.params.userid
197220
const conversWith = req.params.conversWith
198-
chatdb.conversationDetail(appid, userid, conversWith, function(err, docs) {
221+
chatdb.conversationDetail(appid, userid, conversWith, archived, function(err, docs) {
199222
callback(err, docs);
200223
});
201224
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chat21/chat21-http-server",
3-
"version": "0.2.8",
3+
"version": "0.2.9",
44
"description": "Chat21 HTTP APIs",
55
"main": "index.js",
66
"dependencies": {

0 commit comments

Comments
 (0)