|
@@ -10,6 +10,7 @@ const ua = require('universal-analytics');
|
|
|
const isbot = require('isbot');
|
|
const isbot = require('isbot');
|
|
|
const { addIPCooldown } = require('../db/user');
|
|
const { addIPCooldown } = require('../db/user');
|
|
|
const {
|
|
const {
|
|
|
|
|
+ addUrlCount,
|
|
|
createShortUrl,
|
|
createShortUrl,
|
|
|
createVisit,
|
|
createVisit,
|
|
|
deleteCustomDomain,
|
|
deleteCustomDomain,
|
|
@@ -32,7 +33,7 @@ const {
|
|
|
} = require('./validateBodyController');
|
|
} = require('./validateBodyController');
|
|
|
const transporter = require('../mail/mail');
|
|
const transporter = require('../mail/mail');
|
|
|
const redis = require('../redis');
|
|
const redis = require('../redis');
|
|
|
-const { addProtocol, generateShortUrl, getStatsCacheTime } = require('../utils');
|
|
|
|
|
|
|
+const { addProtocol, getStatsLimit, generateShortUrl, getStatsCacheTime } = require('../utils');
|
|
|
|
|
|
|
|
const dnsLookup = promisify(dns.lookup);
|
|
const dnsLookup = promisify(dns.lookup);
|
|
|
|
|
|
|
@@ -160,12 +161,14 @@ exports.goToUrl = async (req, res, next) => {
|
|
|
req.pageType = 'password';
|
|
req.pageType = 'password';
|
|
|
return next();
|
|
return next();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
if (url.password) {
|
|
if (url.password) {
|
|
|
const isMatch = await bcrypt.compare(req.body.password, url.password);
|
|
const isMatch = await bcrypt.compare(req.body.password, url.password);
|
|
|
if (!isMatch) {
|
|
if (!isMatch) {
|
|
|
return res.status(401).json({ error: 'Password is not correct' });
|
|
return res.status(401).json({ error: 'Password is not correct' });
|
|
|
}
|
|
}
|
|
|
if (url.user && !isBot) {
|
|
if (url.user && !isBot) {
|
|
|
|
|
+ addUrlCount(url.id, domain);
|
|
|
createVisit({
|
|
createVisit({
|
|
|
browser,
|
|
browser,
|
|
|
country: country || 'Unknown',
|
|
country: country || 'Unknown',
|
|
@@ -173,11 +176,13 @@ exports.goToUrl = async (req, res, next) => {
|
|
|
id: url.id,
|
|
id: url.id,
|
|
|
os,
|
|
os,
|
|
|
referrer: referrer || 'Direct',
|
|
referrer: referrer || 'Direct',
|
|
|
|
|
+ limit: getStatsLimit(url),
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
return res.status(200).json({ target: url.target });
|
|
return res.status(200).json({ target: url.target });
|
|
|
}
|
|
}
|
|
|
if (url.user && !isBot) {
|
|
if (url.user && !isBot) {
|
|
|
|
|
+ addUrlCount(url.id, domain);
|
|
|
createVisit({
|
|
createVisit({
|
|
|
browser,
|
|
browser,
|
|
|
country: country || 'Unknown',
|
|
country: country || 'Unknown',
|
|
@@ -185,6 +190,7 @@ exports.goToUrl = async (req, res, next) => {
|
|
|
id: url.id,
|
|
id: url.id,
|
|
|
os,
|
|
os,
|
|
|
referrer: referrer || 'Direct',
|
|
referrer: referrer || 'Direct',
|
|
|
|
|
+ limit: getStatsLimit(url),
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|