- 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:
@@ -97,11 +97,17 @@ const MyEventSchema = new Schema({
|
|||||||
MyEventSchema.statics.findAllIdApp = function (idapp) {
|
MyEventSchema.statics.findAllIdApp = function (idapp) {
|
||||||
const Event = this;
|
const Event = this;
|
||||||
|
|
||||||
const myfind = { idapp };
|
const query = [
|
||||||
|
{ $match: { idapp } },
|
||||||
|
{ $sort: { dateTimeStart: 1 } }
|
||||||
|
];
|
||||||
|
|
||||||
return Event.find(myfind, (err, arrrec) => {
|
return Event
|
||||||
|
.aggregate(query)
|
||||||
|
.then((arrrec) => {
|
||||||
return arrrec
|
return arrrec
|
||||||
});
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
|
|||||||
// Remove duplicate
|
// Remove duplicate
|
||||||
// Exclude my chat
|
// Exclude my chat
|
||||||
const myarr = arrmsg.filter((ris) => ris._id !== username);
|
const myarr = arrmsg.filter((ris) => ris._id !== username);
|
||||||
console.table(myarr);
|
// console.table(myarr);
|
||||||
return myarr
|
return myarr
|
||||||
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
|||||||
52
server/models/settings.js
Normal file
52
server/models/settings.js
Normal 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 };
|
||||||
@@ -92,9 +92,6 @@ var UserSchema = new mongoose.Schema({
|
|||||||
perm: {
|
perm: {
|
||||||
type: Number
|
type: Number
|
||||||
},
|
},
|
||||||
img: {
|
|
||||||
type: String
|
|
||||||
},
|
|
||||||
ipaddr: {
|
ipaddr: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
@@ -110,7 +107,21 @@ var UserSchema = new mongoose.Schema({
|
|||||||
},
|
},
|
||||||
lasttimeonline: {
|
lasttimeonline: {
|
||||||
type: Date
|
type: Date
|
||||||
}
|
},
|
||||||
|
profile: {
|
||||||
|
img: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
cell: {
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
dateofbirth: {
|
||||||
|
type: Date,
|
||||||
|
},
|
||||||
|
sex: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const { Operator } = require('../models/operator');
|
|||||||
const { Where } = require('../models/where');
|
const { Where } = require('../models/where');
|
||||||
const { MyEvent } = require('../models/myevent');
|
const { MyEvent } = require('../models/myevent');
|
||||||
const { Contribtype } = require('../models/contribtype');
|
const { Contribtype } = require('../models/contribtype');
|
||||||
|
const { Settings } = require('../models/settings');
|
||||||
const { SendMsg } = require('../models/sendmsg');
|
const { SendMsg } = require('../models/sendmsg');
|
||||||
const { Permission } = require('../models/permission');
|
const { Permission } = require('../models/permission');
|
||||||
|
|
||||||
@@ -142,6 +143,8 @@ function getTableByTableName(tablename) {
|
|||||||
mytable = MyEvent;
|
mytable = MyEvent;
|
||||||
else if (tablename === 'contribtype')
|
else if (tablename === 'contribtype')
|
||||||
mytable = Contribtype;
|
mytable = Contribtype;
|
||||||
|
else if (tablename === 'settings')
|
||||||
|
mytable = Settings;
|
||||||
else if (tablename === 'permissions')
|
else if (tablename === 'permissions')
|
||||||
mytable = Permission;
|
mytable = Permission;
|
||||||
|
|
||||||
@@ -336,10 +339,11 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
const operators = Operator.findAllIdApp(idapp);
|
const operators = Operator.findAllIdApp(idapp);
|
||||||
const wheres = Where.findAllIdApp(idapp);
|
const wheres = Where.findAllIdApp(idapp);
|
||||||
const contribtype = Contribtype.findAllIdApp(idapp);
|
const contribtype = Contribtype.findAllIdApp(idapp);
|
||||||
|
const settings = Settings.findAllIdApp(idapp);
|
||||||
const permissions = Permission.findAllIdApp();
|
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) => {
|
.then((arrdata) => {
|
||||||
// console.table(arrdata);
|
// console.table(arrdata);
|
||||||
res.send({
|
res.send({
|
||||||
@@ -348,7 +352,8 @@ router.get('/loadsite/:userId/:idapp/:sall', authenticate_noerror, (req, res) =>
|
|||||||
operators: arrdata[2],
|
operators: arrdata[2],
|
||||||
wheres: arrdata[3],
|
wheres: arrdata[3],
|
||||||
contribtype: arrdata[4],
|
contribtype: arrdata[4],
|
||||||
permissions: arrdata[5],
|
settings: arrdata[5],
|
||||||
|
permissions: arrdata[6],
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ router.post('/', authenticate, (req, res) => {
|
|||||||
return SendMsg.findById(idobj)
|
return SendMsg.findById(idobj)
|
||||||
.then((recmsg) => {
|
.then((recmsg) => {
|
||||||
// Add this field because I don't want to add into the database
|
// 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 sendNotif(res, body.idapp, req.user, recmsg).then((ris) => {
|
||||||
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
|
return res.send({ code: server_constants.RIS_CODE_OK, msg: '', id: recmsg._id });
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ module.exports = {
|
|||||||
usernameorig: user.name + ' ' + user.surname,
|
usernameorig: user.name + ' ' + user.surname,
|
||||||
emailto: emailto,
|
emailto: emailto,
|
||||||
message: recmsg.message,
|
message: recmsg.message,
|
||||||
infoevent: recmsg.origin.infoevent,
|
infoevent: recmsg.source.infoevent,
|
||||||
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -434,8 +434,8 @@ module.exports = {
|
|||||||
.aggregate(query)
|
.aggregate(query)
|
||||||
.then(([ris]) => {
|
.then(([ris]) => {
|
||||||
if (ris) {
|
if (ris) {
|
||||||
console.table(ris.rows);
|
// console.table(ris.rows);
|
||||||
console.log('ROW ', ris.count);
|
// console.log('ROW ', ris.count);
|
||||||
return ({ count: ris.count, rows: ris.rows })
|
return ({ count: ris.count, rows: ris.rows })
|
||||||
} else {
|
} else {
|
||||||
return ({ count: 0, rows: [] })
|
return ({ count: 0, rows: [] })
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
fieldsUserToChange() {
|
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']
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user