- Message notify when 'Ask Info' and user is not logged

- Ask Info and Book show message if not logged
- TableField fixed and added some features
This commit is contained in:
Paolo Arena
2019-11-04 20:30:09 +01:00
parent f787fd3cea
commit 9205468065
9 changed files with 90 additions and 16 deletions

View File

@@ -97,11 +97,17 @@ const MyEventSchema = new Schema({
MyEventSchema.statics.findAllIdApp = function (idapp) {
const Event = this;
const myfind = { idapp };
const query = [
{ $match: { idapp } },
{ $sort: { dateTimeStart: 1 } }
];
return Event
.aggregate(query)
.then((arrrec) => {
return arrrec
})
return Event.find(myfind, (err, arrrec) => {
return arrrec
});
};

View File

@@ -97,7 +97,7 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
// Remove duplicate
// Exclude my chat
const myarr = arrmsg.filter((ris) => ris._id !== username);
console.table(myarr);
// console.table(myarr);
return myarr
}).catch((err) => {

52
server/models/settings.js Normal file
View File

@@ -0,0 +1,52 @@
const mongoose = require('mongoose');
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 SettingsSchema = new Schema({
idapp: {
type: String,
},
key: {
type: String,
},
type: {
type: Number,
},
value_str: {
type: String,
},
value_date: {
type: Date,
},
value_num: {
type: Number,
}
});
SettingsSchema.statics.executeQueryTable = function (idapp, params) {
return tools.executeQueryTable(this, idapp, params);
};
SettingsSchema.statics.findAllIdApp = function (idapp) {
const Settings = this;
const myfind = { idapp };
return Settings.find(myfind, (err, arrrec) => {
return arrrec
});
};
const Settings = mongoose.model('Settings', SettingsSchema);
module.exports = { Settings };

View File

@@ -92,9 +92,6 @@ var UserSchema = new mongoose.Schema({
perm: {
type: Number
},
img: {
type: String
},
ipaddr: {
type: String,
},
@@ -110,7 +107,21 @@ var UserSchema = new mongoose.Schema({
},
lasttimeonline: {
type: Date
}
},
profile: {
img: {
type: String
},
cell: {
type: String
},
dateofbirth: {
type: Date,
},
sex: {
type: Number,
},
},
});

View File

@@ -16,6 +16,7 @@ const { Operator } = require('../models/operator');
const { Where } = require('../models/where');
const { MyEvent } = require('../models/myevent');
const { Contribtype } = require('../models/contribtype');
const { Settings } = require('../models/settings');
const { SendMsg } = require('../models/sendmsg');
const { Permission } = require('../models/permission');
@@ -142,6 +143,8 @@ function getTableByTableName(tablename) {
mytable = MyEvent;
else if (tablename === 'contribtype')
mytable = Contribtype;
else if (tablename === 'settings')
mytable = Settings;
else if (tablename === 'permissions')
mytable = Permission;
@@ -336,10 +339,11 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
const operators = Operator.findAllIdApp(idapp);
const wheres = Where.findAllIdApp(idapp);
const contribtype = Contribtype.findAllIdApp(idapp);
const settings = Settings.findAllIdApp(idapp);
const permissions = Permission.findAllIdApp();
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, permissions])
return Promise.all([bookedevent, eventlist, operators, wheres, contribtype, settings, permissions])
.then((arrdata) => {
// console.table(arrdata);
res.send({
@@ -348,7 +352,8 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
operators: arrdata[2],
wheres: arrdata[3],
contribtype: arrdata[4],
permissions: arrdata[5],
settings: arrdata[5],
permissions: arrdata[6],
});
})
.catch((e) => {

View File

@@ -57,7 +57,7 @@ router.post('/', authenticate, (req, res) => {
return SendMsg.findById(idobj)
.then((recmsg) => {
// Add this field because I don't want to add into the database
recmsg.origin.infoevent = body.origin.infoevent;
recmsg.source.infoevent = body.source.infoevent;
return sendNotif(res, body.idapp, req.user, recmsg).then((ris) => {
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });

View File

@@ -236,7 +236,7 @@ module.exports = {
usernameorig: user.name + ' ' + user.surname,
emailto: emailto,
message: recmsg.message,
infoevent: recmsg.origin.infoevent,
infoevent: recmsg.source.infoevent,
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
};

View File

@@ -434,8 +434,8 @@ module.exports = {
.aggregate(query)
.then(([ris]) => {
if (ris) {
console.table(ris.rows);
console.log('ROW ', ris.count);
// console.table(ris.rows);
// console.log('ROW ', ris.count);
return ({ count: ris.count, rows: ris.rows })
} else {
return ({ count: 0, rows: [] })

View File

@@ -12,7 +12,7 @@ module.exports = {
},
fieldsUserToChange() {
return ['username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline']
return ['username', 'email', 'cell', 'name', 'surname', 'perm', 'date_reg', 'verified_email', 'img', 'ipaddr', 'lasttimeonline', 'profile']
}
};