fix: remove unused data from post/topic/user hashes

This commit is contained in:
Barış Soner Uşaklı
2019-10-07 23:13:43 -04:00
parent 4bc77d064b
commit 75bcb0f484
8 changed files with 156 additions and 39 deletions

View File

@@ -24,23 +24,20 @@ module.exports = function (User) {
email: data.email || '',
joindate: timestamp,
lastonline: timestamp,
picture: data.picture || '',
fullname: data.fullname || '',
location: data.location || '',
birthday: data.birthday || '',
website: '',
signature: '',
uploadedpicture: '',
profileviews: 0,
reputation: 0,
postcount: 0,
topiccount: 0,
lastposttime: 0,
banned: 0,
status: 'online',
gdpr_consent: data.gdpr_consent === true ? 1 : 0,
acceptTos: data.acceptTos === true ? 1 : 0,
};
['picture', 'fullname', 'location', 'birthday'].forEach((field) => {
if (data[field]) {
userData[field] = data[field];
}
});
if (data.gdpr_consent === true) {
userData.gdpr_consent = 1;
}
if (data.acceptTos === true) {
userData.acceptTos = 1;
}
const renamedUsername = await User.uniqueUsername(userData);
const userNameChanged = !!renamedUsername;
if (userNameChanged) {

View File

@@ -12,7 +12,7 @@ const utils = require('../utils');
const intFields = [
'uid', 'postcount', 'topiccount', 'reputation', 'profileviews',
'banned', 'banned:expire', 'email:confirmed', 'joindate', 'lastonline', 'lastqueuetime',
'lastposttime', 'followingCount', 'followerCount',
'lastposttime', 'followingCount', 'followerCount', 'passwordExpiry',
];
module.exports = function (User) {

View File

@@ -86,7 +86,9 @@ UserReset.updateExpiry = async function (uid) {
const oneDay = 1000 * 60 * 60 * 24;
const expireDays = meta.config.passwordExpiryDays;
const expiry = Date.now() + (oneDay * expireDays);
await user.setUserField(uid, 'passwordExpiry', expireDays > 0 ? expiry : 0);
if (expireDays > 0) {
await user.setUserField(uid, 'passwordExpiry', expiry);
}
};
UserReset.clean = async function () {