correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle...
This commit is contained in:
@@ -2834,7 +2834,7 @@ UserSchema.statics.setCircuitCmd = async function (idapp, usernameOrig, circuitn
|
||||
}
|
||||
|
||||
outres.recnotif = await SendNotif.getRecNotif(extrarec.notifId);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp);
|
||||
outres.arrrecnotif = await SendNotif.findAllNotifByUsernameIdAndIdApp(username_action, extrarec.lastdr, idapp, shared_consts.LIMIT_NOTIF_FOR_USER);
|
||||
|
||||
} else {
|
||||
outres.cansend = false;
|
||||
@@ -3105,27 +3105,34 @@ UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
idapp,
|
||||
'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean().then((rec) => {
|
||||
}).lean().then(async (rec) => {
|
||||
if (!rec) {
|
||||
// Cerca se esiste in quello salvato in precedenza:
|
||||
const recold = await User.findOne({
|
||||
idapp,
|
||||
'profile.teleg_id_old': teleg_id
|
||||
}).lean();
|
||||
if (recold && recold.profile.teleg_id_old === teleg_id) {
|
||||
// Riaggiorna l'ID perché è ritornato sulla chat!
|
||||
await User.SetTelegramIdSuccess(idapp, recold._id, recold.profile.teleg_id_old);
|
||||
|
||||
rec = await User.findOne({
|
||||
idapp,
|
||||
'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
}
|
||||
|
||||
}
|
||||
return (!!rec) ? rec : null;
|
||||
}).catch((e) => {
|
||||
console.error('UserExistByIdTelegram', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.UsersByIdTelegram = async function (idapp, teleg_id) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({
|
||||
idapp, 'profile.teleg_id': teleg_id,
|
||||
$or: [{ deleted: { $exists: false } }, { deleted: { $exists: true, $eq: false } }],
|
||||
}).lean().then((rec) => {
|
||||
return (!!rec) ? rec : null;
|
||||
}).catch((e) => {
|
||||
console.error('UserExistByIdTelegram', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.setPicProfile = async function (idapp, username, imgpic) {
|
||||
const User = this;
|
||||
@@ -3291,7 +3298,9 @@ UserSchema.statics.SetTelegramWasBlocked = async function (idapp, teleg_id) {
|
||||
'profile.teleg_id': 0,
|
||||
};
|
||||
|
||||
if (tools.sulServer()) {
|
||||
|
||||
// if (tools.sulServer()) {
|
||||
if (true) {
|
||||
|
||||
const ris = await User.findOneAndUpdate({
|
||||
idapp,
|
||||
@@ -4889,7 +4898,7 @@ UserSchema.statics.addExtraInfo = async function (idapp, recUser, recUserSave, v
|
||||
{ deleted: { $exists: true, $eq: false } }],
|
||||
}).lean();
|
||||
|
||||
recUser.profile.reaction = await Reaction.find({idapp, username: recUser.username}).lean();
|
||||
recUser.profile.reaction = await Reaction.find({ idapp, username: recUser.username }).lean();
|
||||
|
||||
recUser.profile.manage_mygroups = listManageGroups
|
||||
? listManageGroups
|
||||
@@ -5003,9 +5012,18 @@ UserSchema.statics.moverecordsFavorite = async function (tab) {
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
console.log('fine moverecordsFavorite');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.removerecordsFavorite = async function () {
|
||||
// Rimuovi i record del vecchio schema
|
||||
const attivacanc = false;
|
||||
|
||||
const attivacanc = true;
|
||||
|
||||
if (attivacanc) {
|
||||
const queryfind = { idapp: '13' };
|
||||
await User.findOneAndUpdate(queryfind, {
|
||||
@@ -5019,12 +5037,6 @@ UserSchema.statics.moverecordsFavorite = async function (tab) {
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e.message);
|
||||
}
|
||||
|
||||
console.log('fine moverecordsFavorite');
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.updateVersion = async function (userversion, recUser) {
|
||||
|
||||
Reference in New Issue
Block a user