Browse Source

Use Date.now() (on node side)

pull/60/merge
Lal'C Mellk Mal 6 years ago
parent
commit
1f11f4be98
7 changed files with 11 additions and 11 deletions
  1. +1
    -1
      admin/index.js
  2. +2
    -2
      archive/daemon.js
  3. +1
    -1
      curfew/server.js
  4. +3
    -3
      db.js
  5. +1
    -1
      imager/daemon.js
  6. +2
    -2
      server/persona.js
  7. +1
    -1
      server/server.js

+ 1
- 1
admin/index.js View File

@@ -14,7 +14,7 @@ function ban(m, mod, ip, type) {
m.sadd('hot:' + type + 's', ip);
m.hset('ip:' + ip, 'ban', type);

var now = new Date().getTime();
var now = Date.now();
var info = {ip: ip, type: type, time: now};
if (mod.ident.email)
info.email = mod.ident.email;


+ 2
- 2
archive/daemon.js View File

@@ -23,7 +23,7 @@ function connect() {
}

function at_next_minute(func) {
var now = new Date().getTime();
var now = Date.now();
var inFive = new Date(now + 5000);

var nextMinute = inFive.getTime();
@@ -44,7 +44,7 @@ var CLEANING_LIMIT = 10; // per minute
function clean_up() {
var r = connect();
var expiryKey = db.expiry_queue_key();
var now = Math.floor(new Date().getTime() / 1000);
var now = Math.floor(Date.now() / 1000);
r.zrangebyscore(expiryKey, 1, now, 'limit', 0, CLEANING_LIMIT,
function (err, expired) {
if (err) {


+ 1
- 1
curfew/server.js View File

@@ -114,7 +114,7 @@ function shutdown(board, cb) {
function at_next_curfew_start(board, func) {
var when = curfew_starting_time(board);
winston.info('Next curfew for ' + board + ' at ' + when.toUTCString());
setTimeout(func, when.getTime() - new Date().getTime());
setTimeout(func, when.getTime() - Date.now());
}

function enforce(board) {


+ 3
- 3
db.js View File

@@ -474,7 +474,7 @@ Y.reserve_post = function (op, ip, callback) {
return reserve();

var key = 'ip:' + ip + ':throttle:';
var now = new Date().getTime();
var now = Date.now();
var shortTerm = key + short_term_timeslot(now);
var longTerm = key + long_term_timeslot(now);
r.mget([shortTerm, longTerm], function (err, quants) {
@@ -1080,7 +1080,7 @@ Y.add_image = function (post, alloc, ip, callback) {
delete image.hash;
self._log(m, op, common.INSERT_IMAGE, [num, image]);

var now = new Date().getTime();
var now = Date.now();
var n = post_volume({image: true});
update_throughput(m, ip, now, post_volume({image: true}));
imager.make_image_nontemporary(m, alloc);
@@ -1097,7 +1097,7 @@ Y.append_post = function (post, tail, old_state, extra, cb) {
if (old_state[0] != post.state[0] || old_state[1] != post.state[1])
m.hset(key, 'state', post.state.join());
if (extra.ip) {
var now = new Date().getTime();
var now = Date.now();
update_throughput(m, extra.ip, now, post_volume(null, tail));
}
if (!_.isEmpty(extra.new_links))


+ 1
- 1
imager/daemon.js View File

@@ -276,7 +276,7 @@ IU.got_nails = function () {

this.status('Publishing...');
var image = this.image;
var time = new Date().getTime();
var time = Date.now();
image.src = time + image.ext;
var dest, mvs, pathUpdates = {};
var media_path = index.media_path, mv_file = etc.movex;


+ 2
- 2
server/persona.js View File

@@ -63,7 +63,7 @@ function verify_auth(resp, packet) {
return respond_error(resp, 'Bad Persona audience.');
}
delete packet.audience;
if (packet.expires && packet.expires < new Date().getTime())
if (packet.expires && packet.expires < Date.now())
return respond_error(resp, 'Login attempt expired.');
var email = packet.email;
var admin = config.ADMIN_PERSONAS.indexOf(email) >= 0;
@@ -141,7 +141,7 @@ function respond_ok(resp, cookie) {
}

function make_expiry() {
var expiry = new Date(new Date().getTime()
var expiry = new Date(Date.now()
+ config.LOGIN_SESSION_TIME*1000).toUTCString();
/* Change it to the expected dash-separated format */
var m = expiry.match(/^(\w+,\s+\d+)\s+(\w+)\s+(\d+\s+[\d:]+\s+\w+)$/);


+ 1
- 1
server/server.js View File

@@ -707,7 +707,7 @@ function allocate_post(msg, client, callback) {
return callback(Muggle("Already have a post."));
if (!inactive_board_check(client))
return callback(Muggle("Can't post here."));
var post = {time: new Date().getTime(), nonce: msg.nonce};
var post = {time: Date.now(), nonce: msg.nonce};
var body = '';
var ip = client.ident.ip;
var extra = {ip: ip, board: client.board};


Loading…
Cancel
Save