Zoom Calendar

This commit is contained in:
Paolo Arena
2020-01-21 01:37:15 +01:00
parent 905c4a4a62
commit f5355c3a54
6 changed files with 245 additions and 56 deletions

View File

@@ -0,0 +1,70 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const tools = require('../tools/general');
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CalZoomSchema = new Schema({
idapp: {
type: String,
},
lang: {
type: String,
},
title: {
type: String,
},
typeconf: {
type: String,
},
date_start: {
type: Date
},
date_end: {
type: Date
},
id_conf_zoom: {
type: String
},
note: {
type: String
}
});
CalZoomSchema.statics.getFieldsForSearch = function () {
return ['title']
};
CalZoomSchema.statics.executeQueryTable = function (idapp, params) {
params.fieldsearch = this.getFieldsForSearch();
return tools.executeQueryTable(this, idapp, params);
};
CalZoomSchema.statics.findAllIdApp = async function (idapp) {
const CalZoom = this;
const myfind = { idapp, date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 3) } };
return await CalZoom.find(myfind).sort({ date_start: 1 });
};
CalZoomSchema.statics.getNextZoom = async function (idapp) {
const CalZoom = this;
// const myfind = { idapp, $and: [{ date_start: { $gt: tools.IncDateNow(-1000 * 60 * 5) } }, { date_start: { $lt: tools.IncDateNow(1000 * 60 * 60 * 6) } }] } ;
const myfind = { idapp, $and: [{ date_start: { $lt: tools.IncDateNow(1000 * 60 * 5) } }, { date_start: { $gt: tools.IncDateNow(-1000 * 60 * 60 * 2) } }] } ;
return await CalZoom.findOne(myfind).sort({ date_start: 1 });
};
const CalZoom = mongoose.model('CalZoom', CalZoomSchema);
module.exports = { CalZoom };

View File

@@ -35,6 +35,7 @@ const { PaymentType } = require('../models/paymenttype');
const { Discipline } = require('../models/discipline'); const { Discipline } = require('../models/discipline');
const { Newstosent } = require('../models/newstosent'); const { Newstosent } = require('../models/newstosent');
const { MyPage } = require('../models/mypage'); const { MyPage } = require('../models/mypage');
const { CalZoom } = require('../models/calzoom');
const { Gallery } = require('../models/gallery'); const { Gallery } = require('../models/gallery');
const { TemplEmail } = require('../models/templemail'); const { TemplEmail } = require('../models/templemail');
const { OpzEmail } = require('../models/opzemail'); const { OpzEmail } = require('../models/opzemail');
@@ -179,6 +180,8 @@ function getTableByTableName(tablename) {
mytable = Gallery; mytable = Gallery;
else if (tablename === 'mypage') else if (tablename === 'mypage')
mytable = MyPage; mytable = MyPage;
else if (tablename === 'calzoom')
mytable = CalZoom;
else if (tablename === 'templemail') else if (tablename === 'templemail')
mytable = TemplEmail; mytable = TemplEmail;
else if (tablename === 'opzemail') else if (tablename === 'opzemail')
@@ -425,6 +428,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
let newstosent = Promise.resolve([]); let newstosent = Promise.resolve([]);
let mailinglist = Promise.resolve([]); let mailinglist = Promise.resolve([]);
let mypage = MyPage.findAllIdApp(idapp); let mypage = MyPage.findAllIdApp(idapp);
let calzoom = CalZoom.findAllIdApp(idapp);
let gallery = Gallery.findAllIdApp(idapp); let gallery = Gallery.findAllIdApp(idapp);
if (sall) { if (sall) {
newstosent = Newstosent.findAllIdApp(idapp); newstosent = Newstosent.findAllIdApp(idapp);
@@ -435,7 +439,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
calcstat = User.calculateStat(idapp, req.user.username); calcstat = User.calculateStat(idapp, req.user.username);
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat]) return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions, disciplines, newstosent, mailinglist, mypage, gallery, paymenttype, calcstat, calzoom])
.then((arrdata) => { .then((arrdata) => {
// console.table(arrdata); // console.table(arrdata);
const myuser = req.user; const myuser = req.user;
@@ -458,6 +462,7 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
mypage: arrdata[10], mypage: arrdata[10],
gallery: arrdata[11], gallery: arrdata[11],
paymenttypes: arrdata[12], paymenttypes: arrdata[12],
calzoom: arrdata[14],
myuser, myuser,
}); });
}) })

View File

@@ -111,7 +111,7 @@ router.post('/', async (req, res) => {
return 1; return 1;
} }
const already_registered = recextra; const already_registered = recextra || user.aportador_solidario === tools.APORTADOR_NONE;
// Check if is an other people aportador_solidario // Check if is an other people aportador_solidario

View File

@@ -39,6 +39,7 @@ require('./models/sendmsg');
require('./models/mailinglist'); require('./models/mailinglist');
require('./models/newstosent'); require('./models/newstosent');
require('./models/mypage'); require('./models/mypage');
require('./models/calzoom');
const mysql_func = require('./mysql/mysql_func'); const mysql_func = require('./mysql/mysql_func');

View File

@@ -5,6 +5,7 @@ const appTelegram = ['7'];
const printf = require('util').format; const printf = require('util').format;
const { User } = require('../models/user'); const { User } = require('../models/user');
const { CalZoom } = require('../models/calzoom');
const emoji = require('node-emoji'); const emoji = require('node-emoji');
@@ -13,6 +14,8 @@ const i18n = require("i18n");
const Benvenuto = emoji.get('heartbeat') + emoji.get('heartbeat') + emoji.get('heartbeat') + ' Benvenuto!'; const Benvenuto = emoji.get('heartbeat') + emoji.get('heartbeat') + emoji.get('heartbeat') + ' Benvenuto!';
const emo = { const emo = {
STARS: emoji.get('stars'),
FIRE: emoji.get('fire'),
DREAM: emoji.get('beach_with_umbrella'), DREAM: emoji.get('beach_with_umbrella'),
EYES: emoji.get('eyes'), EYES: emoji.get('eyes'),
DIZZY: emoji.get('dizzy'), DIZZY: emoji.get('dizzy'),
@@ -61,6 +64,7 @@ function getemojibynumber(number) {
const Menu = { const Menu = {
LAVAGNA: emoji.get('om_symbol') + ' La tua Lavagna', LAVAGNA: emoji.get('om_symbol') + ' La tua Lavagna',
LINK_CONDIVIDERE: emoji.get('link') + ' Link da condividere', LINK_CONDIVIDERE: emoji.get('link') + ' Link da condividere',
ZOOM: emoji.get('information_source') + ' Zoom (Conferenze)',
INFO: emoji.get('information_source') + ' Informazioni', INFO: emoji.get('information_source') + ' Informazioni',
ASSISTENZA: emoji.get('open_hands') + ' Assistenza', ASSISTENZA: emoji.get('open_hands') + ' Assistenza',
@@ -75,8 +79,8 @@ const Menu = {
}; };
const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.INFO, Menu.ASSISTENZA]]; const MenuStandard = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA]];
const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.INFO, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]]; const MenuPerAdmin = [[Menu.LAVAGNA, Menu.LINK_CONDIVIDERE], [Menu.ZOOM, Menu.ASSISTENZA], [Menu.ADMIN, Menu.ALTRO]];
const MenuYesNo = [[Menu.SI, Menu.NO]]; const MenuYesNo = [[Menu.SI, Menu.NO]];
const MenuAdmin = [[Menu.MSGATUTTI, Menu.INDIETRO], ['', '']]; const MenuAdmin = [[Menu.MSGATUTTI, Menu.INDIETRO], ['', '']];
@@ -108,7 +112,7 @@ const txt = {
MSG_VERIFY_OK: emoji.get('grinning') + ' Benvenuto %s. Ora sei correttamente verificato!', MSG_VERIFY_OK: emoji.get('grinning') + ' Benvenuto %s. Ora sei correttamente verificato!',
MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi', MSG_ERR_UNKNOWN_VERIFY_CODE: 'Errore durante il salvataggio sul Server. Riprovare piú tardi',
MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.', MSG_EXIT_TELEGRAM: 'L\'account è stato ora scollegato da questo Telegram BOT.',
MSG_APORTADOR_USER_REGISTERED: emoji.get('heart_eyes') + ' Si è appena Registrato %s\n(Invitato da %s)', MSG_APORTADOR_USER_REGISTERED: emo.FIRE + ' Si è appena Registrato %s\n(Invitato da %s)',
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !', MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
}; };
@@ -246,6 +250,8 @@ class Telegram {
await this.menuAssistenza(msg) await this.menuAssistenza(msg)
} else if (msg.text === Menu.INFO) { } else if (msg.text === Menu.INFO) {
await this.menuInformazioni(msg) await this.menuInformazioni(msg)
} else if (msg.text === Menu.ZOOM) {
await this.menuZoom(msg)
} else { } else {
await this.msgScegliMenu(msg); await this.msgScegliMenu(msg);
} }
@@ -366,9 +372,56 @@ class Telegram {
await this.sendMsg(msg.chat.id, mystr); await this.sendMsg(msg.chat.id, mystr);
} }
async menuZoom(msg) {
let mystr = '';
const listazoom = await CalZoom.findAllIdApp(this.idapp);
const nextzoom = await CalZoom.getNextZoom(this.idapp);
mystr += emo.STARS + 'Zoom in programma:' + emo.STARS + '\n\n';
let index = 1;
listazoom.forEach((evento) => {
let iniziata = false;
if (nextzoom)
iniziata = (nextzoom._id.toString() === evento._id.toString());
if (iniziata) {
mystr += emo.CHECK_VERDE + ' QUESTA CONFERENZA E\' INIZIATA! ' + emo.CHECK_VERDE + '\n';
}
mystr += `${emo.EYES} ${tools.getstrDateTimeShort(evento.date_start)} ${emo.EYES}`;
mystr += `\n${evento.title}\n(${evento.note})\n\n`;
if (nextzoom) {
if (iniziata) {
mystr += emo.FIRE + 'CLICCA QUI PER ENTRARE ! ' + emo.FIRE + '\n';
mystr += tools.getlinkzoom(evento.id_conf_zoom) + '\n\n';
}
}
index++;
}
)
;
await
this
.sendMsg(msg
.chat
.id
,
mystr
)
;
}
async menuAdmin(msg) { async menuAdmin(msg) {
const mystr = 'scegli una voce:'; const mystr = 'scegli una voce:';
await this.sendMsg(msg.chat.id, mystr, MenuAdmin); await
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
} }
async menumsgAll(msg) { async menumsgAll(msg) {
@@ -376,7 +429,8 @@ class Telegram {
if (rec.user) { if (rec.user) {
const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:'; const mystr = 'Scrivi qui un Messaggio da inviare a TUTTI:';
rec.msgall_status = StatusMSGALL.ASK; rec.msgall_status = StatusMSGALL.ASK;
await this.sendMsg(msg.chat.id, mystr, MenuAdmin); await
this.sendMsg(msg.chat.id, mystr, MenuAdmin);
} }
} }
@@ -384,7 +438,8 @@ class Telegram {
const mytext = tools.get__('TESTO_ASSISTENZA', msg); const mytext = tools.get__('TESTO_ASSISTENZA', msg);
await this.sendMsg(msg.chat.id, mytext); await
this.sendMsg(msg.chat.id, mytext);
} }
existInMemory(msg) { existInMemory(msg) {
@@ -422,23 +477,29 @@ class Telegram {
rec.username_bo = text; rec.username_bo = text;
// Check if username exist // Check if username exist
const user = await User.findByUsername(this.idapp, rec.username_bo); const user = await
User.findByUsername(this.idapp, rec.username_bo);
if (!user) { if (!user) {
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND) await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND)
} else { } else {
rec.user = user; rec.user = user;
await User.SetTelegramCheckCode(this.idapp, rec.username_bo, rec.code); await
User.SetTelegramCheckCode(this.idapp, rec.username_bo, rec.code);
rec.status = Status.WAITFOR_VERIFY_CODE; rec.status = Status.WAITFOR_VERIFY_CODE;
await this.sendMsg(msg.from.id, txt.MSG_VERIFY_CODE) await
this.sendMsg(msg.from.id, txt.MSG_VERIFY_CODE)
} }
} }
} else if (text.length === 0) { } else if (text.length === 0) {
if (rec) if (rec)
rec.status = Status.NONE; rec.status = Status.NONE;
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA); await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
this.deleteRecInMem(msg) this.deleteRecInMem(msg)
} else { } else {
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME) await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME)
} }
} catch (e) { } catch (e) {
console.error('Error setUsernameBo:', e) console.error('Error setUsernameBo:', e)
@@ -448,20 +509,23 @@ class Telegram {
async setVerifyCode(msg) { async setVerifyCode(msg) {
try { try {
const rec = this.getRecInMem(msg); const rec = this.getRecInMem(msg);
const user = await User.findByUsername(this.idapp, rec.username_bo); const user = await
User.findByUsername(this.idapp, rec.username_bo);
const code = msg.text.toString().trim(); const code = msg.text.toString().trim();
let telegcode = 0; let telegcode = 0;
if (user) { if (user) {
telegcode = user.profile.teleg_checkcode.toString(); telegcode = user.profile.teleg_checkcode.toString();
} else { } else {
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND); await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_NOT_FOUND);
return return
} }
if (msg.text.length < 7) { if (msg.text.length < 7) {
if (rec) { if (rec) {
if (code === telegcode) { if (code === telegcode) {
rec.status = Status.VERIFIED; rec.status = Status.VERIFIED;
await User.SetTelegramIdSuccess(this.idapp, rec.username_bo, msg.from.id).then((recuser) => { await
User.SetTelegramIdSuccess(this.idapp, rec.username_bo, msg.from.id).then((recuser) => {
if (recuser) { if (recuser) {
let name = recuser.name; let name = recuser.name;
this.sendMsg(msg.from.id, printf(txt.MSG_VERIFY_OK, name)) this.sendMsg(msg.from.id, printf(txt.MSG_VERIFY_OK, name))
@@ -472,10 +536,12 @@ class Telegram {
} else { } else {
if (rec.retry < 2) { if (rec.retry < 2) {
rec.retry++; rec.retry++;
await this.sendMsg(msg.from.id, txt.MSG_ERR_VERIFY_CODE) await
this.sendMsg(msg.from.id, txt.MSG_ERR_VERIFY_CODE)
} else { } else {
rec.status = Status.NONE; rec.status = Status.NONE;
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA); await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA);
this.deleteRecInMem(msg); this.deleteRecInMem(msg);
} }
} }
@@ -483,9 +549,11 @@ class Telegram {
} else if (msg.text.length === 0) { } else if (msg.text.length === 0) {
if (rec) if (rec)
rec.status = Status.NONE; rec.status = Status.NONE;
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA) await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_USERNAME_ANNULLA)
} else { } else {
await this.sendMsg(msg.from.id, txt.MSG_ERRORE_VERIFY_CODE_MAXLEN) await
this.sendMsg(msg.from.id, txt.MSG_ERRORE_VERIFY_CODE_MAXLEN)
} }
} catch (e) { } catch (e) {
console.error('Error setVerifyCode', e); console.error('Error setVerifyCode', e);
@@ -495,18 +563,21 @@ class Telegram {
async sendMsgToAll(rec, msg, texttosend) { async sendMsgToAll(rec, msg, texttosend) {
if (texttosend.length < 3) { if (texttosend.length < 3) {
} else { } else {
const usersall = await User.getUsersTelegALL(rec.user.idapp); const usersall = await
User.getUsersTelegALL(rec.user.idapp);
let nummsgsent = 0; let nummsgsent = 0;
if (usersall) { if (usersall) {
for (const rec of usersall) { for (const rec of usersall) {
await this.sendMsg(rec.profile.teleg_id, texttosend); await
this.sendMsg(rec.profile.teleg_id, texttosend);
nummsgsent++; nummsgsent++;
} }
} }
await this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT)); await
this.sendMsg(msg.chat.id, nummsgsent + ' ' + getstr(msg.from.language_code, txt.MSG_MSG_SENT));
} }
rec.start_write_msgall = false; rec.start_write_msgall = false;
@@ -519,29 +590,35 @@ class Telegram {
async receiveMsg(msg) { async receiveMsg(msg) {
let status = this.getstatusInMemory(msg); let status = this.getstatusInMemory(msg);
if (status === Status.NONE) { if (status === Status.NONE) {
await this.start(msg); await
this.start(msg);
let status = this.getstatusInMemory(msg); let status = this.getstatusInMemory(msg);
if (status !== Status.VERIFIED) if (status !== Status.VERIFIED)
return return
} else { } else {
await this.setUser(msg) await
this.setUser(msg)
} }
const rec = this.getRecInMem(msg); const rec = this.getRecInMem(msg);
status = this.getstatus(rec); status = this.getstatus(rec);
if (status === Status.WAITFOR_USERNAME_BO && !this.selectMenuHelp(msg)) { if (status === Status.WAITFOR_USERNAME_BO && !this.selectMenuHelp(msg)) {
await this.setUsernameBo(msg) await
this.setUsernameBo(msg)
} else if (status === Status.WAITFOR_VERIFY_CODE) { } else if (status === Status.WAITFOR_VERIFY_CODE) {
await this.setVerifyCode(msg) await
this.setVerifyCode(msg)
} else if (status === Status.NONE) { } else if (status === Status.NONE) {
await this.start(msg); await
this.start(msg);
} else if (status === Status.VERIFIED) { } else if (status === Status.VERIFIED) {
let normale = true; let normale = true;
if (rec.msgall_status === StatusMSGALL.CONFIRM) { if (rec.msgall_status === StatusMSGALL.CONFIRM) {
if (msg.text === Menu.SI) { if (msg.text === Menu.SI) {
// Take msg to send to ALL // Take msg to send to ALL
await this.sendMsgToAll(rec, msg, rec.msgtosent) await
this.sendMsgToAll(rec, msg, rec.msgtosent)
} else { } else {
this.sendMsg(msg.chat.id, txt.MSG_OPERAZ_ANNULLATA); this.sendMsg(msg.chat.id, txt.MSG_OPERAZ_ANNULLATA);
} }
@@ -555,17 +632,20 @@ class Telegram {
this.ChiediSINO(msg, domanda); this.ChiediSINO(msg, domanda);
} else { } else {
rec.msgall_status = StatusMSGALL.NONE; rec.msgall_status = StatusMSGALL.NONE;
await this.msgScegliMenu(msg); await
this.msgScegliMenu(msg);
} }
normale = false normale = false
} }
if (normale) { if (normale) {
// Check Menu // Check Menu
await this.isMenu(rec, msg); await
this.isMenu(rec, msg);
} }
} else { } else {
await this.isMenuNotVerified(rec, msg); await
this.isMenuNotVerified(rec, msg);
} }
} }
@@ -573,9 +653,11 @@ class Telegram {
const rec = this.arrUsers.find((rec) => rec.id === msg.from.id); const rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
if (!rec) { if (!rec) {
await this.addUser(msg); await
this.addUser(msg);
await this.sendMsg(msg.chat.id, getstr(msg.from.language_code, txt.MSG_ASK_USERNAME_BO)); await
this.sendMsg(msg.chat.id, getstr(msg.from.language_code, txt.MSG_ASK_USERNAME_BO));
return false; return false;
} }
@@ -585,7 +667,8 @@ class Telegram {
async setUser(msg) { async setUser(msg) {
const id = msg.from.id; const id = msg.from.id;
const user = await User.UserByIdTelegram(this.idapp, id); const user = await
User.UserByIdTelegram(this.idapp, id);
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id); let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
if (user && rec) { if (user && rec) {
rec.user = user; rec.user = user;
@@ -597,7 +680,8 @@ class Telegram {
const id = msg.from.id; const id = msg.from.id;
let rec = null; let rec = null;
try { try {
const user = await User.UserByIdTelegram(this.idapp, id); const user = await
User.UserByIdTelegram(this.idapp, id);
let rec = this.arrUsers.find((rec) => rec.id === msg.from.id); let rec = this.arrUsers.find((rec) => rec.id === msg.from.id);
if (user && !rec) { if (user && !rec) {
rec = this.addUser(msg); rec = this.addUser(msg);
@@ -645,7 +729,8 @@ class Telegram {
async getKeyboard(id, menu) { async getKeyboard(id, menu) {
let keyb = MenuStandard; let keyb = MenuStandard;
// Check if you are Admin // Check if you are Admin
const ismanager = await User.isManagerByIdTeleg(this.idapp, id); const ismanager = await
User.isManagerByIdTeleg(this.idapp, id);
if (ismanager) if (ismanager)
keyb = MenuPerAdmin; keyb = MenuPerAdmin;
if (menu) { if (menu) {
@@ -664,7 +749,8 @@ class Telegram {
"resize_keyboard": true, "resize_keyboard": true,
"keyboard": await this.getKeyboard(id, menu) "keyboard": await this.getKeyboard(id, menu)
} }
}); })
;
} }
async msgBenvenuto(id) { async msgBenvenuto(id) {
@@ -674,7 +760,8 @@ class Telegram {
"resize_keyboard": true, "resize_keyboard": true,
"keyboard": await this.getKeyboard(id) "keyboard": await this.getKeyboard(id)
} }
}); })
;
} }
async ChiediSINO(msg, domanda) { async ChiediSINO(msg, domanda) {
@@ -695,7 +782,8 @@ class Telegram {
"resize_keyboard": true, "resize_keyboard": true,
"keyboard": await this.getKeyboard(msg.from.id) "keyboard": await this.getKeyboard(msg.from.id)
} }
}); })
;
} }
} }

View File

@@ -36,8 +36,6 @@ webpush.setVapidDetails(subject, publicVapidKey, privateVapidKey);
// console.log('setVapidDetails... config...'); // console.log('setVapidDetails... config...');
// To Translate! // To Translate!
textlang = { textlang = {
it: { it: {
@@ -117,7 +115,7 @@ module.exports = {
gettranslate(text, lang) { gettranslate(text, lang) {
try { try {
return textlang[lang][text] return textlang[lang][text]
}catch (e) { } catch (e) {
return textlang['it'][text] return textlang['it'][text]
} }
}, },
@@ -128,7 +126,7 @@ module.exports = {
lang = msg.from.language_code; lang = msg.from.language_code;
try { try {
return textlang[lang][text] return textlang[lang][text]
}catch (e) { } catch (e) {
return textlang['it'][text] return textlang['it'][text]
} }
}, },
@@ -138,7 +136,7 @@ module.exports = {
let lang = 'it'; let lang = 'it';
try { try {
return textlang[lang][text] return textlang[lang][text]
}catch (e) { } catch (e) {
return textlang['it'][text] return textlang['it'][text]
} }
}, },
@@ -649,6 +647,33 @@ module.exports = {
return mydate return mydate
}, },
appendLeadingZeroes(n) {
if (n <= 9) {
return "0" + n;
}
return n
},
getWeekDay(date) {
//Create an array containing each day, starting with Sunday.
const weekdays = [
"Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedí", "Venerdì", "Sabato"
];
//Use the getDay() method to get the day.
const day = date.getDay();
//Return the element that corresponds to that index.
return weekdays[day];
},
getstrDateTimeShort(mydate) {
// console.log('getstrDate', mytimestamp)
return this.getWeekDay(mydate) + ' ' + this.appendLeadingZeroes(mydate.getDate()) + '/' + this.appendLeadingZeroes(mydate.getMonth() + 1) + ' ORE ' + this.appendLeadingZeroes(mydate.getHours()) + ':' + this.appendLeadingZeroes(mydate.getMinutes());
},
getlinkzoom(idconf) {
return 'https://zoom.us/j/' + idconf
},
getmd5(mystr) { getmd5(mystr) {
return CryptoJS.MD5(mystr.toLowerCase()).toString(); return CryptoJS.MD5(mystr.toLowerCase()).toString();
}, },
@@ -786,7 +811,7 @@ module.exports = {
if (campi.length === 2) { if (campi.length === 2) {
namesurname.name = campi[0]; namesurname.name = campi[0];
namesurname.surname = campi[1]; namesurname.surname = campi[1];
}else if (campi.length === 3) { } else if (campi.length === 3) {
if (suffissoCognome.includes(campi[1])) { if (suffissoCognome.includes(campi[1])) {
namesurname.name = campi[0]; namesurname.name = campi[0];
namesurname.surname = campi[1] + " " + campi[2]; namesurname.surname = campi[1] + " " + campi[2];
@@ -794,10 +819,10 @@ module.exports = {
namesurname.name = campi[0] + " " + campi[1]; namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = campi[2]; namesurname.surname = campi[2];
} }
}else if (campi.length === 4) { } else if (campi.length === 4) {
namesurname.name = campi[0] + " " + campi[1]; namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = campi[2] + " " + campi[3]; namesurname.surname = campi[2] + " " + campi[3];
}else if (campi.length > 4) { } else if (campi.length > 4) {
namesurname.name = campi[0] + " " + campi[1]; namesurname.name = campi[0] + " " + campi[1];
namesurname.surname = " " + campi[2]; namesurname.surname = " " + campi[2];
for (let ind = 3; ind < campi.length; ind++) { for (let ind = 3; ind < campi.length; ind++) {