messages.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793
  1. /**
  2. * 消息控制器。
  3. *
  4. * 此控制器处理点对点,组及消息消息。为三类消息提供发送及查询功能。
  5. */
  6. var http = require('http');
  7. var qs = require('querystring');
  8. var getui = require('getui');
  9. var endpoints = require('../include/endpoints').END_POINTS;
  10. var express = require('express');
  11. var router = express.Router();
  12. var groupMsg = require("../models/msg.group");
  13. var privateMsg = require('../models/msg.p2p');
  14. var StatMsg = require("../models/msg.stat");
  15. var systemMsg = require("../models/msg.system");
  16. var user = require("../models/user");
  17. var push = require("../models/push_notify");
  18. /**
  19. * 发送P2P消息。
  20. *
  21. * from_uid=x&to_uid=xx&content=xxx&type=1
  22. *
  23. * 参数:
  24. * from_uid:发送者id
  25. * to_uid:接收者id
  26. * content:消息内容
  27. * type:消息类型:1文本,2图片,3语音
  28. */
  29. router.post(endpoints.Msg.Privates, function (req, res, next) {
  30. if (req.query.from_uid == null
  31. || req.query.to_uid == null
  32. || req.query.content == null
  33. || req.query.type == null) {
  34. res.send({errno: -1, errmsg: 'parameter error'});
  35. return;
  36. }
  37. privateMsg.isUserExist(req.query.to_uid, function (err, result) {
  38. if (err) {
  39. res.send({errno: 1, errmsg: 'get users from db error'});
  40. return;
  41. }
  42. if (result.length == 0) {
  43. res.send({errno: 2, errmsg: 'no receive users'});
  44. return;
  45. }
  46. // 保存一对一消息
  47. privateMsg.saveP2PMsg(req.query.to_uid, req.query.from_uid, req.query.type, req.query.content, function (err, result) {
  48. if (err) {
  49. res.send({errno: 3, errmsg: 'save msg to db error'});
  50. return;
  51. }
  52. res.send({errno: 0, errmsg: 'send p2p msg success'});
  53. // 更新自身的聊天统计信息
  54. StatMsg.updateP2PChatInfo(req.query.from_uid,
  55. req.query.to_uid,
  56. req.query.from_uid,
  57. req.query.type,
  58. req.query.content,
  59. function (err, result) {
  60. if (err) {
  61. console.log(err);
  62. }
  63. });
  64. // 更新对端的聊天统计信息
  65. StatMsg.updateP2PChatInfo(req.query.to_uid,
  66. req.query.from_uid,
  67. req.query.from_uid,
  68. req.query.type,
  69. req.query.content,
  70. function (err, result) {
  71. if (err) {
  72. console.log(err);
  73. }
  74. });
  75. // 推送通知消息给对端
  76. user.getUserbyID(req.query.to_uid, function (err, result) {
  77. if (err) {
  78. console.log('group msg:get users by id from db failed');
  79. return;
  80. }
  81. var title = '';
  82. var content = '';
  83. if (req.query.type == 1) {
  84. title = '新消息';
  85. content = req.query.content;
  86. } else if (req.query.type == 2) {
  87. title = '新消息';
  88. content = '接收到 [图片]';
  89. } else if (req.query.type == 3) {
  90. title = '新消息';
  91. content = '接收到 [语音]';
  92. } else {
  93. title = '新消息';
  94. content = '接收到一条新消息';
  95. }
  96. var bMustPush = 0;
  97. var data;
  98. if (result.length > 0) {
  99. data = result[0];
  100. if (data.is_online) {
  101. bMustPush = 1;
  102. }
  103. }
  104. var push_data = JSON.stringify({
  105. type: 'p2p_msg',
  106. from_uid: req.query.from_uid
  107. });
  108. // 保存通知到数据库中
  109. push.savePushNotify(req.query.to_uid,
  110. req.query.type,
  111. title,
  112. content,
  113. push_data,
  114. bMustPush,
  115. function (err, result) {
  116. if (err) {
  117. // 保存失败
  118. console.log('save msg to db failed');
  119. } else {
  120. console.log('save msg to db success');
  121. if (bMustPush == true) {
  122. if (data.platform == 0) {// iOS
  123. getui.pushAPN(req.query.to_uid,
  124. data.token,
  125. req.query.type,
  126. title,
  127. content,
  128. push_data,
  129. function (err, result) {
  130. if (err != null) {
  131. console.log(err);
  132. } else {
  133. console.log(result);
  134. }
  135. });
  136. } else {// Android
  137. getui.pushAndroid(data.client_id,
  138. req.query.type,
  139. title,
  140. content,
  141. push_data,
  142. data.status,
  143. function (err, result) {
  144. if (err != null) {
  145. console.log(err);
  146. } else {
  147. console.log(result);
  148. }
  149. });
  150. }
  151. }
  152. }
  153. });
  154. });
  155. });
  156. });
  157. });
  158. /**
  159. * 获取P2P消息。
  160. *
  161. * p2p/getmsg.im?uid=x&peer_uid=xx&start=0&count=20
  162. *
  163. * 参数:
  164. * uid:用户id
  165. * peer_uid:对端id
  166. * start;分页查询起始条目
  167. * count:查询条数
  168. * 备注:按时间倒序
  169. */
  170. router.get(endpoints.Msg.Privates, function (req, res, next) {
  171. if (req.query.uid == null
  172. || req.query.peer_uid == null
  173. || req.query.start == null
  174. || req.query.count == null) {
  175. res.send({errno: -1, errmsg: 'parameter error'});
  176. return;
  177. }
  178. privateMsg.getP2PMsg(req.query.uid, req.query.peer_uid, req.query.start, req.query.count, function (err, result) {
  179. if (err) {
  180. res.send({errno: 1, errmsg: 'get group msg from db error'});
  181. return;
  182. }
  183. var data = {};
  184. data.start = parseInt(req.query.start);
  185. data.count = result.length;
  186. data.list = new Array();
  187. for (var nIndex = 0; nIndex < result.length; nIndex++) {
  188. result[nIndex].timestamp = Date.parse(new Date(result[nIndex].timestamp));
  189. data.list.push(result[nIndex]);
  190. }
  191. res.send(data);
  192. // 清空统计信息
  193. StatMsg.clearP2PChatInfo(req.query.uid,
  194. req.query.peer_uid,
  195. function (err, result) {
  196. if (err) {
  197. console.log(err);
  198. }
  199. });
  200. });
  201. });
  202. /**
  203. * 发送群组消息。
  204. *
  205. * group/sendmsg.im?from_uid=x&to_gid=xx&content=xxx&type=1&at_uid=xxxx&group_type
  206. *
  207. * 参数:
  208. * from_uid:发送者id
  209. * to_gid:群组id
  210. * content:消息内容
  211. * type:消息类型:1文本,2图片,3语音
  212. * at_uid:@用户id:1为行政组,null或者其他值为自定义组
  213. * group_type:区分是行政组还是自定义组,从不同表中查找组成员
  214. */
  215. router.post(endpoints.Msg.Groups, function (req, res, next) {
  216. if (req.query.from_uid == null
  217. || req.query.to_gid == null
  218. || req.query.content == null
  219. || req.query.type == null) {
  220. res.send({errno: -1, errmsg: 'parameter error'});
  221. return;
  222. }
  223. groupMsg.isGroupUser(req.query.from_uid, req.query.to_gid, req.query.group_type, function (err, result) {
  224. if (err) {
  225. res.send({errno: 1, errmsg: 'get users from db error'});
  226. return;
  227. }
  228. if (result.length == 0) {
  229. res.send({errno: 2, errmsg: 'no receive users'});
  230. return;
  231. }
  232. var at_uid = '';
  233. if (req.query.at_uid != null) {
  234. at_uid = req.query.at_uid;
  235. }
  236. // 保存群组消息
  237. groupMsg.saveGroupMsg(req.query.from_uid, req.query.to_gid, at_uid, req.query.type, req.query.content, function (err, result) {
  238. if (err) {
  239. res.send({errno: 3, errmsg: 'save msg to db error'});
  240. return;
  241. }
  242. res.send({errno: 0, errmsg: 'send group msg success'});
  243. // 统计信息
  244. StatMsg.updateGroupChatInfo(req.query.from_uid,
  245. req.query.to_gid,
  246. req.query.from_uid,
  247. 0,
  248. req.query.type,
  249. req.query.content,
  250. false,
  251. function (err, result) {
  252. if (err) {
  253. console.log(err);
  254. }
  255. });
  256. // 推送通知消息给群组各成员
  257. groupMsg.getGroupUsers(req.query.to_gid, req.query.group_type, function (err, result) {
  258. if (err) {
  259. console.log('get users from db error');
  260. return;
  261. }
  262. if (result.length == 0) {
  263. console.log('no receive users');
  264. return;
  265. }
  266. // 推送通知
  267. for (var nIndex = 0; nIndex < result.length; nIndex++) {
  268. if (result[nIndex].member_code == req.query.from_uid) {
  269. continue;
  270. }
  271. (function () {
  272. var toUserID = result[nIndex].member_code;
  273. user.getUserbyID(toUserID, function (err, result) {
  274. var tmp = toUserID;
  275. if (err) {
  276. console.log('group msg:get users by id from db failed');
  277. return;
  278. }
  279. var title = '';
  280. var content = '';
  281. if (req.query.type == 1) {
  282. title = '群组消息';
  283. content = req.query.content;
  284. } else if (req.query.type == 2) {
  285. title = '群组消息';
  286. content = '接收到 [图片]';
  287. } else if (req.query.type == 3) {
  288. title = '群组消息';
  289. content = '接收到 [语音]';
  290. } else {
  291. title = '群组消息';
  292. content = '接收到一条新消息';
  293. }
  294. var bMustPush = 0;
  295. var data;
  296. if (result.length > 0) {
  297. data = result[0];
  298. if (data.is_online) {
  299. bMustPush = 1;
  300. }
  301. }
  302. var push_data = JSON.stringify({
  303. type: 'group_msg',
  304. gid: req.query.to_gid
  305. });
  306. // 保存通知到数据库中
  307. push.savePushNotify(toUserID,
  308. req.query.type,
  309. title,
  310. content,
  311. push_data,
  312. bMustPush,
  313. function (err, result) {
  314. if (err) {
  315. // 保存失败
  316. console.log('save msg to db failed');
  317. } else {
  318. console.log('save msg to db success');
  319. if (bMustPush == true) {
  320. if (data.platform == 0) {// iOS
  321. getui.pushAPN(toUserID,
  322. data.token,
  323. req.query.type,
  324. title,
  325. content,
  326. push_data,
  327. function (err, result) {
  328. if (err != null) {
  329. console.log(err);
  330. } else {
  331. console.log(result);
  332. }
  333. });
  334. } else {// Android
  335. getui.pushAndroid(data.client_id,
  336. req.query.type,
  337. title,
  338. content,
  339. push_data,
  340. data.status,
  341. function (err, result) {
  342. if (err != null) {
  343. console.log(err);
  344. } else {
  345. console.log(result);
  346. }
  347. });
  348. }
  349. }
  350. }
  351. });
  352. });
  353. // 统计信息
  354. var at_me = 0;
  355. if (at_uid == toUserID) {
  356. at_me = 1;
  357. }
  358. StatMsg.updateGroupChatInfo(toUserID,
  359. req.query.to_gid,
  360. req.query.from_uid,
  361. at_me,
  362. req.query.type,
  363. req.query.content,
  364. true,
  365. function (err, result) {
  366. if (err) {
  367. console.log(err);
  368. }
  369. });
  370. })();
  371. }
  372. });
  373. });
  374. });
  375. });
  376. /**
  377. * 读取群组消息。
  378. *
  379. * :group/getmsg.im?uid=x&gid=xx&start=0&count=20
  380. *
  381. * 参数:
  382. * uid:用户id
  383. * gid:群组id
  384. * start;分页查询起始条目
  385. * count:查询条数
  386. * 备注:按时间倒序
  387. */
  388. router.get(endpoints.Msg.Groups, function (req, res, next) {
  389. if (req.query.uid == null
  390. || req.query.gid == null
  391. || req.query.start == null
  392. || req.query.count == null) {
  393. res.send({errno: -1, errmsg: 'parameter error'});
  394. return;
  395. }
  396. groupMsg.getGroupMsg(req.query.gid, req.query.start, req.query.count, function (err, result) {
  397. if (err) {
  398. res.send({errno: 1, errmsg: 'get group msg from db error'});
  399. return;
  400. }
  401. var data = {};
  402. data.start = parseInt(req.query.start);
  403. data.count = result.length;
  404. data.list = new Array();
  405. for (var nIndex = 0; nIndex < result.length; nIndex++) {
  406. result[nIndex].timestamp = Date.parse(new Date(result[nIndex].timestamp));
  407. data.list.push(result[nIndex]);
  408. }
  409. res.send(data);
  410. // 清空统计信息
  411. StatMsg.clearGroupChatInfo(req.query.uid,
  412. req.query.gid,
  413. function (err, result) {
  414. if (err) {
  415. console.log(err);
  416. }
  417. });
  418. });
  419. });
  420. /**
  421. * 发送系统消息。
  422. *
  423. * system/sendmsg.im?to_uid=x&type=xx&title=xxx&content=xxxx&data=xxxxx
  424. *
  425. * 参数:
  426. * to_uid:消息接收者ID
  427. * type:消息类型
  428. * title:消息标题
  429. * content:推送消息提示内容
  430. * data:推送消息内容
  431. */
  432. router.get(endpoints.Msg.System, function (req, res, next) {
  433. if (req.query.to_uid == null
  434. || req.query.title == null
  435. || req.query.type == null
  436. || req.query.content == null
  437. || req.query.data == null) {
  438. res.send({errno: -1, errmsg: 'parameter error'});
  439. return;
  440. }
  441. user.getUserbyID(req.query.to_uid, function (err, result) {
  442. if (err) {
  443. res.send({errno: 1, errmsg: 'get users by id from db failed'});
  444. return;
  445. }
  446. var bMustPush = 0;
  447. var data;
  448. if (result.length > 0) {
  449. data = result[0];
  450. if (data.is_online) {
  451. bMustPush = 1;
  452. }
  453. }
  454. var push_data = JSON.stringify({
  455. type: req.query.type,
  456. data: req.query.data
  457. });
  458. // 保存该条推送信息
  459. systemMsg.saveSystemMsg(req.query.to_uid,
  460. req.query.type,
  461. req.query.title,
  462. req.query.content,
  463. req.query.data,
  464. function (err, result) {
  465. if (err) {
  466. // 保存失败
  467. res.send({errno: 2, errmsg: 'save msg to db failed'});
  468. } else {
  469. // 保存通知到数据库中
  470. push.savePushNotify(req.query.to_uid,
  471. req.query.type,
  472. req.query.title,
  473. req.query.content,
  474. push_data,
  475. bMustPush,
  476. function (err, result) {
  477. if (err) {
  478. // 保存失败
  479. res.send({errno: 3, errmsg: 'save msg to db failed'});
  480. } else {
  481. res.send({errno: 0, errmsg: 'save msg to db success'});
  482. if (bMustPush == true) {
  483. if (data.platform == 0) {// iOS
  484. getui.pushAPN(req.query.to_uid,
  485. data.token,
  486. req.query.type,
  487. req.query.title,
  488. req.query.content,
  489. push_data,
  490. function (err, result) {
  491. if (err != null) {
  492. console.log(err);
  493. } else {
  494. console.log(result);
  495. }
  496. });
  497. } else {// Android
  498. getui.pushAndroid(data.client_id,
  499. req.query.type,
  500. req.query.title,
  501. req.query.content,
  502. push_data,
  503. data.status,
  504. function (err, result) {
  505. if (err != null) {
  506. console.log(err);
  507. } else {
  508. console.log(result);
  509. }
  510. });
  511. }
  512. }
  513. }
  514. });
  515. }
  516. });
  517. });
  518. });
  519. /**
  520. * 获取群组消息统计。
  521. *
  522. * statistic/getgroupchatinfo.im?uid=x&gid=xx
  523. *
  524. * 参数:
  525. * uid:信息所有者id
  526. * gid:群组id
  527. */
  528. router.get(endpoints.Msg.GroupStat, function (req, res, next) {
  529. if (req.query.uid == null
  530. || req.query.gid == null) {
  531. res.send({errno: -1, errmsg: 'parameter error'});
  532. return;
  533. }
  534. StatMsg.getGroupChatInfo(req.query.uid, req.query.gid, function (err, result) {
  535. if (err) {
  536. res.send({errno: 1, errmsg: 'get statistic from db error'});
  537. return;
  538. }
  539. if (result.length == 0) {
  540. var data = {"uid":req.query.uid,"from_uid":"","from_gid":req.query.gid,"at_me":0,"last_content_type":1,"last_content":"","new_msg_count":0,"timestamp":0};
  541. res.send(data);
  542. return;
  543. }
  544. result[0].timestamp = Date.parse(new Date(result[0].timestamp));
  545. res.send(result[0]);
  546. });
  547. });
  548. /**
  549. * 获取点对点消息统计。
  550. *
  551. * statistic/getp2pchatinfo.im?uid=x&peer_uid=xx
  552. *
  553. * 参数:
  554. * uid:信息所有者id
  555. * peer_uid:聊天对端id
  556. */
  557. router.get(endpoints.Msg.PrivateStat, function (req, res, next) {
  558. if (req.query.uid == null
  559. || req.query.peer_uid == null) {
  560. res.send({errno: -1, errmsg: 'parameter error'});
  561. return;
  562. }
  563. StatMsg.getP2PChatInfo(req.query.uid, req.query.peer_uid, function (err, result) {
  564. if (err) {
  565. res.send({errno: 1, errmsg: 'get statistic from db error'});
  566. return;
  567. }
  568. if (result.length == 0) {
  569. var data = {"uid":req.query.uid,"from_uid":req.query.peer_uid,"last_content_type":1,"last_content":"","new_msg_count":0,"timestamp":0};
  570. res.send(data);
  571. return;
  572. }
  573. result[0].timestamp = Date.parse(new Date(result[0].timestamp));
  574. res.send(result[0]);
  575. });
  576. });
  577. /**
  578. * 获取参与的聊天列表,包括:点对点,@我,参与的讨论组等。
  579. *
  580. * statistic/getchatlist.im?uid=x
  581. *
  582. * 参数:
  583. * uid:信息所有者id
  584. */
  585. router.get(endpoints.Users.ChatList, function (req, res, next) {
  586. if (req.query.uid == null) {
  587. res.send({errno: -1, errmsg: 'parameter error'});
  588. return;
  589. }
  590. StatMsg.getChatList(req.query.uid, function (err, result) {
  591. if (err) {
  592. res.send({errno: 1, errmsg: 'get statistic from db error'});
  593. return;
  594. }
  595. if (result.length == 0) {
  596. var data = {"uid":req.query.uid,"from_uid":req.query.peer_uid,"last_content_type":1,"last_content":"","new_msg_count":0,"timestamp":0};
  597. res.send(data);
  598. return;
  599. }
  600. //result[0].timestamp = Date.parse(new Date(result[0].timestamp));
  601. for (var index = 0; index < result.length; index++) {
  602. result[index].timestamp = Date.parse(new Date(result[index].timestamp));
  603. }
  604. res.send(result);
  605. });
  606. });
  607. /**
  608. * 群组聊天消息所有未读数。
  609. *
  610. * statistic/getgroupunreadcount.im?uid=x
  611. *
  612. * 参数:
  613. * uid:信息所有者id
  614. */
  615. router.get(endpoints.Users.GroupUnreadMsgCount, function (req, res, next) {
  616. if (req.query.uid == null) {
  617. res.send({errno: -1, errmsg: 'parameter error'});
  618. return;
  619. }
  620. StatMsg.getGroupChatAllUnRead(req.query.uid, function (err, result) {
  621. if (err) {
  622. res.send({errno: 1, errmsg: 'get statistic from db error'});
  623. return;
  624. }
  625. var data = {"uid":req.query.uid,"msg_type":2,"new_msg_count":0};
  626. if (result.length == 0) {
  627. res.send(data);
  628. return;
  629. }
  630. var count = 0;
  631. var index = 0;
  632. var length = result.length;
  633. for (; index < length; index++) {
  634. count += result[index].new_msg_count;
  635. }
  636. data.new_msg_count = count;
  637. res.send(data);
  638. });
  639. });
  640. /**
  641. * 一对一聊天消息所有未读数。
  642. *
  643. * statistic/getp2punreadcount.im?uid=x
  644. *
  645. * 参数:
  646. * uid:信息所有者id
  647. */
  648. router.get(endpoints.Users.PrivateUnreadMsgCount, function (req, res, next) {
  649. if (req.query.uid == null) {
  650. res.send({errno: -1, errmsg: 'parameter error'});
  651. return;
  652. }
  653. StatMsg.getP2PChatAllUnRead(req.query.uid, function (err, result) {
  654. if (err) {
  655. res.send({errno: 1, errmsg: 'get statistic from db error'});
  656. return;
  657. }
  658. var data = {"uid":req.query.uid,"msg_type":1,"new_msg_count":0};
  659. if (result.length == 0) {
  660. res.send(data);
  661. return;
  662. }
  663. var count = 0;
  664. var index = 0;
  665. var length = result.length;
  666. for (; index < length; index++) {
  667. count += result[index].new_msg_count;
  668. }
  669. data.new_msg_count = count;
  670. res.send(data);
  671. });
  672. });
  673. /**
  674. * 所有聊天消息未读数。
  675. *
  676. * statistic/getallunreadmsgcount.im?uid=x
  677. *
  678. * 参数:
  679. * uid:信息所有者id
  680. */
  681. router.get(endpoints.Users.UnreadMsgCount, function (req, res, next) {
  682. if (req.query.uid == null) {
  683. res.send({errno: -1, errmsg: 'parameter error'});
  684. return;
  685. }
  686. StatMsg.getChatAllUnRead(req.query.uid, function (err, result) {
  687. if (err) {
  688. res.send({errno: 1, errmsg: 'get statistic from db error'});
  689. return;
  690. }
  691. var data = {"uid":req.query.uid,"msg_type":0,"new_msg_count":0};
  692. if (result.length == 0) {
  693. res.send(data);
  694. return;
  695. }
  696. var count = 0;
  697. var index = 0;
  698. var length = result.length;
  699. for (; index < length; index++) {
  700. count += result[index].new_msg_count;
  701. }
  702. data.new_msg_count = count;
  703. res.send(data);
  704. });
  705. });
  706. /**
  707. * 获取角标数。
  708. *
  709. * statistic/getbadgenum.im?uid=x
  710. *
  711. * 参数:
  712. * uid:用户id
  713. */
  714. router.get('/getbadgenum.im', function (req, res, next) {
  715. if (req.query.uid == null) {
  716. res.send({errno: -1, errmsg: 'parameter error'});
  717. return;
  718. }
  719. StatMsg.getBadgeNumber(req.query.uid, function (err, result) {
  720. if (err) {
  721. res.send({errno: 1, errmsg: 'get badge error'});
  722. return;
  723. }
  724. var data = {"uid":req.query.uid,"badge":result};
  725. res.send(data);
  726. });
  727. });
  728. module.exports = router;