fix: Upload Foto
This commit is contained in:
@@ -128,6 +128,7 @@ MySkillSchema.statics.getFieldsLastForSearch = function() {
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
params.fieldsearch_last = this.getFieldsLastForSearch();
|
||||
@@ -147,6 +148,7 @@ MySkillSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
idContribType: 1,
|
||||
idCity: 1,
|
||||
numLevel: 1,
|
||||
adType: 1,
|
||||
photos: 1,
|
||||
note: 1,
|
||||
descr: 1,
|
||||
@@ -231,6 +233,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
@@ -280,6 +283,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
@@ -329,6 +333,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
@@ -378,6 +383,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
@@ -427,6 +433,7 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
'idContribType': 1,
|
||||
'idCity': 1,
|
||||
'numLevel': 1,
|
||||
adType: 1,
|
||||
'photos': 1,
|
||||
'note': 1,
|
||||
'descr': 1,
|
||||
@@ -449,6 +456,14 @@ MySkillSchema.statics.getMySkillByIdkill = function(idapp, idSkill) {
|
||||
});
|
||||
};
|
||||
|
||||
MySkillSchema.statics.getCompleteRecord = function(idapp, id) {
|
||||
const MySkill = this;
|
||||
|
||||
return MySkill.getMySkillByIdkill(idapp, id);
|
||||
|
||||
};
|
||||
|
||||
|
||||
const MySkill = mongoose.model('MySkill', MySkillSchema);
|
||||
|
||||
module.exports = {MySkill};
|
||||
|
||||
@@ -137,18 +137,16 @@ module.exports = {
|
||||
"label" : "Dono",
|
||||
"__v" : 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("51bc466567de9a1f54b254f4"),
|
||||
"idapp" : "13",
|
||||
"label" : "Offerta Libera",
|
||||
"__v" : 0
|
||||
},
|
||||
|
||||
{
|
||||
"_id" : ObjectID("51bc454867de9a1f54b254f2"),
|
||||
"idapp" : "13",
|
||||
"label" : "Baratto (scambio Beni o Servizi)",
|
||||
"label" : "Baratto",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
@@ -163,11 +161,41 @@ module.exports = {
|
||||
"label" : "Monete Alternative",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254ac"),
|
||||
"idapp" : "13",
|
||||
"label" : "Ris (RISO)",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254ad"),
|
||||
"idapp" : "13",
|
||||
"label" : "Sardex",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254ae"),
|
||||
"idapp" : "13",
|
||||
"label" : "Gaiax (ProItaly)",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254af"),
|
||||
"idapp" : "13",
|
||||
"label" : "Val (VAL.AZ.CO.)",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b254fb"),
|
||||
"idapp" : "13",
|
||||
"label" : "Euro",
|
||||
"__v" : 0
|
||||
},
|
||||
{
|
||||
"_id" : ObjectID("51bc482667de9a1f64b257fb"),
|
||||
"idapp" : "13",
|
||||
"label" : "Criptomonete",
|
||||
"__v" : 0
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
module.exports = {
|
||||
list: [
|
||||
{_id: 0, descr: '[Nessuno]', years_of_exp: 0},
|
||||
{_id: 1, descr: 'Principiante', years_of_exp: 1},
|
||||
{_id: 1, descr: 'Elementare', years_of_exp: 1},
|
||||
{_id: 2, descr: 'Intermedio', years_of_exp: 3},
|
||||
{_id: 3, descr: 'Avanzato', years_of_exp: 5},
|
||||
{_id: 4, descr: 'Esperto', years_of_exp: 10},
|
||||
{_id: 5, descr: 'Veterano', years_of_exp: 20},
|
||||
],
|
||||
};
|
||||
|
||||
@@ -169,6 +169,7 @@ module.exports = {
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
await this.insertIntoDb_NoDuplicate(false, 'contribtypes', Contribtype, 'label')
|
||||
|
||||
// AdTypes
|
||||
const {AdType} = require('../models/adtype');
|
||||
await this.insertIntoDb_NoDuplicate(abilita, 'adtypes', AdType, 'descr')
|
||||
|
||||
|
||||
@@ -370,7 +370,9 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
if (params.table === shared_consts.TAB_MYGROUPS) {
|
||||
if (shared_consts.MYGROUPS_KEY_TO_CRYPTED in mydata) {
|
||||
if (mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]) {
|
||||
mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED + shared_consts.SUFFIX_CRYPTED] = tools.cryptdata(mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]);
|
||||
mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED +
|
||||
shared_consts.SUFFIX_CRYPTED] = tools.cryptdata(
|
||||
mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +390,8 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
|
||||
*/
|
||||
}
|
||||
const indfind = mydata.admins.findIndex((rec) => (rec.username === req.user.username));
|
||||
const indfind = mydata.admins.findIndex(
|
||||
(rec) => (rec.username === req.user.username));
|
||||
|
||||
if (indfind < 0) {
|
||||
mydata.admins.push({username: req.user.username});
|
||||
@@ -416,9 +419,18 @@ router.post('/settable', authenticate, (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
return mytablerec.save().then(rec => {
|
||||
// tools.mylog('rec', rec);
|
||||
return mytablerec.save().
|
||||
then(async (rec) => {
|
||||
|
||||
if (shared_consts.TABLES_GETCOMPLETEREC.includes(params.table)) {
|
||||
const myrec = await mytablestrutt.getCompleteRecord(rec.idapp,
|
||||
rec._id);
|
||||
return res.send(myrec);
|
||||
} else {
|
||||
return res.send(rec);
|
||||
}
|
||||
|
||||
// tools.mylog('rec', rec);
|
||||
|
||||
}).catch((e) => {
|
||||
if (e.code === 11000) {
|
||||
@@ -716,7 +728,9 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
msg = 'Ripristinato';
|
||||
|
||||
await telegrambot.sendMsgTelegramToTheManagers(idapp,
|
||||
`L\'utente ` + tools.getNomeCognomeEUserNameByUser(rec) + ` è stato ${msg} da ` + tools.getNomeCognomeEUserNameByUser(req.user));
|
||||
`L\'utente ` + tools.getNomeCognomeEUserNameByUser(rec) +
|
||||
` è stato ${msg} da ` +
|
||||
tools.getNomeCognomeEUserNameByUser(req.user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -728,8 +742,10 @@ router.patch('/chval', authenticate, async (req, res) => {
|
||||
fieldsvalue.aportador_solidario);
|
||||
const nomecognomeas = await User.getNameSurnameByUsername(idapp,
|
||||
rec.aportador_solidario);
|
||||
msg = `Variato l'invitante di ` + tools.getNomeCognomeEUserNameByUser(rec) +
|
||||
'\nmodificato da ' + tools.getNomeCognomeEUserNameByUser(req.user) +
|
||||
msg = `Variato l'invitante di ` +
|
||||
tools.getNomeCognomeEUserNameByUser(rec) +
|
||||
'\nmodificato da ' +
|
||||
tools.getNomeCognomeEUserNameByUser(req.user) +
|
||||
' \n' +
|
||||
'Prima: ' + nomecognomeas + ' (' + rec.aportador_solidario +
|
||||
')\n' +
|
||||
@@ -1418,10 +1434,12 @@ function uploadFile(req, res, version) {
|
||||
// res.sendFile(path.resolve(filename));
|
||||
|
||||
oldpath = file.path;
|
||||
// newname = '/home/paolo/Documents/prova.png'
|
||||
file.path = newname;
|
||||
|
||||
// Move in the folder application !
|
||||
tools.move(oldpath, newname, (err) => {
|
||||
// tools.move(oldpath, newname, (err) => {
|
||||
tools.move(oldpath, newname, async (err) => {
|
||||
if (err)
|
||||
console.log('err:', err);
|
||||
|
||||
@@ -1444,10 +1462,9 @@ function uploadFile(req, res, version) {
|
||||
};
|
||||
|
||||
// Salva le immagini in formato compresso
|
||||
(async () => {
|
||||
try {
|
||||
const ris = await resizer(newname, setup_image_compress);
|
||||
|
||||
console.log('resizer', newname);
|
||||
if (ris) {
|
||||
if (tools.isFileExists(resized_img)) {
|
||||
tools.delete(newname, false, () => {});
|
||||
@@ -1455,6 +1472,8 @@ function uploadFile(req, res, version) {
|
||||
tools.move(resized_img, newname, (err) => {
|
||||
if (err)
|
||||
console.error('err', err);
|
||||
else
|
||||
console.log('move', newname);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1462,8 +1481,8 @@ function uploadFile(req, res, version) {
|
||||
console.error('newname', e);
|
||||
}
|
||||
|
||||
})();
|
||||
res.end();
|
||||
console.log('res.end');
|
||||
// return res.send({filename: newname });
|
||||
|
||||
});
|
||||
|
||||
@@ -361,7 +361,7 @@ router.post('/login', (req, res) => {
|
||||
var user = new User(body);
|
||||
// const subs = _.pick(req.body, ['subs']);
|
||||
|
||||
// tools.mylog("LOGIN: username: " + user.username + " pwd = " + user.password);
|
||||
// tools.mylog("LOG: u: " + user.username + " p:" + user.password);
|
||||
|
||||
// tools.mylog("user REC:", user);
|
||||
|
||||
@@ -381,18 +381,11 @@ router.post('/login', (req, res) => {
|
||||
tools.mylogshow(msg);
|
||||
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
|
||||
res.status(404).send({code: server_constants.RIS_CODE_LOGIN_ERR});
|
||||
} else if (!!user.subaccount && user.subaccount) {
|
||||
await tools.snooze(1000);
|
||||
// const msg = "Tentativo di Login ERRATO [" + body.username + ' , ' + body.password + ']\n' + '[IP: ' + tools.getiPAddressUser(req) + ']';
|
||||
// tools.mylogshow(msg);
|
||||
// telegrambot.sendMsgTelegramToTheManagers(body.idapp, msg);
|
||||
res.status(404).
|
||||
send({code: server_constants.RIS_CODE_LOGIN_ERR_SUBACCOUNT});
|
||||
return null;
|
||||
}
|
||||
return user;
|
||||
}).
|
||||
then(user => {
|
||||
// console.log('Lgn-Ok');
|
||||
if (user) {
|
||||
return user.generateAuthToken(req).then((token) => {
|
||||
var usertosend = new User();
|
||||
@@ -421,6 +414,7 @@ router.post('/login', (req, res) => {
|
||||
return (subscribe !== null);
|
||||
}).
|
||||
then(subsExistonDb => {
|
||||
// console.log('ESEGUITO OK')
|
||||
return {
|
||||
usertosend: myris.usertosend,
|
||||
token: myris.token,
|
||||
@@ -451,7 +445,7 @@ router.post('/login', (req, res) => {
|
||||
}
|
||||
}).
|
||||
catch((e) => {
|
||||
tools.mylog('ERRORE IN LOGIN: ' + e.message);
|
||||
console.error('ERRORE IN LOGIN: ' + e.message);
|
||||
if (!resalreadysent)
|
||||
res.status(400).
|
||||
send({code: server_constants.RIS_CODE_LOGIN_ERR_GENERIC});
|
||||
@@ -918,18 +912,34 @@ async function eseguiDbOp(idapp, mydata, locale) {
|
||||
|
||||
} else if (mydata.dbop === 'emptyDbSkill') {
|
||||
|
||||
// Svuota e Ricrea
|
||||
|
||||
const {Sector} = require('../models/sector');
|
||||
const {Skill} = require('../models/skill');
|
||||
const {SubSkill} = require('../models/subskill');
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
const {Contribtype} = require('../models/contribtype');
|
||||
const {AdType} = require('../models/adtype');
|
||||
|
||||
await Sector.deleteMany({});
|
||||
await Skill.deleteMany({});
|
||||
await SubSkill.deleteMany({});
|
||||
await Contribtype.deleteMany({});
|
||||
await AdType.deleteMany({});
|
||||
|
||||
await populate.popolaTabelleNuove();
|
||||
|
||||
} else if (mydata.dbop === 'ricreaTabCitiesProvinces') {
|
||||
|
||||
// Svuota e Ricrea
|
||||
|
||||
const {City} = require('../models/city');
|
||||
const {Province} = require('../models/province');
|
||||
|
||||
await City.deleteMany({});
|
||||
await Province.deleteMany({});
|
||||
|
||||
await populate.popolaTabelleNuove();
|
||||
|
||||
} else if (mydata.dbop === 'PopulateTables') {
|
||||
|
||||
populate.popolaTabelleNuove();
|
||||
|
||||
@@ -140,6 +140,7 @@ MsgBot = {
|
||||
'mi sposi'],
|
||||
CHE_TEMPO_FA: ['che tempo'],
|
||||
NON_TROO_INVITATI: ['non trovo invitati', 'non riesco a trovare invitati'],
|
||||
TROVAMI_UN_UOMO_DONNA: ['trovami un uomo', 'trovami una donna', 'esiste una donna per me', 'esiste un uomo per me'],
|
||||
PAROLACCE: [
|
||||
'stronz',
|
||||
'fanculo',
|
||||
@@ -1566,6 +1567,8 @@ class Telegram {
|
||||
emo.GIFT_HEART;
|
||||
} else if (MsgBot.MA_ALLORA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Ma allora cosa?';
|
||||
} else if (MsgBot.TROVAMI_UN_UOMO_DONNA.find((rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Eh non è cosi facile. Ma se t\'impegni a cercare ci riuscirai. Nel frattempo trova la tua strada, fai il tuo percorso interiore, e magari arriva proprio quando meno te l\'aspetti';
|
||||
} else if (MsgBot.SEI_LIBERO_STASERA.find(
|
||||
(rec) => testo.indexOf(rec) > -1)) {
|
||||
risp = 'Si vabbeh, non è che puoi prendere subito tutta questa confidenza' +
|
||||
|
||||
@@ -2139,6 +2139,14 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
copy(oldPath, newPath, callback) {
|
||||
|
||||
fs.copyFile(oldPath, newPath, (err) => {
|
||||
if (err) throw err;
|
||||
// console.log('source.txt was copied to destination.txt');
|
||||
});
|
||||
},
|
||||
|
||||
extractFileName: function(filename) {
|
||||
return path.basename(filename);
|
||||
},
|
||||
@@ -2155,6 +2163,7 @@ module.exports = {
|
||||
let img_small = path.dirname(mypath) + '/' +
|
||||
server_constants.PREFIX_IMG_SMALL + path.basename(mypath);
|
||||
fs.unlink(img_small, () => {});
|
||||
console.log('delete file', mypath)
|
||||
} catch (e) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ module.exports = {
|
||||
TABLES_USER_ID: ['myskills', 'mygroups'],
|
||||
TABLES_USER_INCLUDE_MY: ['mygroups'],
|
||||
TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybots', 'mygroups'],
|
||||
TABLES_GETCOMPLETEREC: ['myskills'],
|
||||
|
||||
TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mygroups'],
|
||||
TABLES_PERM_NEWREC: ['skills', 'subskills', 'mygroups'],
|
||||
|
||||
Reference in New Issue
Block a user