From d5bc76335f913acf127d6c4697578f8f60dd2a37 Mon Sep 17 00:00:00 2001 From: Surya Paolo Date: Wed, 6 Dec 2023 00:41:50 +0100 Subject: [PATCH] - Entri in Circuito Italia solo se hai il fido nel circuito provinciale - Aggiunta Zona, oltre alla provincia, per visualizzare i vari circuiti della prov --- src/server/locales/it.json | 20 ++++++++--------- src/server/models/account.js | 3 +-- src/server/models/circuit.js | 4 ++-- src/server/models/mygroup.js | 19 +++++++++++++++- src/server/models/user.js | 4 ++-- src/server/populate/provinces.js | 2 +- src/server/telegram/telegrambot.js | 35 ++++++++++++++++-------------- 7 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/server/locales/it.json b/src/server/locales/it.json index a33bbe5..adaef79 100644 --- a/src/server/locales/it.json +++ b/src/server/locales/it.json @@ -18,9 +18,9 @@ "%s refused your Friendship": "%s ha rifiutato l'Amicizia", "✅ %s accepted your Friendship request !": "✅ %s ha accettato la tua richiesta di Amicizia !", "✅ You have accepted %s' Friendship request!": "✅ Hai accettato la richiesta di Amicizia di %s !", - "HANDSHAKE_SET": "%s ha comunicato che ti conosce personalmente e ha fiducia in te.", - "HANDSHAKE_CONFIRMED": "🤝 Hai contraccambiato la fiducia in %s!", - "HANDSHAKE_ACCEPTED": "🤝 %s ha contraccambiato la stretta di mano (fiducia) !", + "HANDSHAKE_SET": "%s ha comunicato che ti conosce personalmente e ha fiducia in te (Stretta di mano).", + "HANDSHAKE_CONFIRMED": "🤝 Hai contraccambiato la stretta di mano di %s!", + "HANDSHAKE_ACCEPTED": "🤝 %s ha contraccambiato la stretta di mano !", "GROUPS_ACCEPTED": "✅ Sei stato accettato a far parte del Gruppo %s (da parte di %s)", "GROUPS_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del Gruppo %s. Se pensi sia un'errore, contatta l'amministratore del Gruppo.", "GROUPS_REMOVED": "❌ l'utente %s è stato rimosso del Gruppo %s (da parte di %s)", @@ -43,10 +43,10 @@ "FRIEND_UNBLOCKED_TO_ME": "Sei stato riattivato da %s", "FRIEND_UNBLOCKED": "E' stato riattivato %s da %s.", "FRIEND_UNBLOCKED_YOU": "Hai riattivato %s.", - "CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Abilita fido a %s nel '%s':", - "CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Abilita fido nel Circuito al gruppo %s:", + "CIRCUIT_ACCEPT_NEWENTRY": "❇️👥 🧍‍♂️ Abilita fiducia a %s nel '%s':", + "CIRCUIT_ACCEPT_NEWENTRY_BYGROUP": "❇️👥 🧍‍♂️ Abilita fiducia nel Circuito al gruppo %s:", "CIRCUIT_OPEN_RISITALIA": "Apri il Circuito RIS Italia e chiedi di entrare", - "CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato al Fido (è stato invitato da %s)", + "CIRCUIT_REQUEST_TO_ENTER": "%s è entrato nel %s (con %s iscritti) ed è in attesa di essere abilitato alla Fiducia\n🙎🏻‍♂️ Invitato da %s", "CIRCUIT_ADMINS": "Gli amministratori del circuito sono %s:\n%s", "CIRCUIT_WHERE_IS_PRESENT": "\nAttualmente è presente in: %s", "CIRCUIT_REQUEST_TO_ENTER_WITH_GROUP": "il gruppo %s ha chiesto di entrare nel %s (con %s iscritti)", @@ -58,12 +58,12 @@ "CIRCUIT_REMOVED_ADMIN_YOU": "%s ti è stato rimosso l'incarico di Amministratore del %s da parte di %s", "RICHIESTA_BLOCCO_CIRCUIT": "Richiesta di bloccare il %s da parte di %s", "CIRCUIT_ELIMINATO": "Il %s è stato eliminato da parte di %s", - "FIDO_IMPOSTATO_ADMINS_CIRCUIT": "✅ l'utente %s è stato abilitato al Fido (%s RIS) sul '%s' (da parte di %s)", - "FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato abilitato al Fido fino a -%s sul '%s' (da parte di %s)", + "FIDO_IMPOSTATO_ADMINS_CIRCUIT": "✅ l'utente %s è stato abilitato alla Fiducia (%s RIS) sul '%s' (da parte di %s)", + "FIDO_IMPOSTATO_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato abilitato alla Fiducia fino a -%s sul '%s' (da parte di %s)", "ACCETTATO_NOTIFICA_ADMINS_CIRCUIT": "✅ l'utente %s è stato accettato a far parte del '%s' (da parte di %s)", "ACCETTATO_NOTIFICA_ADMINS_CIRCUIT_MYGROUP": "✅ il Conto di Gruppo %s è stato accettato a far parte del '%s' (da parte di %s)", "CIRCUIT_ACCEPTED": "✅ Sei stato accettato da %s a far parte del %s.\nApri la APP e clicca in alto a destra sull'icona delle monete, oppure clicca qui: %s", - "FIDO_IMPOSTATO": "✅ Ti è stata attivata la possibilità di utilizzare il fido (Fiducia Concessa) fino a %s RIS da %s sul '%s'.", + "FIDO_IMPOSTATO": "✅ Ti è stata attivata la possibilità di utilizzare la Fiducia Concessa fino a %s RIS da %s sul '%s'.", "CIRCUIT_ACCEPTED_YOU": "✅ Hai accettato %s a far parte del '%s'", "CIRCUIT_REFUSED": "❌ Ti è stato rifiutato l'accesso da %s a far parte del '%s'. Se pensi sia un'errore, contatta l'amministratore del Circuito.", "CIRCUIT_REMOVED": "❌ l'utente %s è stato rimosso del %s (da parte di %s)", @@ -97,7 +97,7 @@ "STATUS_SENT": "Inviato", "STATUS_REFUSED": "Rifiutato", "SALDO_VARIATO": "[%s] l'utente %s ha variato il Saldo di %s da %s a %s %s", - "FIDOCONCESSO_VARIATO": "[%s] l'utente %s ha variato il Fido Concesso di %s da %s a %s %s", + "FIDOCONCESSO_VARIATO": "[%s] l'utente %s ha variato la Fiducia Concesso di %s da %s a %s %s", "QTAMAX_VARIATO": "[%s] l'utente %s ha variato la quantità massima concessa di %s da %s a %s %s", "SET_FAVORITE": "%s ha messo 'Mi Piace' al tuo post: %s", "SET_FAVORITE_OTHERS": "%s e altre %s persone hanno messo 'Mi Piace' al tuo post: %s", diff --git a/src/server/models/account.js b/src/server/models/account.js index bd60579..5e15e9f 100755 --- a/src/server/models/account.js +++ b/src/server/models/account.js @@ -725,9 +725,8 @@ AccountSchema.statics.removeAdminOfAccount = async function (idapp, username, ci // Rimuovi l'account AccountSchema.statics.removeAccount = async function (accountId) { - const { Circuit } = require('../models/circuit'); - return await Circuit.deleteOne({ _id: accountId}); + return await Account.deleteOne({ _id: accountId}); }; AccountSchema.statics.updateSaldoAndTransato_AllAccounts = async function (idapp) { diff --git a/src/server/models/circuit.js b/src/server/models/circuit.js index 9b18de6..eb75d88 100755 --- a/src/server/models/circuit.js +++ b/src/server/models/circuit.js @@ -1110,7 +1110,7 @@ CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, usernam if (account.groupname === '') { mystr += '\n👉🏻 ' + account.circuit.name + '\n'; mystr += ' [Saldo: ' + account.saldo + ' RIS, '; - mystr += ' Fido: ' + account.fidoConcesso + ' RIS, '; + mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, '; mystr += ' Transato: ' + account.totTransato + ' RIS]'; } } @@ -1121,7 +1121,7 @@ CircuitSchema.statics.getListCircuitsByUsername = async function (idapp, usernam if (myuser.profile.mycircuits.find((rec) => (rec.circuitname === account.circuit.name))) { mystr += '\n GRUPPO: 👉🏻 ' + account.groupname + ' in ' + account.circuit.name + '\n'; mystr += ' [Saldo: ' + account.saldo + ' RIS, '; - mystr += ' Fido: ' + account.fidoConcesso + ' RIS, '; + mystr += ' Fiducia: ' + account.fidoConcesso + ' RIS, '; mystr += ' Transato: ' + account.totTransato + ' RIS]'; } } diff --git a/src/server/models/mygroup.js b/src/server/models/mygroup.js index c656491..296d95b 100755 --- a/src/server/models/mygroup.js +++ b/src/server/models/mygroup.js @@ -507,9 +507,26 @@ MyGroupSchema.statics.addCircuitFromGroup = async function (idapp, groupname, ci // Rimuovo il Circuito all'interno del Gruppo MyGroupSchema.statics.removeCircuitFromGroup = async function (idapp, groupname, circuitname) { - return await this.updateOne({ idapp, groupname }, + + + const ris = await this.updateOne({ idapp, groupname }, { $pull: { 'mycircuits': { circuitname: { $in: [circuitname] } } } }); + const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname); + let remove = false; + + // Se il mio account non è stato utilizzato, allora lo cancello anche questo + const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, groupname, ''); + if (myaccount && myaccount.totTransato === 0) { + remove = true; + } else { + remove = true; + } + + if (remove) { + await Account.removeAccount(myaccount._id); + } + }; MyGroupSchema.statics.getQueryReceiveRISGroups = function (idapp, hours) { diff --git a/src/server/models/user.js b/src/server/models/user.js index 7b09af5..28fc87d 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -2085,8 +2085,8 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use if (value) { // Aggiungi alle amicizie - await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest, - shared_consts.FRIENDSCMD.SETFRIEND, value); + // await this.setFriendsCmd(req, idapp, usernameOrig, usernameDest, + // shared_consts.FRIENDSCMD.SETFRIEND, value); msgOrig = i18n.__({ phrase: '✅ Hai Abilitato l\'accesso alla App a %s !', locale: userDest.lang }, userDest.username); msgDest = i18n.__({ phrase: '✅ Sei stato Abilitato correttamente da %s!', locale: lang }, usernameOrig); diff --git a/src/server/populate/provinces.js b/src/server/populate/provinces.js index 655037e..91274c9 100644 --- a/src/server/populate/provinces.js +++ b/src/server/populate/provinces.js @@ -121,6 +121,6 @@ module.exports = { {_id: 119, reg: 'PUG', prov: 'VAL', descr: 'Valle D\'Itria', link_grp: 'https://t.me/progettoriso/7016?thread=7015', link_telegram: ''}, {_id: 120, reg: 'SAR', prov: 'SUS', descr: 'Sud Sardegna', link_grp: 'https://t.me/c/1614195634/552?thread=545', link_telegram: ''}, {_id: 121, reg: 'ITA', prov: 'ITA', descr: 'Italia', link_grp: '', link_telegram: ''}, - {_id: 122, reg: 'LOM', prov: 'MI', card: 'EST', descr: 'Milano Est', link_grp: '', link_telegram: ''}, + {_id: 122, reg: 'LOM', prov: 'MI', descr: 'Milano Est', card: 'EST', link_grp: '', link_telegram: ''}, ], }; diff --git a/src/server/telegram/telegrambot.js b/src/server/telegram/telegrambot.js index 2d005e5..1dfb32e 100755 --- a/src/server/telegram/telegrambot.js +++ b/src/server/telegram/telegrambot.js @@ -924,7 +924,7 @@ const MyTelegramBot = { keyb = cl.getInlineKeyboard(myuser.lang, [ { - text: '✅ Abilita fido a ' + groupname, + text: '✅ Abilita fiducia a ' + groupname, callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid + tools.SEP + groupname, }, @@ -942,7 +942,7 @@ const MyTelegramBot = { keyb = cl.getInlineKeyboard(myuser.lang, [ { - text: '✅ Abilita fido a ' + myuser.username, + text: '✅ Abilita fiducia a ' + myuser.username, callback_data: InlineConferma.RISPOSTA_SI + myfunc + tools.SEP + myuser.username + tools.SEP + '' + tools.SEP + '' + tools.SEP + groupid, }, @@ -3752,12 +3752,13 @@ class Telegram { if (!form) { form = { - 'parse_mode': opt && opt.parse_mode ? opt.parse_mode : 'HTML', - 'message_id': msg_id, - 'reply_markup': { - 'resize_keyboard': true, - 'keyboard': await this.getKeyboard(id, menu, mylang), - 'keyboard_inline': (opt && opt.keyboard_inline) ? opt.keyboard_inline : undefined, + parse_mode: opt && opt.parse_mode ? opt.parse_mode : 'HTML', + message_id: msg_id, + disable_web_page_preview: true, + reply_markup: { + resize_keyboard: true, + keyboard: await this.getKeyboard(id, menu, mylang), + keyboard_inline: (opt && opt.keyboard_inline) ? opt.keyboard_inline : undefined, }, }; } @@ -3980,10 +3981,11 @@ class Telegram { const lang = this.getlang(msg); this._inviaMsg(msg.from.id, domanda, { - 'reply_markup': { - 'resize_keyboard': true, - 'one_time_keyboard': true, - 'keyboard': this.getmenuKey(MenuYesNo, lang), + disable_web_page_preview: true, + reply_markup: { + resize_keyboard: true, + one_time_keyboard: true, + keyboard: this.getmenuKey(MenuYesNo, lang), }, }); } @@ -4005,10 +4007,11 @@ class Telegram { async msgScegliMenu(msg) { this._inviaMsg(msg.from.id, getstr(this.getlang(msg), 'MSG_SCEGLI_MENU'), { - 'parse_mode': 'HTML', - 'reply_markup': { - 'resize_keyboard': true, - 'keyboard': await this.getKeyboard(msg.from.id, undefined, + parse_mode: 'HTML', + disable_web_page_preview: true, + reply_markup: { + resize_keyboard: true, + keyboard: await this.getKeyboard(msg.from.id, undefined, this.getlang(msg)), }, });