@tiledesk/tiledesk-server 2.3.46 → 2.3.48

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,14 @@
1
1
 
2
2
 
3
- 💥 TILEDESK SERVER v2.3.46 💥
3
+ 💥 TILEDESK SERVER v2.3.47 💥
4
4
  🚀 TAGGED AND PUBLISHED ON NPM 🚀
5
5
  🚀 IN PRODUCTION 🚀
6
- (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.46)
6
+ (https://www.npmjs.com/package/@tiledesk/tiledesk-server/v/2.3.47)
7
7
 
8
- # 2.3.46 -> PROD
8
+ # 2.3.47 -> PROD
9
+ - added root message endpoint for descending
10
+
11
+ # 2.3.46
9
12
  - @tiledesk/tiledesk-tybot-connector": "^0.1.21
10
13
 
11
14
  # 2.3.45
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-server",
3
3
  "description": "The Tiledesk server module",
4
- "version": "2.3.46",
4
+ "version": "2.3.48",
5
5
  "scripts": {
6
6
  "start": "node ./bin/www",
7
7
  "pretest": "mongodb-runner start",
@@ -5,6 +5,7 @@ var router = express.Router({mergeParams: true});
5
5
 
6
6
  var MessageConstants = require("../models/messageConstants");
7
7
  var Message = require("../models/message");
8
+ var Request = require("../models/request");
8
9
  var messageService = require("../services/messageService");
9
10
  var winston = require('../config/winston');
10
11
  var fastCsv = require("fast-csv");
@@ -65,6 +66,44 @@ router.post('/',
65
66
 
66
67
 
67
68
 
69
+ router.get('/',roleChecker.hasRoleOrTypes('owner'), function(req, res) {
70
+
71
+ const DEFAULT_LIMIT = 10;
72
+
73
+ var limit = DEFAULT_LIMIT; // Number of rows per page
74
+
75
+ // console.log("req.query.populate_request",req.query.populate_request);
76
+ if (req.query.limit) {
77
+ limit = parseInt(req.query.limit);
78
+ }
79
+ if (limit > 50) {
80
+ limit = DEFAULT_LIMIT;
81
+ }
82
+
83
+
84
+ var page = 0;
85
+
86
+ if (req.query.page) {
87
+ page = req.query.page;
88
+ }
89
+
90
+ var skip = page * limit;
91
+
92
+ return Message.find({id_project: req.projectid}).sort({createdAt: 'desc'}).
93
+ skip(skip).limit(limit).lean().exec(async (err, messages) => {
94
+ if (err) return next(err);
95
+
96
+ if (req.query.populate_request) {
97
+ // console.log("pupulate")
98
+ for (var i = 0; i < messages.length; i++) {
99
+ messages[i].request = await Request.findOne({request_id:messages[i].recipient, id_project: messages[i].id_project }).exec();
100
+ }
101
+ }
102
+
103
+ res.json(messages);
104
+ });
105
+ });
106
+
68
107
  router.get('/csv', roleChecker.hasRoleOrTypes('owner'), function(req, res) {
69
108
 
70
109