Step 1: Creating page Messages: userlist last messages + a page for all the messages received and sent.
This commit is contained in:
@@ -15,11 +15,13 @@ const sendmsgSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
origin: {
|
||||
userId: { type: String },
|
||||
source: {
|
||||
page: { type: String },
|
||||
event_id: { type: String }
|
||||
},
|
||||
origin: {
|
||||
username: { type: String },
|
||||
},
|
||||
dest: {
|
||||
idapp: { type: String, },
|
||||
username: { type: String },
|
||||
@@ -41,20 +43,20 @@ const sendmsgSchema = new Schema({
|
||||
|
||||
});
|
||||
|
||||
sendmsgSchema.statics.findAllByUserIdAndIdApp = function (userId, username, idapp) {
|
||||
sendmsgSchema.statics.findAllMsgByUsernameIdAndIdApp = function (username, lastdataread, idapp) {
|
||||
const SendMsg = this;
|
||||
|
||||
return SendMsg.find({
|
||||
$and: [
|
||||
{
|
||||
$or: [
|
||||
{ 'origin.userId': userId },
|
||||
{ 'dest.username': username }]
|
||||
},
|
||||
{ $or: [ { 'dest.username': username }, { 'origin.username': username },] },
|
||||
{ 'datemsg': {$gt: new Date(lastdataread)} },
|
||||
{ idapp }
|
||||
]
|
||||
}, (err, arrmsg) => {
|
||||
}).then((arrmsg) => {
|
||||
console.log('arrmsg', arrmsg);
|
||||
return arrmsg
|
||||
}).catch((err) => {
|
||||
console.error('err', err);
|
||||
});
|
||||
|
||||
};
|
||||
@@ -65,7 +67,7 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
|
||||
return SendMsg.aggregate([
|
||||
{
|
||||
$match: {
|
||||
$or: [{ 'origin.userId': userId }, { 'dest.username': username }, { idapp }],
|
||||
$or: [{ 'origin.username': username }, { 'dest.username': username }, { idapp }],
|
||||
$and: [{ idapp }]
|
||||
}
|
||||
},
|
||||
@@ -74,7 +76,6 @@ sendmsgSchema.statics.findLastGroupByUserIdAndIdApp = function (userId, username
|
||||
{
|
||||
_id: "$dest.username",
|
||||
message: { $last: "$message" },
|
||||
|
||||
datemsg: { $last: "$datemsg" },
|
||||
dest: { $last: "$dest" },
|
||||
origin: { $last: "$origin" },
|
||||
|
||||
Reference in New Issue
Block a user