Ghost/core/server/web/api/middleware/update-user-last-seen.js
Hannah Wolfe 05cf4f495d Moved update-user-last-seen mw into api app
- Moved update-user-last-seen from shared to api as it is not shared (except within the API)
- This file is only used in one part of the app, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
2020-04-22 07:12:25 +01:00

16 lines
358 B
JavaScript

const constants = require('../../../lib/constants');
module.exports = function updateUserLastSeenMiddleware(req, res, next) {
if (!req.user) {
return next();
}
if (Date.now() - req.user.get('last_seen') < constants.ONE_HOUR_MS) {
return next();
}
req.user.updateLastSeen().then(() => {
next();
}, next);
};