- menu BOT
- verified_by_aportador
This commit is contained in:
73
src/server/models/bot.js
Executable file
73
src/server/models/bot.js
Executable file
@@ -0,0 +1,73 @@
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = 'F';
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true;
|
||||
});
|
||||
|
||||
const BotSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
page: {
|
||||
type: Number,
|
||||
},
|
||||
index: {
|
||||
type: Number,
|
||||
},
|
||||
riga: {
|
||||
type: Number,
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
},
|
||||
main: {
|
||||
type: Boolean,
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
},
|
||||
type: {
|
||||
type: Number,
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
},
|
||||
visibility: {
|
||||
type: Number, // VISIB_ALL, VISIB_ONLYIF_LOGGED, VISIB_ONLY_ADMIN
|
||||
},
|
||||
date_updated: {
|
||||
type: Date,
|
||||
default: Date.now,
|
||||
},
|
||||
});
|
||||
|
||||
BotSchema.statics.getFieldsForSearch = function() {
|
||||
return [];
|
||||
};
|
||||
|
||||
BotSchema.statics.executeQueryTable = function(idapp, params) {
|
||||
params.fieldsearch = this.getFieldsForSearch();
|
||||
return tools.executeQueryTable(this, idapp, params);
|
||||
};
|
||||
|
||||
BotSchema.statics.findAllIdApp = async function(idapp) {
|
||||
const Bot = this;
|
||||
|
||||
const myfind = {idapp};
|
||||
|
||||
return Bot.find(myfind).sort({page: 1, lang: 1, riga: 1, index: 1});
|
||||
};
|
||||
|
||||
const MyBot = mongoose.model('Bot', BotSchema);
|
||||
|
||||
module.exports = {MyBot};
|
||||
@@ -135,6 +135,10 @@ const UserSchema = new mongoose.Schema({
|
||||
aportador_solidario: { // da cancellare
|
||||
type: String,
|
||||
},
|
||||
verified_by_aportador: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
aportador_iniziale: {
|
||||
type: String,
|
||||
},
|
||||
@@ -568,6 +572,7 @@ UserSchema.statics.getUserShortDataByUsername = async function(
|
||||
deleted: 1,
|
||||
sospeso: 1,
|
||||
verified_email: 1,
|
||||
verified_by_aportador: 1,
|
||||
'profile.teleg_id': 1,
|
||||
// 'profile.saw_zoom_presentation': 1,
|
||||
'profile.ask_zoom_partecipato': 1,
|
||||
@@ -860,6 +865,30 @@ UserSchema.statics.setUserQualified = async function(idapp, username) {
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setVerifiedByAportador = async function(idapp, username, valuebool) {
|
||||
const User = this;
|
||||
|
||||
if (username === undefined)
|
||||
return false;
|
||||
|
||||
const myquery = {
|
||||
'idapp': idapp,
|
||||
'username': username,
|
||||
};
|
||||
|
||||
const myrec = await User.findOneAndUpdate(myquery,
|
||||
{$set: {'verified_by_aportador': valuebool}}, {new: false});
|
||||
|
||||
return !!myrec;
|
||||
};
|
||||
|
||||
UserSchema.statics.setVerifiedByAportadorToALL = async function () {
|
||||
|
||||
return User.updateMany({}, {$set: {'verified_by_aportador': true}}, {new: false});
|
||||
|
||||
};
|
||||
|
||||
|
||||
UserSchema.statics.setUserQualified_2Invitati = async function(
|
||||
idapp, username) {
|
||||
const User = this;
|
||||
@@ -1506,6 +1535,7 @@ UserSchema.statics.getUsersList = function(idapp) {
|
||||
name: 1,
|
||||
surname: 1,
|
||||
verified_email: 1,
|
||||
verified_by_aportador: 1,
|
||||
made_gift: 1,
|
||||
perm: 1,
|
||||
email: 1,
|
||||
@@ -2069,6 +2099,7 @@ UserSchema.statics.checkUser = async function(idapp, username) {
|
||||
|
||||
return User.findOne({idapp, username}, {
|
||||
verified_email: 1,
|
||||
verified_by_aportador: 1,
|
||||
'profile.teleg_id': 1,
|
||||
'profile.teleg_checkcode': 1,
|
||||
}).then((rec) => {
|
||||
|
||||
Reference in New Issue
Block a user