Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/controllers/ArticlesController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const sequelize = require('sequelize');
const auth = require('../config/auth.json');
const bcrypt = require('bcryptjs');
const PlayerModel = require('../database/models/Player');
const config = require('config');
const db = require('../database');
const moment = require('moment');
Expand All @@ -10,7 +9,7 @@ const jwt = require('jsonwebtoken');
const functions = require('../modules/functions');
const i18n = require('../translation/i18n');

const ArticlesModel = require('../database/models/Articles');
const FormArticleModal = require('../database/models/FormArticle');

module.exports = {

Expand Down Expand Up @@ -592,6 +591,45 @@ module.exports = {
} catch (error) {
return res.status(500).json({ error });
}
},

async sendForm(req, res) {


var success = [];


const { articleId, userId, participants, link, message } = req.body;
const checkLimitForm = await FormArticleModal.findAndCountAll({ where: { article_id: articleId, user_id: userId } });

if (!participants || !link) {
return res.status(200).json({
error: true,
status_code: 400,
message: i18n.__('formParticipantsOrLinkRequired')
});
} else if (checkLimitForm.count >= 3) {
return res.status(200).json({
error: true,
status_code: 400,
message: i18n.__('formCheckLimit')
});
} else {
await FormArticleModal.create({ article_id: articleId, user_id: userId, usernames: participants, timestamp: moment().unix(), link: link, message: message })
.then(() => {
return res.status(200).json({
status_code: 200,
message: i18n.__('formSendSuccess')
});
}).catch(() => {
return res.status(200).json({
error: true,
status_code: 400,
message: i18n.__('formErrorUnknow')
});
}).finally(() => {})
}

}

}
2 changes: 1 addition & 1 deletion src/controllers/HomeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ module.exports = {
type: sequelize.QueryTypes.SELECT
});

let usersOnline = JSON.stringify(count[0].active_players + 23);
let usersOnline = JSON.stringify(count[0].active_players);

return res.status(200).json({ count: usersOnline });

Expand Down
7 changes: 5 additions & 2 deletions src/controllers/LoginController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ var mt = require('../modules/mt_rand');
const i18n = require('../translation/i18n');

function generateToken(params = {}) {
/*
return jwt.sign(params, auth.jwt_secret_key, {
expiresIn: '1d' // 1day
});
expiresIn: '1d' // 1 dia
});*/

return jwt.sign(params, auth.jwt_secret_key); //never expire
}
module.exports = {

Expand Down
7 changes: 5 additions & 2 deletions src/controllers/RegisterController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ const functions = require('../modules/functions');
const { verify } = require('hcaptcha');

function generateToken(params = {}) {
/*
return jwt.sign(params, auth.jwt_secret_key, {
expiresIn: '1d' // 1day
});
expiresIn: '1d' // 1 dia
});*/

return jwt.sign(params, auth.jwt_secret_key); //never expire
}


Expand Down
7 changes: 6 additions & 1 deletion src/translation/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@
"articlesSectionsThisMont": "Esse mês",
"articlesSectionsLastMonth": "Último mês",
"articlesSectionsOldest": "Antigo",
"getNewsNotFound": "getNewsNotFound"
"getNewsNotFound": "getNewsNotFound",
"formCheckLimit": "Submission limit reached",
"formSendSuccess": "Form submitted successfully! Thank you for participating!",
"formErrorUnknow": "Unknown error, please try again.",
"formParticipantsOrLinkRequired": "Participant or link is required to submit the form"

}
6 changes: 5 additions & 1 deletion src/translation/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@
"articlesSectionsThisMont": "Esse mês",
"articlesSectionsLastMonth": "Último mês",
"articlesSectionsOldest": "Antigo",
"getNewsNotFound": "getNewsNotFound"
"getNewsNotFound": "getNewsNotFound",
"formParticipantsOrLinkRequired": "O participante ou o link é obrigatório para enviar o formulário",
"formCheckLimit": "Limite de envios antigidos",
"formSendSuccess": "Formulário enviado com sucesso! Obrigado por participar!",
"formErrorUnknow": "Erro desconhecido, tente novamente."
}