piccole modifiche...

This commit is contained in:
Surya Paolo
2025-01-12 21:29:05 +01:00
parent c631ca9d6a
commit 45be5038b9
9 changed files with 15 additions and 34 deletions

View File

@@ -1107,7 +1107,7 @@ CircuitSchema.statics.getCircuitMyProvince = async function (idapp, username) {
CircuitSchema.statics.createCircuitIfNotExist = async function (req, idapp, province, card) {
const { User } = require('../models/user');
const useradmin = tools.USER_ADMIN_CIRCUITS;
const useradmin = shared_consts.USER_ADMIN_CIRCUITS;
let myrec = null;
try {

View File

@@ -409,7 +409,7 @@ module.exports.createFirstUserAdmin = async function () {
if (numusers === 0) {
// Non esistono utenti, quindi creo quello di Admin
const utenteadmin = { idapp: '13', username: telegrambot.ADMIN_USER_SERVER };
const utenteadmin = { idapp: '13', username: shared_consts.ADMIN_USER_SERVER };
const newuser = new User(utenteadmin);
newuser._id = new ObjectId();

View File

@@ -2653,10 +2653,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
if (usernameOrig !== shared_consts.ADMIN_USER_SERVER) {
// Send a notification to the Admin
await SendNotif.createNewNotifToSingleUser(req, null,
{ username_worked, usernameDest: telegrambot.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
{ username_worked, usernameDest: shared_consts.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_REPORTED);
}
@@ -2685,10 +2685,10 @@ UserSchema.statics.setFriendsCmd = async function (req, idapp, usernameOrig, use
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
if (usernameOrig !== telegrambot.ADMIN_USER_SERVER) {
if (usernameOrig !== shared_consts.ADMIN_USER_SERVER) {
// Send a notification to the Admin
await SendNotif.createNewNotifToSingleUser(req, null,
{ username_worked, usernameDest: telegrambot.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
{ username_worked, usernameDest: shared_consts.ADMIN_USER_SERVER, username_action, isAdmin: true }, false,
shared_consts.TypeNotifs.TYPEDIR_FRIENDS,
shared_consts.TypeNotifs.ID_FRIENDS_UNBLOCKED);
}
@@ -4085,22 +4085,6 @@ UserSchema.statics.isManagerByIdTeleg = async function (idapp, idtelegram) {
});
};
UserSchema.statics.isAdminByIdTeleg = async function (idapp, idtelegram) {
const User = this;
return await User.findOne({
idapp,
username: 'paoloar77',
'profile.admin_telegram': true,
'profile.teleg_id': idtelegram,
}, { 'profile.teleg_id': 1 }).then((rec) => {
return (!!rec && rec.profile.teleg_id === idtelegram);
}).catch((e) => {
console.error('getusersManagers', e);
return false;
});
};
UserSchema.statics.isAdminByUsername = async function (idapp, username) {
const User = this;