fix: add timestamp to initial username history

v1.18.x
Barış Soner Uşaklı 5 years ago
parent 8f81651e2f
commit 18d892398f

@ -55,7 +55,7 @@ module.exports = function (User) {
const bulkAdd = [
['username:uid', userData.uid, userData.username],
['user:' + userData.uid + ':usernames', timestamp, userData.username],
['user:' + userData.uid + ':usernames', timestamp, userData.username + ':' + timestamp],
['username:sorted', 0, userData.username.toLowerCase() + ':' + userData.uid],
['userslug:uid', userData.uid, userData.userslug],
['users:joindate', timestamp, userData.uid],

@ -1137,17 +1137,12 @@ describe('User', function () {
});
it('should get history from set', function (done) {
var now = Date.now();
db.sortedSetAdd('user:' + testUid + ':usernames', now, 'derp:' + now, function (err) {
assert.ifError(err);
User.getHistory('user:' + testUid + ':usernames', function (err, data) {
assert.ifError(err);
assert.equal(data[0].value, 'derp');
assert.equal(data[0].timestamp, now);
done();
});
});
it('should get history from set', async function () {
const now = Date.now();
await db.sortedSetAdd('user:' + testUid + ':usernames', now, 'derp:' + now);
const data = await User.getHistory('user:' + testUid + ':usernames');
assert.equal(data[0].value, 'derp');
assert.equal(data[0].timestamp, now);
});
it('should return the correct ban reason', function (done) {

Loading…
Cancel
Save