|
@@ -72,9 +72,16 @@ const sentMessage = async (req, res, next) => {
|
|
|
owner: id,
|
|
|
});
|
|
|
const { total } = await MessageModel.getList(userId, {});
|
|
|
- await ChatModel.update(isChat._id, { total, seen: total });
|
|
|
+ await ChatModel.update(isChat._id, {
|
|
|
+ total,
|
|
|
+ seen: total,
|
|
|
+ lastMessage: message,
|
|
|
+ });
|
|
|
const { total: Total } = await MessageModel.getList(id, {});
|
|
|
- await ChatModel.update(isCompanionChat._id, { total: Total });
|
|
|
+ await ChatModel.update(isCompanionChat._id, {
|
|
|
+ total: Total,
|
|
|
+ lastMessage: message,
|
|
|
+ });
|
|
|
return res.status(201).json({
|
|
|
status: 'success',
|
|
|
code: 201,
|
|
@@ -127,9 +134,16 @@ const imageMessage = async (req, res, next) => {
|
|
|
owner: id,
|
|
|
});
|
|
|
const { total } = await MessageModel.getList(userId, {});
|
|
|
- await ChatModel.update(isChat._id, { total, seen: total });
|
|
|
+ await ChatModel.update(isChat._id, {
|
|
|
+ total,
|
|
|
+ seen: total,
|
|
|
+ lastMessage: imgUrl,
|
|
|
+ });
|
|
|
const { total: Total } = await MessageModel.getList(id, {});
|
|
|
- await ChatModel.update(isCompanionChat._id, { total: Total });
|
|
|
+ await ChatModel.update(isCompanionChat._id, {
|
|
|
+ total: Total,
|
|
|
+ lastMessage: imgUrl,
|
|
|
+ });
|
|
|
return res.status(201).json({
|
|
|
status: 'success',
|
|
|
code: 201,
|
|
@@ -181,9 +195,16 @@ const audioMessage = async (req, res, next) => {
|
|
|
owner: id,
|
|
|
});
|
|
|
const { total } = await MessageModel.getList(userId, {});
|
|
|
- await ChatModel.update(isChat._id, { total, seen: total });
|
|
|
+ await ChatModel.update(isChat._id, {
|
|
|
+ total,
|
|
|
+ seen: total,
|
|
|
+ lastMessage: audioUrl,
|
|
|
+ });
|
|
|
const { total: Total } = await MessageModel.getList(id, {});
|
|
|
- await ChatModel.update(isCompanionChat._id, { total: Total });
|
|
|
+ await ChatModel.update(isCompanionChat._id, {
|
|
|
+ total: Total,
|
|
|
+ lastMessage: audioUrl,
|
|
|
+ });
|
|
|
return res.status(201).json({
|
|
|
status: 'success',
|
|
|
code: 201,
|
|
@@ -235,9 +256,16 @@ const videoMessage = async (req, res, next) => {
|
|
|
owner: id,
|
|
|
});
|
|
|
const { total } = await MessageModel.getList(userId, {});
|
|
|
- await ChatModel.update(isChat._id, { total, seen: total });
|
|
|
+ await ChatModel.update(isChat._id, {
|
|
|
+ total,
|
|
|
+ seen: total,
|
|
|
+ lastMessage: videoUrl,
|
|
|
+ });
|
|
|
const { total: Total } = await MessageModel.getList(id, {});
|
|
|
- await ChatModel.update(isCompanionChat._id, { total: Total });
|
|
|
+ await ChatModel.update(isCompanionChat._id, {
|
|
|
+ total: Total,
|
|
|
+ lastMessage: videoUrl,
|
|
|
+ });
|
|
|
return res.status(201).json({
|
|
|
status: 'success',
|
|
|
code: 201,
|
|
@@ -303,9 +331,16 @@ const fileMessage = async (req, res, next) => {
|
|
|
owner: id,
|
|
|
});
|
|
|
const { total } = await MessageModel.getList(userId, {});
|
|
|
- await ChatModel.update(isChat._id, { total, seen: total });
|
|
|
+ await ChatModel.update(isChat._id, {
|
|
|
+ total,
|
|
|
+ seen: total,
|
|
|
+ lastMessage: fileUrl,
|
|
|
+ });
|
|
|
const { total: Total } = await MessageModel.getList(id, {});
|
|
|
- await ChatModel.update(isCompanionChat._id, { total: Total });
|
|
|
+ await ChatModel.update(isCompanionChat._id, {
|
|
|
+ total: Total,
|
|
|
+ lastMessage: fileUrl,
|
|
|
+ });
|
|
|
return res.status(201).json({
|
|
|
status: 'success',
|
|
|
code: 201,
|