- Fixed Image avatar user list, q-qvatar rounded image
This commit is contained in:
@@ -44,43 +44,54 @@ const sendmsgSchema = new Schema({
|
||||
sendmsgSchema.statics.findAllByUserIdAndIdApp = function (userId, username, idapp) {
|
||||
const SendMsg = this;
|
||||
|
||||
// Filter my msg
|
||||
//
|
||||
// (userId or dest.username === username) and idapp
|
||||
|
||||
console.log('userId', userId);
|
||||
|
||||
return SendMsg.find({
|
||||
$and: [
|
||||
$and: [
|
||||
{
|
||||
$or: [
|
||||
{ 'origin.userId': userId },
|
||||
{ 'dest.username': username }]
|
||||
},
|
||||
{ idapp }
|
||||
]
|
||||
}, (err, arrmsg) => {
|
||||
return arrmsg
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username, idapp) {
|
||||
const SendMsg = this;
|
||||
|
||||
return SendMsg.aggregate([
|
||||
{
|
||||
$match: {
|
||||
$or: [{ 'origin.userId': userId }, { 'dest.username': username }, { idapp }],
|
||||
$and: [{ idapp }]
|
||||
}
|
||||
},
|
||||
{
|
||||
$group:
|
||||
{
|
||||
$or: [
|
||||
{ 'origin.userId': userId },
|
||||
{ 'dest.username': username }]
|
||||
},
|
||||
{ idapp }
|
||||
]
|
||||
}, (err, arrmsg) => {
|
||||
// console.log('ris arrmsg:', arrmsg);
|
||||
_id: "$dest.username",
|
||||
message: { $last: "$message" },
|
||||
datemsg: { $last: "$datemsg" },
|
||||
dest: { $last: "$dest" },
|
||||
origin: { $last: "$origin" },
|
||||
read: { $last: "$read" }
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
$sort: { datemsg: -1 }
|
||||
},
|
||||
])
|
||||
.then((arrmsg) => {
|
||||
console.table(arrmsg);
|
||||
return arrmsg
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
// return SendMsg.find(
|
||||
// {
|
||||
// $and: [
|
||||
// {
|
||||
// $or: [
|
||||
// { 'dest.username': username },
|
||||
// { userId: userId }
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// idapp
|
||||
// }
|
||||
// ]
|
||||
// }, (err, arrmsg) => {
|
||||
// console.log('ris arrmsg:', arrmsg);
|
||||
// return arrmsg
|
||||
// });
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -89,6 +89,9 @@ var UserSchema = new mongoose.Schema({
|
||||
perm: {
|
||||
type: Number
|
||||
},
|
||||
img: {
|
||||
type: String
|
||||
},
|
||||
ipaddr: {
|
||||
type: String,
|
||||
},
|
||||
@@ -109,7 +112,7 @@ UserSchema.methods.toJSON = function () {
|
||||
var user = this;
|
||||
var userObject = user.toObject();
|
||||
|
||||
return _.pick(userObject, ['_id', 'email', 'verified_email', 'idapp', 'username', 'userId', 'name', 'surname', 'perm']);
|
||||
return _.pick(userObject, ['_id', ...shared_consts.fieldsUserToChange()]);
|
||||
};
|
||||
|
||||
UserSchema.methods.generateAuthToken = function (req) {
|
||||
@@ -306,7 +309,7 @@ UserSchema.methods.removeToken = function (token) {
|
||||
UserSchema.statics.getUsersList = function (idapp) {
|
||||
const User = this;
|
||||
|
||||
return User.find({ 'idapp': idapp }, { username: 1, name: 1, surname: 1, verified_email: 1, perm:1, email: 1, date_reg: 1 })
|
||||
return User.find({ 'idapp': idapp }, { username: 1, name: 1, surname: 1, verified_email: 1, perm:1, email: 1, date_reg: 1, img: 1 })
|
||||
|
||||
};
|
||||
|
||||
@@ -321,7 +324,7 @@ UserSchema.statics.getUsersListByParams = function (params) {
|
||||
return User.find(
|
||||
{ $match: filterMatchBefore },
|
||||
{ 'idapp': idapp },
|
||||
{ username: 1, name: 1, surname: 1, verified_email: 1, perm:1, email: 1, date_reg: 1 })
|
||||
{ username: 1, name: 1, surname: 1, verified_email: 1, perm:1, email: 1, date_reg: 1, img: 1 })
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user