diff --git a/backend/src/controllers/MessageController.js b/backend/src/controllers/MessageController.js
index cb92091..a92f121 100644
--- a/backend/src/controllers/MessageController.js
+++ b/backend/src/controllers/MessageController.js
@@ -104,7 +104,7 @@ exports.store = async (req, res, next) => {
{
model: Contact,
as: "contact",
- attributes: ["number"],
+ attributes: ["number", "name", "profilePicUrl"],
},
],
});
@@ -124,11 +124,14 @@ exports.store = async (req, res, next) => {
`${ticket.contact.number}@c.us`,
newMedia
);
+
+ await ticket.update({ lastMessage: message.mediaUrl });
} else {
sentMessage = await wbot.sendMessage(
`${ticket.contact.number}@c.us`,
message.body
);
+ await ticket.update({ lastMessage: message.body });
}
message.id = sentMessage.id.id;
@@ -144,9 +147,11 @@ exports.store = async (req, res, next) => {
}`,
};
- io.to(ticketId).emit("appMessage", {
+ io.to(ticketId).to("notification").emit("appMessage", {
action: "create",
message: serialziedMessage,
+ ticket: ticket,
+ contact: ticket.contact,
});
await setMessagesAsRead(ticketId);
diff --git a/backend/src/services/wbotMessageListener.js b/backend/src/services/wbotMessageListener.js
index 81e1b56..57bc6ab 100644
--- a/backend/src/services/wbotMessageListener.js
+++ b/backend/src/services/wbotMessageListener.js
@@ -120,8 +120,6 @@ const handleMessage = async (msg, ticket, contact) => {
const serializaedTicket = {
...ticket.dataValues,
- // unreadMessages: 1,
- // lastMessage: newMessage.body,
contact: contact,
};
diff --git a/frontend/src/components/MessagesList/index.js b/frontend/src/components/MessagesList/index.js
index b9c9ff6..843676e 100644
--- a/frontend/src/components/MessagesList/index.js
+++ b/frontend/src/components/MessagesList/index.js
@@ -368,7 +368,11 @@ const MessagesList = () => {
/>
);
} else {
- return Download;
+ return (
+
+ Download
+
+ );
}
};