- Bot Telegram ...
This commit is contained in:
@@ -146,6 +146,9 @@ var UserSchema = new mongoose.Schema({
|
||||
teleg_checkcode: {
|
||||
type: Number
|
||||
},
|
||||
manage_telegram: {
|
||||
type: Boolean
|
||||
},
|
||||
dateofbirth: {
|
||||
type: Date,
|
||||
},
|
||||
@@ -207,15 +210,15 @@ UserSchema.statics.setPermissionsById = function (id, perm) {
|
||||
|
||||
UserSchema.statics.isAdmin = function (user) {
|
||||
try {
|
||||
return ((user.perm & shared_consts.Permissions.Admin) === shared_consts.Permissions.Admin);
|
||||
return ((perm & shared_consts.Permissions.Admin) === shared_consts.Permissions.Admin);
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
};
|
||||
|
||||
UserSchema.statics.isManager = function (user) {
|
||||
UserSchema.statics.isManager = function (perm) {
|
||||
try {
|
||||
return ((user.perm & shared_consts.Permissions.Manager) === shared_consts.Permissions.Manager);
|
||||
return ((perm & shared_consts.Permissions.Manager) === shared_consts.Permissions.Manager);
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
@@ -422,6 +425,17 @@ UserSchema.statics.UserByIdTelegram = async function (idapp, teleg_id) {
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.TelegIdByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, username }, {'profile.teleg_id': 1})
|
||||
.then((rec) => {
|
||||
return (!!rec) ? rec.profile.teleg_id : null;
|
||||
}).catch((e) => {
|
||||
console.error('TelegIdByUsername', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.SetTelegramCheckCode = async function (idapp, username, teleg_checkcode) {
|
||||
const User = this;
|
||||
|
||||
@@ -455,6 +469,29 @@ UserSchema.statics.SetTelegramIdSuccess = async function (idapp, username, teleg
|
||||
|
||||
};
|
||||
|
||||
UserSchema.statics.getNameSurnameByUsername = async function (idapp, username) {
|
||||
const User = this;
|
||||
|
||||
return await User.findOne({ idapp, username }, {name: 1, surname: 1})
|
||||
.then((rec) => {
|
||||
return (!!rec) ? `${rec.name} ${rec.surname}` : '';
|
||||
}).catch((e) => {
|
||||
console.error('getNameSurnameByUsername', e);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.getusersManagers = async function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return await User.find({ idapp, 'profile.manage_telegram': true }, {'profile.teleg_id': 1})
|
||||
.then((arrrec) => {
|
||||
return (!!arrrec) ? arrrec : null;
|
||||
}).catch((e) => {
|
||||
console.error('getusersManagers', e);
|
||||
});
|
||||
};
|
||||
|
||||
UserSchema.statics.getUsersList = function (idapp) {
|
||||
const User = this;
|
||||
@@ -474,6 +511,7 @@ UserSchema.statics.getUsersList = function (idapp) {
|
||||
};
|
||||
|
||||
|
||||
|
||||
UserSchema.statics.getUsersListByParams = function (params) {
|
||||
const User = this;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user