mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
05cf4f495d
- 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
16 lines
358 B
JavaScript
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);
|
|
};
|