mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-20 20:59:16 +00:00
first commit on wsl
This commit is contained in:
@@ -12,6 +12,7 @@ const wbotMessageListener = () => {
|
|||||||
const wbot = getWbot();
|
const wbot = getWbot();
|
||||||
|
|
||||||
wbot.on("message", async msg => {
|
wbot.on("message", async msg => {
|
||||||
|
console.log(msg);
|
||||||
let newMessage;
|
let newMessage;
|
||||||
// console.log(msg);
|
// console.log(msg);
|
||||||
if (msg.from === "status@broadcast") {
|
if (msg.from === "status@broadcast") {
|
||||||
@@ -19,14 +20,14 @@ const wbotMessageListener = () => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const msgContact = await msg.getContact();
|
const msgContact = await msg.getContact();
|
||||||
const imageUrl = await msgContact.getProfilePicUrl();
|
const profilePicUrl = await msgContact.getProfilePicUrl();
|
||||||
try {
|
try {
|
||||||
let contact = await Contact.findOne({
|
let contact = await Contact.findOne({
|
||||||
where: { number: msgContact.number },
|
where: { number: msgContact.number },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (contact) {
|
if (contact) {
|
||||||
await contact.update({ profilePicUrl: imageUrl });
|
await contact.update({ profilePicUrl: profilePicUrl });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contact) {
|
if (!contact) {
|
||||||
@@ -34,12 +35,18 @@ const wbotMessageListener = () => {
|
|||||||
contact = await Contact.create({
|
contact = await Contact.create({
|
||||||
name: msgContact.pushname || msgContact.number.toString(),
|
name: msgContact.pushname || msgContact.number.toString(),
|
||||||
number: msgContact.number,
|
number: msgContact.number,
|
||||||
profilePicUrl: imageUrl,
|
profilePicUrl: profilePicUrl,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg.hasQuotedMsg) {
|
||||||
|
const quotedMessage = await msg.getQuotedMessage();
|
||||||
|
console.log("quoted", quotedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
if (msg.hasMedia) {
|
if (msg.hasMedia) {
|
||||||
const media = await msg.downloadMedia();
|
const media = await msg.downloadMedia();
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module.exports = (req, res, next) => {
|
|||||||
try {
|
try {
|
||||||
const [, token] = req.get("Authorization").split(" ");
|
const [, token] = req.get("Authorization").split(" ");
|
||||||
decodedToken = jwt.verify(token, "mysecret");
|
decodedToken = jwt.verify(token, "mysecret");
|
||||||
|
// todo >> find user in DB and store in req.user to use latter, or throw an error if user not exists anymore
|
||||||
req.userId = decodedToken.userId;
|
req.userId = decodedToken.userId;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
err.statusCode = 401;
|
err.statusCode = 401;
|
||||||
|
|||||||
2513
backend/yarn.lock
Normal file
2513
backend/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,4 +0,0 @@
|
|||||||
[ZoneTransfer]
|
|
||||||
ZoneId=3
|
|
||||||
ReferrerUrl=https://notificationsounds.com/message-tones/juntos-607
|
|
||||||
HostUrl=https://notificationsounds.com/message-tones/juntos-607/download/mp3
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
[ZoneTransfer]
|
|
||||||
ZoneId=3
|
|
||||||
ReferrerUrl=https://notificationsounds.com/message-tones/juntos-607
|
|
||||||
HostUrl=https://notificationsounds.com/message-tones/juntos-607/download/ogg
|
|
||||||
11504
frontend/yarn.lock
Normal file
11504
frontend/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user