mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 04:39:20 +00:00
🗑added public folder content to gitignore
This commit is contained in:
4
backend/.gitignore
vendored
4
backend/.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
public/*
|
src/public/*
|
||||||
!public/.gitkeep
|
!src/public/.gitkeep
|
||||||
.env
|
.env
|
||||||
@@ -14,9 +14,7 @@ module.exports = (req, res, next) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!decodedToken) {
|
if (!decodedToken) {
|
||||||
const error = new Error("Falha na autenticação");
|
return res.status(401).json({ message: "Unauthorized" });
|
||||||
error.statusCode = 401;
|
|
||||||
next(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const ContactController = require("../controllers/ContactController");
|
|||||||
const routes = express.Router();
|
const routes = express.Router();
|
||||||
|
|
||||||
routes.get("/contacts", isAuth, ContactController.index);
|
routes.get("/contacts", isAuth, ContactController.index);
|
||||||
// routes.post(ContactController.postCreateContact);
|
|
||||||
|
|
||||||
routes.post("/contacts", isAuth, ContactController.store);
|
routes.post("/contacts", isAuth, ContactController.store);
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const MessageController = require("../controllers/MessageController");
|
|||||||
const routes = express.Router();
|
const routes = express.Router();
|
||||||
|
|
||||||
routes.get("/messages/:contactId", isAuth, MessageController.index);
|
routes.get("/messages/:contactId", isAuth, MessageController.index);
|
||||||
|
|
||||||
routes.post("/messages/:contactId", isAuth, MessageController.store);
|
routes.post("/messages/:contactId", isAuth, MessageController.store);
|
||||||
|
|
||||||
module.exports = routes;
|
module.exports = routes;
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ const wbotMessageListener = () => {
|
|||||||
wbot.on("message", async msg => {
|
wbot.on("message", async msg => {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
let newMessage;
|
let newMessage;
|
||||||
// console.log(msg);
|
if (msg.from === "status@broadcast" || msg.type === "location") {
|
||||||
if (msg.from === "status@broadcast") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -28,9 +27,7 @@ const wbotMessageListener = () => {
|
|||||||
|
|
||||||
if (contact) {
|
if (contact) {
|
||||||
await contact.update({ profilePicUrl: profilePicUrl });
|
await contact.update({ profilePicUrl: profilePicUrl });
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (!contact) {
|
|
||||||
try {
|
try {
|
||||||
contact = await Contact.create({
|
contact = await Contact.create({
|
||||||
name: msgContact.pushname || msgContact.number.toString(),
|
name: msgContact.pushname || msgContact.number.toString(),
|
||||||
@@ -81,24 +78,26 @@ const wbotMessageListener = () => {
|
|||||||
await contact.update({ lastMessage: msg.body });
|
await contact.update({ lastMessage: msg.body });
|
||||||
}
|
}
|
||||||
|
|
||||||
io.to(contact.id)
|
const serializedMessage = {
|
||||||
.to("notification")
|
...newMessage.dataValues,
|
||||||
.emit("appMessage", {
|
mediaUrl: `${
|
||||||
action: "create",
|
newMessage.mediaUrl
|
||||||
message: {
|
? `http://${process.env.HOST}:${process.env.PORT}/public/${newMessage.mediaUrl}`
|
||||||
...newMessage.dataValues,
|
: ""
|
||||||
mediaUrl: `${
|
}`,
|
||||||
newMessage.mediaUrl
|
};
|
||||||
? `http://${process.env.HOST}:${process.env.PORT}/public/${newMessage.mediaUrl}`
|
|
||||||
: ""
|
const serializaedContact = {
|
||||||
}`,
|
...contact.dataValues,
|
||||||
},
|
unreadMessages: 1,
|
||||||
contact: {
|
lastMessage: newMessage.messageBody,
|
||||||
...contact.dataValues,
|
};
|
||||||
unreadMessages: 1,
|
|
||||||
lastMessage: newMessage.messageBody,
|
io.to(contact.id).to("notification").emit("appMessage", {
|
||||||
},
|
action: "create",
|
||||||
});
|
message: serializedMessage,
|
||||||
|
contact: serializaedContact,
|
||||||
|
});
|
||||||
|
|
||||||
let chat = await msg.getChat();
|
let chat = await msg.getChat();
|
||||||
chat.sendSeen();
|
chat.sendSeen();
|
||||||
|
|||||||
Reference in New Issue
Block a user