3 const mongoUtils = require('gitter-web-persistence-utils/lib/mongo-utils');
4 const restSerializer = require('../../serializers/rest-serializer');
5 const chatReportService = require('gitter-web-chat-reports');
7 function postprocessUser(user) {
9 return Object.assign({}, user, {
10 accountCreatedDate: mongoUtils.getTimestampFromObjectId(user.id)
15 function getSnapshotsForPageContext(req) {
16 return chatReportService
17 .findChatMessageReports({
18 beforeId: req.query.beforeId,
19 afterId: req.query.afterId,
20 limit: req.query.limit
22 .then(function(reports) {
23 const strategy = new restSerializer.ChatMessageReportStrategy();
24 return restSerializer.serialize(reports, strategy);
26 .then(serializedReports => {
28 adminChatMessageReportDashboard: {
29 reports: serializedReports.map(report => {
30 return Object.assign({}, report, {
31 reporterUser: postprocessUser(report.reporterUser),
32 messageUser: postprocessUser(report.messageUser)
40 module.exports = getSnapshotsForPageContext;