Settore se compariva "Tutti", veniva selezionato erroneamente di default -100
Risolto caricamento immagini Cliccando sull'immagine del profilo, nella Card, non si apre il Profilo Aggiunto "Estero" e "On Line" sul campo Comune. Orientamento dell'Immagine. viene storta una volta ridimensionata. Al momento della registrazione, dal BOT, in automatico viene presa l'immagine di Telegram e salvata sul proprio profilo della APP.
This commit is contained in:
@@ -28,6 +28,8 @@ require('./db/mongoose');
|
||||
|
||||
const {Settings} = require('./models/settings');
|
||||
|
||||
const globalTables = require('./tools/globalTables');
|
||||
|
||||
const i18n = require('i18n');
|
||||
|
||||
// OBTAIN
|
||||
@@ -241,6 +243,8 @@ async function myLoad() {
|
||||
|
||||
async function mystart() {
|
||||
|
||||
await estraiTutteLeImmagini();
|
||||
|
||||
if (process.env.PROD !== 1) {
|
||||
|
||||
testmsgwebpush();
|
||||
@@ -424,6 +428,104 @@ async function inizia() {
|
||||
// console.log(link2);
|
||||
// }
|
||||
|
||||
async function estraiImmagini(table) {
|
||||
const {User} = require('./models/user');
|
||||
|
||||
let idapp = '13';
|
||||
|
||||
let arrlist;
|
||||
|
||||
const mytable = globalTables.getTableByTableName(table);
|
||||
if (!mytable)
|
||||
return;
|
||||
|
||||
console.log('INIZIO - estraiImmagini', table);
|
||||
|
||||
arrlist = await mytable.find({idapp}).lean();
|
||||
|
||||
let file = '';
|
||||
let filetocheck = '';
|
||||
let dirmain = '';
|
||||
let filefrom = '';
|
||||
let filefrom2 = '';
|
||||
let dir = tools.getdirByIdApp(idapp) + dirmain + '/upload/';
|
||||
|
||||
try {
|
||||
if (!tools.sulServer()) {
|
||||
dirmain = '/public';
|
||||
}
|
||||
|
||||
for (const rec of arrlist) {
|
||||
const myuser = await User.findOne({idapp, _id: rec.userId}).lean();
|
||||
if (myuser) {
|
||||
const myphotos = rec.photos;
|
||||
|
||||
if (myphotos.length > 0) {
|
||||
let folderprof = dir + 'profile/' + myuser.username;
|
||||
|
||||
try {
|
||||
// console.log('checkdir', folderprof);
|
||||
if (!fs.existsSync(folderprof)) {
|
||||
console.log('*** Creadir', folderprof)
|
||||
fs.mkdirSync(folderprof);
|
||||
}
|
||||
|
||||
folderprof = dir + 'profile/' + myuser.username + '/' + table;
|
||||
// console.log('checkdir', folderprof);
|
||||
if (!fs.existsSync(folderprof)) {
|
||||
console.log('creadir', folderprof)
|
||||
fs.mkdirSync(folderprof);
|
||||
}
|
||||
}catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (const photo of myphotos) {
|
||||
|
||||
if (photo.imagefile) {
|
||||
file = dir + 'profile/' + myuser.username + '/' + table + '/' +
|
||||
photo.imagefile;
|
||||
filefrom = dir + 'profile/undefined/' + table + '/' + photo.imagefile;
|
||||
filefrom2 = dir + 'profile/' + myuser.username + '/' + photo.imagefile;
|
||||
|
||||
// console.log('file', file);
|
||||
// console.log('filefrom', filefrom);
|
||||
|
||||
if (!tools.isFileExists(file)){
|
||||
// non esiste
|
||||
console.log('non esiste', file);
|
||||
console.log(' filefrom', filefrom);
|
||||
console.log(' filefrom2', filefrom2);
|
||||
}
|
||||
|
||||
if (!tools.isFileExists(file) && tools.isFileExists(filefrom)) {
|
||||
console.log('@@@@@@ copia file:', filefrom, 'a', file);
|
||||
tools.copy(filefrom, file);
|
||||
}
|
||||
if (!tools.isFileExists(file) && tools.isFileExists(filefrom2)) {
|
||||
console.log('@@@@@@ copia file 2:', filefrom2, 'a', file);
|
||||
tools.copy(filefrom2, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log('FINE - estraiImmagini', table);
|
||||
}catch (e) {
|
||||
console.error('e', e);
|
||||
}
|
||||
}
|
||||
|
||||
async function estraiTutteLeImmagini() {
|
||||
|
||||
await estraiImmagini('myskills');
|
||||
await estraiImmagini('mygoods');
|
||||
await estraiImmagini('mybachecas');
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function faitest() {
|
||||
// console.log('Fai Test:')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user