From f89281e3161aa06d2857ea83255a2b3ef37beb1c Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Sat, 2 Nov 2024 19:25:37 +0100 Subject: [PATCH] - ok --- src/server/models/sendnotif.js | 5 ++-- src/server/tools/general.js | 44 +++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/server/models/sendnotif.js b/src/server/models/sendnotif.js index e1d9cb5..fcc95b3 100755 --- a/src/server/models/sendnotif.js +++ b/src/server/models/sendnotif.js @@ -247,7 +247,8 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us recnotif.openUrl = shared_consts.getDirectoryByTable(shared_consts.TABLES_MYBACHECAS, true) + myidrec; tag = 'newevent'; if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_NEW_REC) { - let eventobj = await tools.getEventForTelegram(recnotif.myrectableorig, mydescr, userorig); + // let eventobj = await tools.getEventForTelegram(recnotif.myrectableorig, mydescr, userorig); + let eventobj = await tools.getAnnuncioForTelegram(recnotif.myrectableorig, shared_consts.TABLES_MYBACHECAS, mydescr, userorig, true); newdescr = eventobj.newdescr; newdescrtelegram = eventobj.newdescrtelegram; } else if (recnotif.typeid === shared_consts.TypeNotifs.ID_EVENTS_SEND_MSG) { @@ -266,7 +267,7 @@ sendNotifSchema.statics.getDescrAndLinkByRecNotif = async function (recnotif, us } recnotif.textcontent_Telegram = newdescrtelegram; - recnotif.linkaddTelegram = i18n.__('SHOW_POST'); + // recnotif.linkaddTelegram = i18n.__('SHOW_POST'); } else if (recnotif.typedir === shared_consts.TypeNotifs.TYPEDIR_FRIENDS) { recnotif.openUrl = '/my/' + sender; diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 1b68422..c16a515 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -3800,8 +3800,8 @@ module.exports = { }, - getmd5(mystr) { - return CryptoJS.MD5(mystr ? mystr.toLowerCase(): '').toString(); + getmd5(mystr) { + return CryptoJS.MD5(mystr ? mystr.toLowerCase() : '').toString(); }, getHash(mystr) { @@ -4639,7 +4639,7 @@ module.exports = { } else if (paramstr === 'DESCRIZ') { description = value; } else if (paramstr === 'SOCK') { - sock = (value ? (value.toLowerCase() === 'true'): false); + sock = (value ? (value.toLowerCase() === 'true') : false); } } @@ -5252,7 +5252,7 @@ module.exports = { let status = ''; let online = false; let solo_online = false; - let writtenby = myrec.username; + let writtenby = myrec.profile.username_telegram; let sitoweb = ''; let contact_phone = ''; let contact_email = ''; @@ -5273,13 +5273,18 @@ module.exports = { if (myrec.website) { sitoweb = myrec.website } - + contact_phone = myrec.contact_phone || ''; contact_email = myrec.contact_email || ''; if (myrec.organisedBy) { organizedBy = myrec.organisedBy; contatto = ''; + } else { + if (myrec.mygrp && myrec.mygrp.title) { + organizedBy = myrec.mygrp.title; + contatto = ''; + } } if ((myrec.contact_telegram && myrec.contact_telegram.toLowerCase() !== contatto_telegram.toLowerCase()) || !contatto) { contatto += '\n' + myrec.contact_telegram; @@ -5299,7 +5304,7 @@ module.exports = { out += `${myrec.descr}\n\n`; if (datastr) - out += this.addRowTelegram('๐Ÿ—“', 'Data Evento', datastr, true); + out += this.addRowTelegram('โœจ', 'Data Evento', datastr, true); if (cat) out += this.addRowTelegram('โญ๏ธ', 'Categoria', cat, true); @@ -5324,24 +5329,25 @@ module.exports = { if (incambiodi) out += this.addRowTelegram('โš–๏ธ', 'In cambio di', incambiodi, true); - if (sitoweb) - out += this.addRowTelegram('๐ŸŒ', 'Sito Web', sitoweb, true); + if (organizedBy) { + out += this.addRowTelegram('๐Ÿ ', 'Organizzato da', organizedBy, true); + } else { + out += this.addRowTelegram('๐Ÿ‘ค', 'Contatto', contatto, true); + } if (contributo) out += this.addRowTelegram('๐Ÿ’ฐ', 'Contributo Richiesto', contributo, true); - if (contact_phone) { - out += this.addRowTelegram('๐Ÿ“ž', 'Telefono', contact_phone, true); - } - if (contact_email) { - out += this.addRowTelegram('๐Ÿ“จ', 'Email', contact_email, true); + if (contact_phone || contact_email || sitoweb) { + out += this.addRowTelegram('โ„น๏ธ', 'Info', + (contact_phone ? ('๐Ÿ“ž ' + contact_phone + ' ') : '') + + (contact_email ? (' ๐Ÿ“จ ' + contact_email + ' ') : '') + + (sitoweb ? (' ๐ŸŒ ' + sitoweb + ' ') : '') + , true); } - if (organizedBy) { - out += this.addRowTelegram('๐Ÿ ', 'Organizzato da', organizedBy, true); - out += this.addRowTelegram('โœ๏ธ', 'Redatto da', writtenby, true); - } else { - out += this.addRowTelegram('๐Ÿ‘ค', 'Contatto', contatto, true); + if (writtenby && organizedBy) { + out += this.addRowTelegram('โœ๏ธ', 'Redatto da', '@' + writtenby, true); } out += this.addRowTelegram('', `๐Ÿ‘‰๐Ÿป Vedi Annuncio completo su RISO`, url, true, true); @@ -5801,7 +5807,7 @@ module.exports = { } if (myurl.startsWith('http://127.0.0.1')) { //myurl = myurl.replace('http://127.0.0.1:8084/', 'https://riso.app/') - + // Se รจ in locale allora metti una foto finta... myurl = 'https://images.unsplash.com/photo-1464047736614-af63643285bf?q=80&w=2874&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D' //myurl = myurl.replace('http://127.0.0.1', 'http://localhost')