- Versione 1.0.28
- Bottone "Condividi" permette di creare un post Telegram con l'annuncio selezionato. - migliorata grafica dell'annuncio.
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
{
|
{
|
||||||
"Hello": "Ciao",
|
"Hello": "Ciao",
|
||||||
"Hello %s": "Ciao %s",
|
"Hello %s": "Ciao %s",
|
||||||
|
"Good": "Bene",
|
||||||
|
"Service": "Servizio",
|
||||||
|
"Hosp": "Ospitalità",
|
||||||
"Good: %s": "Bene: %s",
|
"Good: %s": "Bene: %s",
|
||||||
"Service: %s": "Servizio: %s",
|
"Service: %s": "Servizio: %s",
|
||||||
"NEW_GOOD": "❇️ <strong>%s</strong> ha aggiunto un nuovo Bene: \n<strong>%s</strong>",
|
"Hosp: %s": "Ospitalità: %s",
|
||||||
"NEW_SERVICE": "❇️ <strong>%s</strong> ha aggiunto un nuovo Servizio: \n<strong>%s</strong>",
|
|
||||||
"NEW_HOSP": "❇️ <strong>%s</strong> ha aggiunto una nuova Ospitalità: \n<strong>%s</strong>",
|
|
||||||
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
|
"NEW_EVENT": "❇️ <strong>%s</strong> ha aggiunto un nuovo Evento: \n%s\n<strong>%s</strong>\n%s",
|
||||||
"NEW_EVENT_TELEGRAM": "%s\n\n❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
"NEW_EVENT_TELEGRAM": "%s\n\n❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
||||||
"NEW_ANNUNCIO_TELEGRAM": "❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
"NEW_ANNUNCIO_TELEGRAM": "❇️ <strong>%s</strong>\n\n%s\n\n%s",
|
||||||
@@ -115,5 +116,6 @@
|
|||||||
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
|
"🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!": "🚫 Hai rifiutato l'accesso alla App di RISO da parte di %s!",
|
||||||
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
|
"🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.": "🚫 Ti è stato rifiutato l'accesso. Probabilmente l'username con cui ti sei registrato non ti conosce. (%s) !<br>Contatta l'Assistenza Tecnica.",
|
||||||
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
|
"🚫 %s ha rifiutato l'accesso alla App a %s !": "🚫 %s ha rifiutato l'accesso alla App a %s !",
|
||||||
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !"
|
"✅ Hai Abilitato l'accesso alla App a %s !": "✅ Hai Abilitato l'accesso alla App a %s !",
|
||||||
|
"Good %s": "Good %s"
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ ContribtypeSchema.statics.findAllIdApp = async function (idapp) {
|
|||||||
|
|
||||||
return await Contribtype.find(myfind, (err, arrrec) => {
|
return await Contribtype.find(myfind, (err, arrrec) => {
|
||||||
return arrrec
|
return arrrec
|
||||||
});
|
}).lean();
|
||||||
};
|
};
|
||||||
|
|
||||||
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
|
const Contribtype = mongoose.model('Contribtype', ContribtypeSchema);
|
||||||
|
|||||||
@@ -204,20 +204,24 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA) {
|
if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_BACHECA) {
|
||||||
|
let tablerec = '';
|
||||||
if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
|
if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
|
||||||
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
|
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
|
||||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGOODS, true) + myidrec;
|
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYGOODS, true) + myidrec;
|
||||||
tag = 'newgood';
|
tag = 'newgood';
|
||||||
|
tablerec = 'mygoods';
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
|
||||||
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
|
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
|
||||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYSKILLS, true) + myidrec;
|
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYSKILLS, true) + myidrec;
|
||||||
tag = 'newservice';
|
tag = 'newservice';
|
||||||
|
tablerec = 'myskills';
|
||||||
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP) {
|
} else if (recnotif.typeid === shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP) {
|
||||||
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
|
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
|
||||||
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYHOSPS, true) + myidrec;
|
||||||
tag = 'newhosp';
|
tag = 'newhosp';
|
||||||
|
tablerec = 'myhosps';
|
||||||
}
|
}
|
||||||
let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, mydescr, userorig);
|
let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, tablerec, mydescr, userorig, true);
|
||||||
newdescr = eventobj.newdescr;
|
newdescr = eventobj.newdescr;
|
||||||
recnotif.textcontent_Telegram = eventobj.newdescrtelegram;
|
recnotif.textcontent_Telegram = eventobj.newdescrtelegram;
|
||||||
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
|
recnotif.linkaddTelegram = i18n.__('SHOW_POST');
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ const appTelegram_DEVELOP = [tools.RISO];
|
|||||||
const appTelegramFinti = ['2', tools.CNM];
|
const appTelegramFinti = ['2', tools.CNM];
|
||||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||||
|
|
||||||
|
|
||||||
|
const appTeleg_BotOnGroup = [tools.IDAPP_BOTONGROUP];
|
||||||
|
|
||||||
//PIPPO
|
//PIPPO
|
||||||
|
|
||||||
const printf = require('util').format;
|
const printf = require('util').format;
|
||||||
@@ -722,7 +725,7 @@ const MyTelegramBot = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return arrTeleg;
|
return arrTeleg;
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -1350,6 +1353,25 @@ const MyTelegramBot = {
|
|||||||
invia = true;
|
invia = true;
|
||||||
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_TEXT) {
|
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_TEXT) {
|
||||||
invia = !!params.content;
|
invia = !!params.content;
|
||||||
|
} else if (params.cmd === shared_consts.MsgTeleg.SHARE_ANNUNCIO) {
|
||||||
|
const mytable = globalTables.getTableByTableName(params.tablerec);
|
||||||
|
|
||||||
|
if (params.idrec && params.idrec !== '0') {
|
||||||
|
// const myrectableorig = await mytable.findOne({ _id: myrecnotifpass.idrec }).lean();
|
||||||
|
const myrectableorig = await mytable.getCompleteRecord(params.idapp, params.idrec);
|
||||||
|
|
||||||
|
if (myrectableorig) {
|
||||||
|
const eventobj = await tools.getAnnuncioForTelegram(myrectableorig, params.tablerec, '', user.username, false);
|
||||||
|
if (eventobj) {
|
||||||
|
params.textcontent_Telegram = eventobj.newdescrtelegram;
|
||||||
|
params.typesend = shared_consts.TypeSend.TELEGRAM;
|
||||||
|
//const rismsg =
|
||||||
|
params.content = eventobj.newdescr;
|
||||||
|
params.title = '';
|
||||||
|
invia = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tipomsgtempl > 0) {
|
if (tipomsgtempl > 0) {
|
||||||
@@ -4089,6 +4111,17 @@ function getclTelegBytoken(token) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Funzione per ottenere il nome del gruppo
|
||||||
|
async function getGroupName(bot, groupId) {
|
||||||
|
try {
|
||||||
|
const chat = await bot.getChat(groupId);
|
||||||
|
return chat.title;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Errore durante l\'ottenimento del nome del gruppo:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getclTelegByidapp(idapp) {
|
function getclTelegByidapp(idapp) {
|
||||||
// ****************************
|
// ****************************
|
||||||
if (appTelegramFinti.includes(idapp)) {
|
if (appTelegramFinti.includes(idapp)) {
|
||||||
@@ -4112,6 +4145,81 @@ if (true) {
|
|||||||
|
|
||||||
internetAvailable().then(() => {
|
internetAvailable().then(() => {
|
||||||
// ..
|
// ..
|
||||||
|
|
||||||
|
if (appTeleg_BotOnGroup.length > 0) {
|
||||||
|
console.log('TELEGRAM BOT GROUP .... ');
|
||||||
|
|
||||||
|
for (const idapp of appTeleg_BotOnGroup) {
|
||||||
|
|
||||||
|
const token = tools.getTelegramKeyByIdApp(idapp);
|
||||||
|
const nomebot = tools.getTelegramBotNameByIdApp(idapp);
|
||||||
|
|
||||||
|
if (token && nomebot) {
|
||||||
|
const bot = new TelegramBot(token, { polling: true });
|
||||||
|
|
||||||
|
// Gestisce il comando /start
|
||||||
|
bot.onText(/\/start/, (msg) => {
|
||||||
|
console.log('START BOT GROUP ... ');
|
||||||
|
/*
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
const message = 'Benvenuto! Usa il comando /request per inviare una richiesta di accesso al gruppo.';
|
||||||
|
bot.sendMessage(chatId, message);
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.onText(/\/request/, (msg) => {
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
const fromId = msg.from.id;
|
||||||
|
const fromUsername = msg.from.username;
|
||||||
|
|
||||||
|
const groupId = chatId;
|
||||||
|
|
||||||
|
if (chatId == groupId) {
|
||||||
|
const message = `Richiesta di accesso al gruppo da parte di ${msg.from.first_name} ${msg.from.last_name} (@${fromUsername})`;
|
||||||
|
bot.sendMessage(groupId, message);
|
||||||
|
} else {
|
||||||
|
console.log('Comando /request ricevuto in una chat privata.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.on('text', (msg) => {
|
||||||
|
console.log('TEXT...');
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
const userName = msg.from.username || msg.from.first_name;
|
||||||
|
const userId = msg.from.id;
|
||||||
|
});
|
||||||
|
|
||||||
|
bot.on('new_chat_members', async (msg) => {
|
||||||
|
const chatId = msg.chat.id;
|
||||||
|
const newMembers = msg.new_chat_members;
|
||||||
|
|
||||||
|
const groupId = chatId;
|
||||||
|
|
||||||
|
const nomegruppo = await getGroupName(bot, groupId);
|
||||||
|
|
||||||
|
// Ottiene la lista degli amministratori del gruppo
|
||||||
|
const admins = await bot.getChatAdministrators(chatId);
|
||||||
|
|
||||||
|
// Trova l'ID dell'amministratore del gruppo
|
||||||
|
const adminId = admins.find(admin => admin.status === 'administrator').user.id;
|
||||||
|
|
||||||
|
// Verifica se il nuovo membro è stato aggiunto al gruppo
|
||||||
|
if (chatId == groupId) {
|
||||||
|
newMembers.forEach(async (member) => {
|
||||||
|
|
||||||
|
//const message = `🔑 Nuova Richiesta di accesso al gruppo ${nomegruppo} da parte di ${member.username} (` + member.first_name + ' ' + member.last_name + ')';
|
||||||
|
const message = `Benvenuto/a ${member.first_name} (${member.username}) sul gruppo "${nomegruppo}" !`;
|
||||||
|
bot.sendMessage(adminId, message);
|
||||||
|
|
||||||
|
// bot.sendMessage(groupId, message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log('TELEGRAM STARTING.... ', process.env.NODE_ENV);
|
console.log('TELEGRAM STARTING.... ', process.env.NODE_ENV);
|
||||||
|
|
||||||
for (const idapp of arrTeleg) {
|
for (const idapp of arrTeleg) {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ const shared_consts = require('./shared_nodejs');
|
|||||||
const mongoose = require('mongoose').set('debug', false);
|
const mongoose = require('mongoose').set('debug', false);
|
||||||
const Subscription = require('../models/subscribers');
|
const Subscription = require('../models/subscribers');
|
||||||
|
|
||||||
|
const { Contribtype } = require('../models/contribtype');
|
||||||
|
const { Skill } = require('../models/skill');
|
||||||
|
const { Good } = require('../models/good');
|
||||||
|
const { SectorGood } = require('../models/sectorgood');
|
||||||
|
|
||||||
const server_constants = require('./server_constants');
|
const server_constants = require('./server_constants');
|
||||||
|
|
||||||
const download = require('image-downloader');
|
const download = require('image-downloader');
|
||||||
@@ -29,6 +34,7 @@ const download = require('image-downloader');
|
|||||||
const webpush = require('web-push');
|
const webpush = require('web-push');
|
||||||
|
|
||||||
const i18n = require('i18n');
|
const i18n = require('i18n');
|
||||||
|
const { StatusSkill } = require('../models/statusSkill');
|
||||||
|
|
||||||
|
|
||||||
const FILELOG = 'filelog.txt';
|
const FILELOG = 'filelog.txt';
|
||||||
@@ -418,6 +424,8 @@ module.exports = {
|
|||||||
FIOREDELLAVITA: '15',
|
FIOREDELLAVITA: '15',
|
||||||
PIUCHEBUONO: '17',
|
PIUCHEBUONO: '17',
|
||||||
|
|
||||||
|
IDAPP_BOTONGROUP: '1000',
|
||||||
|
|
||||||
HELP_CHAT: '',
|
HELP_CHAT: '',
|
||||||
TYPECONF_ZOOM: 'zoom',
|
TYPECONF_ZOOM: 'zoom',
|
||||||
TYPECONF_JITSI: 'jitsi',
|
TYPECONF_JITSI: 'jitsi',
|
||||||
@@ -2904,7 +2912,7 @@ module.exports = {
|
|||||||
$match: {
|
$match: {
|
||||||
$or: [
|
$or: [
|
||||||
{ $and: params.filtersearch3and },
|
{ $and: params.filtersearch3and },
|
||||||
{ idStatusSkill: { $in: [2]} }
|
{ idStatusSkill: { $in: [2] } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -4238,13 +4246,22 @@ module.exports = {
|
|||||||
return myval.charAt(0).toUpperCase() + myval.slice(1);
|
return myval.charAt(0).toUpperCase() + myval.slice(1);
|
||||||
},
|
},
|
||||||
|
|
||||||
firstchars(value, numchars = 200) {
|
firstchars(value, numchars = 200, continua, link) {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let mycar = value.substring(0, numchars);
|
let mycar = value.substring(0, numchars);
|
||||||
if (value.length > numchars) mycar += '...';
|
if (value.length > numchars) {
|
||||||
|
if (continua) {
|
||||||
|
if (link)
|
||||||
|
mycar += `<em> (... <a href="${link}">continua sulla App</a>)</em>`;
|
||||||
|
else
|
||||||
|
mycar += `<em> (... continua sulla App)</em>`;
|
||||||
|
} else {
|
||||||
|
mycar += ' ...';
|
||||||
|
}
|
||||||
|
}
|
||||||
return mycar;
|
return mycar;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return value;
|
return value;
|
||||||
@@ -4307,21 +4324,6 @@ module.exports = {
|
|||||||
return `<a href='${link}'>${username}</a>`;
|
return `<a href='${link}'>${username}</a>`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
firstchars(value, numchars) {
|
|
||||||
if (!value) {
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
let mycar = value.substring(0, numchars)
|
|
||||||
if (value.length > numchars)
|
|
||||||
mycar += '...'
|
|
||||||
return mycar
|
|
||||||
} catch (e) {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
replaceStringAtEnd(inputString, searchString, replacement) {
|
replaceStringAtEnd(inputString, searchString, replacement) {
|
||||||
// Create a regular expression that matches the searchString at the end of the inputString
|
// Create a regular expression that matches the searchString at the end of the inputString
|
||||||
const regex = new RegExp(searchString + '$');
|
const regex = new RegExp(searchString + '$');
|
||||||
@@ -4390,26 +4392,244 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async getAnnuncioForTelegram(myrec, mydescr, userorig) {
|
addRowTelegram(icon, title, content, acapo, islink) {
|
||||||
|
let mystr = '';
|
||||||
|
|
||||||
|
let descrcontent = content;
|
||||||
|
if (islink) {
|
||||||
|
title = `<a href="${content}">${title}</a>`;
|
||||||
|
descrcontent = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
mystr += `${icon} <strong>${title}</strong> ${icon}\n`;
|
||||||
|
if (descrcontent) {
|
||||||
|
mystr += `${descrcontent}\n`;
|
||||||
|
|
||||||
|
if (acapo) {
|
||||||
|
mystr += `\n`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mystr;
|
||||||
|
},
|
||||||
|
|
||||||
|
async getInCambioDiByRec(myrec) {
|
||||||
|
const contribtype = await Contribtype.findAllIdApp(idapp);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let mystr = '';
|
||||||
|
for (const contribId of myrec.idContribType) {
|
||||||
|
const reccontr = contribtype.find((rec) => rec._id.toString() === contribId);
|
||||||
|
if (reccontr) {
|
||||||
|
if (mystr) {
|
||||||
|
mystr += ', ';
|
||||||
|
}
|
||||||
|
mystr += reccontr.label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mystr;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getStatusSkillByRec(myrec, onlyifNoDiPersona) {
|
||||||
|
const statusskill = await StatusSkill.findAllIdApp(idapp);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let mystr = '';
|
||||||
|
if (onlyifNoDiPersona) {
|
||||||
|
if ((myrec.idStatusSkill.length === 1) && (myrec.idStatusSkill[0] === shared_consts.STATUSSKILL_DI_PERSONA))
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
for (const status of myrec.idStatusSkill) {
|
||||||
|
const reccontr = statusskill.find((rec) => rec._id === status);
|
||||||
|
if (reccontr) {
|
||||||
|
if (mystr) {
|
||||||
|
mystr += ' e ';
|
||||||
|
}
|
||||||
|
mystr += reccontr.descr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mystr;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getIconByAdType(adType) {
|
||||||
|
if (adType === shared_consts.AdType.OFFRO)
|
||||||
|
return '🟢';
|
||||||
|
else if (adType === shared_consts.AdType.CERCO)
|
||||||
|
return '🔴';
|
||||||
|
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
|
||||||
|
async getCategoriaSkillByRec(myrec) {
|
||||||
|
const skillrec = await Skill.findAllIdApp(idapp);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let mystr = '';
|
||||||
|
const rec = skillrec.find((rec) => rec._id === myrec.idSkill);
|
||||||
|
if (rec) {
|
||||||
|
mystr += rec.descr;
|
||||||
|
}
|
||||||
|
return mystr;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getCategoriaGoodByRec(myrec) {
|
||||||
|
// const goodrec = await Good.findAllIdApp(idapp);
|
||||||
|
const secgoodrec = await SectorGood.findAllIdApp(idapp);
|
||||||
|
|
||||||
|
try {
|
||||||
|
let mystr = '';
|
||||||
|
const rec = secgoodrec.find((rec) => rec._id === myrec.idSectorGood);
|
||||||
|
// const rec = goodrec.find((rec) => rec._id === myrec.idSectorGood);
|
||||||
|
if (rec) {
|
||||||
|
mystr += rec.descr;
|
||||||
|
}
|
||||||
|
return mystr;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getComuniEProvinceByRec(myrec) {
|
||||||
|
try {
|
||||||
|
let mystr = '';
|
||||||
|
if (myrec.hasOwnProperty('mycities')) {
|
||||||
|
let ind = 0;
|
||||||
|
for (const city of myrec.mycities) {
|
||||||
|
if (ind > 0)
|
||||||
|
mystr += ', '
|
||||||
|
mystr += city.comune + ' (' + city.prov + ')';
|
||||||
|
ind++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mystr;
|
||||||
|
} catch (e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getAnnuncioForTelegram(myrec, tablerec, mydescr, userorig, nuovo) {
|
||||||
try {
|
try {
|
||||||
let dovestr = this.getDoveStrByEvent(myrec);
|
|
||||||
let descrestesa = await this.getDescrEstesaStrByEvent(myrec);
|
|
||||||
let contributo = myrec.contribstr;
|
|
||||||
|
|
||||||
let newdescr = '';
|
let newdescr = '';
|
||||||
|
|
||||||
if (myrec.adType === shared_consts.TypeNotifs.ID_BACHECA_NEW_GOOD) {
|
let out = '';
|
||||||
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
|
|
||||||
} else if (myrec.adType === shared_consts.TypeNotifs.ID_BACHECA_NEW_SERVICE) {
|
let tiposcambio = ''
|
||||||
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
|
let iconascambio = '🟢';
|
||||||
} else if (myrec.adType === shared_consts.TypeNotifs.ID_BACHECA_NEW_HOSP) {
|
|
||||||
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
|
let datastr = '';
|
||||||
|
let dovestr = '';
|
||||||
|
let organizedby = '';
|
||||||
|
let contributo = '';
|
||||||
|
|
||||||
|
if ((tablerec === shared_consts.TABLES_MYGOODS) || (tablerec === shared_consts.TABLES_MYSKILLS)) {
|
||||||
|
iconascambio = this.getIconByAdType(myrec.adType);
|
||||||
|
if (myrec.adType === shared_consts.AdType.OFFRO)
|
||||||
|
tiposcambio = 'Offro';
|
||||||
|
else if (myrec.adType === shared_consts.AdType.CERCO)
|
||||||
|
tiposcambio = 'Cerco';
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYHOSPS) {
|
||||||
|
tiposcambio = 'Offro ';
|
||||||
|
if (myrec.typeHosp === shared_consts.TYPEHOSP_OSPITALITA)
|
||||||
|
tiposcambio += 'Ospitalità';
|
||||||
|
else if (myrec.typeHosp === shared_consts.TYPEHOSP_SCAMBIOCASA)
|
||||||
|
tiposcambio += 'Scambio Casa';
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYBACHECAS) {
|
||||||
|
datastr = this.getstrDateTimeEvent(myrec);
|
||||||
|
organizedby = myrec.organisedBy;
|
||||||
|
contributo = myrec.contribstr;
|
||||||
}
|
}
|
||||||
let newdescrtelegram = i18n.__('NEW_ANNUNCIO_TELEGRAM', mydescr, dovestr, descrestesa, userorig);
|
|
||||||
|
|
||||||
newdescrtelegram += i18n.__('ADDED_FROM', userorig);
|
if (nuovo) {
|
||||||
|
if (tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
|
newdescr = i18n.__('NEW_GOOD', userorig, mydescr);
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYSKILLS) {
|
||||||
|
newdescr = i18n.__('NEW_SERVICE', userorig, mydescr);
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYHOSPS) {
|
||||||
|
newdescr = i18n.__('NEW_HOSP', userorig, mydescr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
|
newdescr = i18n.__('Good', userorig, mydescr);
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYSKILLS) {
|
||||||
|
newdescr = i18n.__('Service', userorig, mydescr);
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYHOSPS) {
|
||||||
|
newdescr = i18n.__('Hosp', userorig, mydescr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let cat = '';
|
||||||
|
let status = '';
|
||||||
|
let online = false;
|
||||||
|
let solo_online = false;
|
||||||
|
if (tablerec === shared_consts.TABLES_MYGOODS) {
|
||||||
|
cat = await this.getCategoriaGoodByRec(myrec)
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYSKILLS) {
|
||||||
|
cat = await this.getCategoriaSkillByRec(myrec)
|
||||||
|
online = myrec.idStatusSkill.findIndex((id) => id === shared_consts.STATUSSKILL_ONLINE) >= 0
|
||||||
|
solo_online = online && myrec.idStatusSkill.length === 1
|
||||||
|
status = await this.getStatusSkillByRec(myrec, true);
|
||||||
|
if (status) {
|
||||||
|
status = ' ' + status;
|
||||||
|
}
|
||||||
|
} else if (tablerec === shared_consts.TABLES_MYHOSPS) {
|
||||||
|
cat = '';
|
||||||
|
}
|
||||||
|
// let out = i18n.__('NEW_ANNUNCIO_TELEGRAM', mydescr, dovestr, descrestesa, userorig);
|
||||||
|
|
||||||
return { newdescr, newdescrtelegram }
|
if (tiposcambio)
|
||||||
|
out += this.addRowTelegram(iconascambio, tiposcambio + status, '', false);
|
||||||
|
|
||||||
|
const url = this.getHostByIdApp(myrec.idapp) + shared_consts.getDirectoryByTable(tablerec, true) + myrec._id;
|
||||||
|
|
||||||
|
out += `<strong>${myrec.descr}</strong>\n\n`;
|
||||||
|
|
||||||
|
if (datastr)
|
||||||
|
out += this.addRowTelegram('🗓', 'Data Evento', datastr, true);
|
||||||
|
|
||||||
|
if (cat)
|
||||||
|
out += this.addRowTelegram('⭐️', 'Categoria', cat, true);
|
||||||
|
|
||||||
|
let descrcontent = this.firstchars(this.removeLastSpaceAndACapo(myrec.note), 175, true, url);
|
||||||
|
|
||||||
|
if (descrcontent)
|
||||||
|
out += this.addRowTelegram('📝', 'Descrizione ' + newdescr, descrcontent, true);
|
||||||
|
|
||||||
|
const localita = this.getComuniEProvinceByRec(myrec);
|
||||||
|
|
||||||
|
if (!solo_online)
|
||||||
|
out += this.addRowTelegram('🏠', 'Località', localita, true);
|
||||||
|
|
||||||
|
const incambiodi = await this.getInCambioDiByRec(myrec);
|
||||||
|
if (incambiodi)
|
||||||
|
out += this.addRowTelegram('⚖️', 'In cambio di', incambiodi, true);
|
||||||
|
|
||||||
|
if (contributo)
|
||||||
|
out += this.addRowTelegram('💰', 'Contributo', contributo, true);
|
||||||
|
|
||||||
|
let contatto = userorig;
|
||||||
|
try {
|
||||||
|
let username_telegram = myrec.profile.username_telegram;
|
||||||
|
|
||||||
|
if (username_telegram)
|
||||||
|
contatto = `@${username_telegram}`;
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
out += this.addRowTelegram('👤', 'Contatto', contatto, true);
|
||||||
|
|
||||||
|
out += this.addRowTelegram('', `👉🏻 Vedi Annuncio completo su RISO`, url, true, true);
|
||||||
|
|
||||||
|
// out += i18n.__('ADDED_FROM', );
|
||||||
|
|
||||||
|
return { newdescr, newdescrtelegram: out }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error', e);
|
console.error('Error', e);
|
||||||
}
|
}
|
||||||
@@ -4534,5 +4754,22 @@ module.exports = {
|
|||||||
return inputString.replace(/[^\d.,]/g, '').replace(',', '.');
|
return inputString.replace(/[^\d.,]/g, '').replace(',', '.');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
removeLastSpaceAndACapo(miastr) {
|
||||||
|
miastr = miastr.trimRight().replace(/[\n\r]+$/, '');
|
||||||
|
// Rimuove eventuali '<br>' in fondo alla stringa
|
||||||
|
// Rimuove eventuali '<div><br></div>' in fondo alla stringa
|
||||||
|
miastr = miastr.replace(/<\/div>$/, '');
|
||||||
|
miastr = miastr.replace(/<\/div>$/, '');
|
||||||
|
miastr = miastr.replace(/<br>$/, '');
|
||||||
|
miastr = miastr.replace(/<div><br><\/div>$/, '');
|
||||||
|
miastr = miastr.replace(/<br>$/, '');
|
||||||
|
miastr = miastr.trimRight().replace(/[\n\r]+$/, '');
|
||||||
|
miastr = miastr.replace(/<div><br><\/div>$/, '');
|
||||||
|
miastr = miastr.replace(/<div>$/, '');
|
||||||
|
miastr = miastr.replace(/<br>$/, '');
|
||||||
|
miastr = miastr.replace(/<br>$/, '');
|
||||||
|
|
||||||
|
return miastr;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -347,6 +347,11 @@ module.exports = {
|
|||||||
OUT: 2,
|
OUT: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
AdType: {
|
||||||
|
OFFRO: 1,
|
||||||
|
CERCO: 2,
|
||||||
|
},
|
||||||
|
|
||||||
TypeCashStr: [
|
TypeCashStr: [
|
||||||
{
|
{
|
||||||
label: '[Nessuno]',
|
label: '[Nessuno]',
|
||||||
@@ -508,6 +513,7 @@ module.exports = {
|
|||||||
MsgTeleg: {
|
MsgTeleg: {
|
||||||
SHARE_MSGREG: 1,
|
SHARE_MSGREG: 1,
|
||||||
SHARE_TEXT: 2,
|
SHARE_TEXT: 2,
|
||||||
|
SHARE_ANNUNCIO: 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
TypeMsgTemplate: {
|
TypeMsgTemplate: {
|
||||||
@@ -874,6 +880,7 @@ module.exports = {
|
|||||||
|
|
||||||
getProjectForAll(proj_add, table) {
|
getProjectForAll(proj_add, table) {
|
||||||
let proj = {
|
let proj = {
|
||||||
|
idapp: 1,
|
||||||
idContribType: 1,
|
idContribType: 1,
|
||||||
idCity: 1,
|
idCity: 1,
|
||||||
pub_to_share: 1,
|
pub_to_share: 1,
|
||||||
@@ -1015,4 +1022,10 @@ module.exports = {
|
|||||||
|
|
||||||
MAX_QTA_PREORD: 5000,
|
MAX_QTA_PREORD: 5000,
|
||||||
|
|
||||||
|
STATUSSKILL_DI_PERSONA: 1,
|
||||||
|
STATUSSKILL_ONLINE: 2,
|
||||||
|
|
||||||
|
TYPEHOSP_SCAMBIOCASA: 1,
|
||||||
|
TYPEHOSP_OSPITALITA: 2,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user