Merge branch 'develop' of gitlab.com:surya89/freeplanet_serverside into develop

This commit is contained in:
Surya Paolo
2023-10-03 00:44:24 +02:00
2 changed files with 41 additions and 2 deletions

View File

@@ -25,14 +25,14 @@ const _ = require('lodash');
const reg = require('../reg/registration');
const { authenticate, authenticate_noerror } = require('../middleware/authenticate');
const { authenticate, authenticate_noerror, authenticate_noerror } = require('../middleware/authenticate');
const TypedError = require('../modules/ErrorHandler');
const globalTables = require('../tools/globalTables');
const mongoose = require('mongoose').set('debug', false);
router.post('/cmd', authenticate_noerror, async (req, res) => {
router.post('/cmd', authenticate_noerror_noerror, async (req, res) => {
const mydata = req.body.mydata;
const idapp = req.body.idapp;

View File

@@ -1554,6 +1554,40 @@ module.exports = {
},
htmlToTelegramText(html) {
try {
const withMarkdown = html
.replace(/<strong>(.*?)<\/strong>/g, '*$1*')
.replace(/<b>(.*?)<\/b>/g, '*$1*')
.replace(/<em>(.*?)<\/em>/g, '_$1_')
.replace(/<u>(.*?)<\/u>/g, '__$1__');
// Remove other HTML tags
const plainText = withMarkdown.replace(/<[^>]*>/g, '');
// Replace HTML entities with their equivalent Markdown or plain text representations
const replacements = [
{ pattern: /&amp;/g, replacement: '&' },
{ pattern: /&lt;/g, replacement: '<' },
{ pattern: /&gt;/g, replacement: '>' },
{ pattern: /&quot;/g, replacement: '"' },
{ pattern: /&#39;/g, replacement: "'" },
];
let telegramText = plainText;
replacements.forEach((replacement) => {
telegramText = telegramText.replace(replacement.pattern, replacement.replacement);
});
return telegramText;
} catch (e) {
console.error(e);
};
},
convertTexttoHtml(myhtml) {
// let msg = myhtml;
// msg = msg.replace('\n', '<br>');
@@ -2115,6 +2149,11 @@ module.exports = {
// query = {};
}
if (true) {
// RIMUOVI
// query = {};
}
if (Object.keys(query).length > 0) {
const numtabbacheca = this.getNumTabByTable(shared_consts.TABLES_MYBACHECAS);
if (numtab === numtabbacheca) {