- fix: "Circuito RIS {nomecircuito}" uniformati tutti quanti.
- fix Strette di mano dicitura. - poter vedere e cliccare sul gruppo telegram della provincia (dalla lista dei circuiti).
This commit is contained in:
@@ -1712,13 +1712,15 @@ UserSchema.methods.removeToken = function (token) {
|
||||
});
|
||||
};
|
||||
|
||||
// # Rimuove tutti i tokens di tutti gli utenti con idapp
|
||||
// TODO: Cancellare i token che non hanno refreshToken, ad esempio quando l'utente esce dal browser
|
||||
// TODO: Cancellare i token con data_login meno di 2 giorni fa, per esempio se l'utente si è disconnesso dal browser ma è ancora online
|
||||
|
||||
UserSchema.statics.SvuotaTuttiGliAccessiOnlineConToken = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.updateMany({ idapp },
|
||||
{ $set: { tokens: [] } });
|
||||
};
|
||||
{ $pull: { tokens: { refreshToken: { $exists: false } } } });
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.getEmailByUsername = async function (idapp, username) {
|
||||
@@ -1782,7 +1784,7 @@ UserSchema.statics.getUserByUsername = function (idapp, username) {
|
||||
UserSchema.statics.getUserByUsernameTelegram = function (idapp, username_telegram) {
|
||||
const User = this;
|
||||
|
||||
if (username_telegram[0] === '@'){
|
||||
if (username_telegram[0] === '@') {
|
||||
username_telegram = username_telegram.substring(1);
|
||||
}
|
||||
|
||||
@@ -2162,6 +2164,14 @@ UserSchema.statics.removeFromCircuits = async function (idapp, username, circuit
|
||||
const circuitId = await Circuit.getCircuitIdByName(idapp, circuitname);
|
||||
let remove = false;
|
||||
|
||||
const circuit = await Circuit.findOne({ idapp, name: circuitname }).lean();
|
||||
if (circuit) {
|
||||
// Invio la notifica agli amministratori del circuito
|
||||
const title = `L\'utente ${username} è uscito dal ${circuitname}`;
|
||||
const msg = ``;
|
||||
await tools.sendNotifToCircuitsAdmin(idapp, circuit, true, title, msg, '')
|
||||
}
|
||||
|
||||
// Se il mio account non è stato utilizzato, allora lo cancello anche questo
|
||||
const myaccount = await Account.getAccountByUsernameAndCircuitId(idapp, username, circuitId, false, false, '', '');
|
||||
if (myaccount && myaccount.totTransato === 0) {
|
||||
@@ -2460,6 +2470,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const already_stretta = await User.isMyHandShake(idapp, usernameDest, usernameOrig);
|
||||
const already_stretta_orig = await User.isMyHandShake(idapp, usernameOrig, usernameDest);
|
||||
|
||||
rec = await User.updateOne({ idapp, username: usernameDest }, update);
|
||||
|
||||
tools.sendNotificationByUsername(idapp, usernameDest, cmd, true, usernameOrig);
|
||||
@@ -2470,8 +2484,11 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
|
||||
if (!disablenotif) {
|
||||
const userDest = await User.getRecLangAndIdByUsername(idapp, usernameDest);
|
||||
const user = await User.getRecLangAndIdByUsername(idapp, usernameOrig);
|
||||
const already_stretta = await User.isMyHandShake(idapp, usernameDest, usernameOrig);
|
||||
const msgDest = i18n.__({ phrase: 'HANDSHAKE_CONFIRMED', locale: userDest.lang }, usernameDest);
|
||||
|
||||
let msgDest = i18n.__({ phrase: 'HANDSHAKE_SENT_FROM_YOU', locale: userDest.lang }, usernameDest);
|
||||
if (already_stretta)
|
||||
msgDest = i18n.__({ phrase: 'HANDSHAKE_CONFIRMED', locale: userDest.lang }, usernameDest);
|
||||
|
||||
let phrase = 'HANDSHAKE_SET';
|
||||
if (already_stretta) {
|
||||
phrase = 'HANDSHAKE_ACCEPTED';
|
||||
@@ -5786,6 +5803,12 @@ UserSchema.statics.addNewSite = async function (idappPass, body) {
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.renameCircuitName = async function (idapp, oldcircuitname, newcircuitname) {
|
||||
const User = this;
|
||||
|
||||
return await User.updateMany({ idapp, 'profile.mycircuits.circuitname': oldcircuitname }, { $set: { 'profile.mycircuits.$.circuitname': newcircuitname } });
|
||||
};
|
||||
|
||||
UserSchema.statics.createNewSubRecord = async function (idapp, req) {
|
||||
const User = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user