first commit on wsl

This commit is contained in:
canove
2020-06-24 13:42:45 -03:00
parent c60c0f44fc
commit 1bc4831f8f
6 changed files with 14028 additions and 11 deletions

View File

@@ -12,6 +12,7 @@ const wbotMessageListener = () => {
const wbot = getWbot();
wbot.on("message", async msg => {
console.log(msg);
let newMessage;
// console.log(msg);
if (msg.from === "status@broadcast") {
@@ -19,14 +20,14 @@ const wbotMessageListener = () => {
}
try {
const msgContact = await msg.getContact();
const imageUrl = await msgContact.getProfilePicUrl();
const profilePicUrl = await msgContact.getProfilePicUrl();
try {
let contact = await Contact.findOne({
where: { number: msgContact.number },
});
if (contact) {
await contact.update({ profilePicUrl: imageUrl });
await contact.update({ profilePicUrl: profilePicUrl });
}
if (!contact) {
@@ -34,12 +35,18 @@ const wbotMessageListener = () => {
contact = await Contact.create({
name: msgContact.pushname || msgContact.number.toString(),
number: msgContact.number,
profilePicUrl: imageUrl,
profilePicUrl: profilePicUrl,
});
} catch (err) {
console.log(err);
}
}
if (msg.hasQuotedMsg) {
const quotedMessage = await msg.getQuotedMessage();
console.log("quoted", quotedMessage);
}
if (msg.hasMedia) {
const media = await msg.downloadMedia();

View File

@@ -5,6 +5,7 @@ module.exports = (req, res, next) => {
try {
const [, token] = req.get("Authorization").split(" ");
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;
} catch (err) {
err.statusCode = 401;

2513
backend/yarn.lock Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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

File diff suppressed because it is too large Load Diff