Skip to content

Commit

Permalink
Required changes done
Browse files Browse the repository at this point in the history
  • Loading branch information
JAYBORICHA07 committed Oct 30, 2023
1 parent 50d3344 commit 99a093c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/controller/messageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const messageController = {
send: async (req:Request, res:Response, ) => {
try {
const { jid, type = 'number', message, options } = req.body;
const newMsg = { text : `Following msg was sent to the ${jid.slice(2,12)} \n ${message.text}` }
// @ts-ignore
const session = getSession(req.query.sessionId);
const exists = await jidExist(session, jid, type);
if (!exists) return res.status(400).json({ error: 'JID does not exists' });
console.log('sending message')
// console.log(jid);
// console.log(session.user.id);
console.log('sending message')
// console.log();
const result = await session.sendMessage(jid, message, options);
const msgSelf = await session.sendMessage(session.user.id, message, options)
const msgSelf = await session.sendMessage(session.user.id, newMsg, options)
res.status(200).json({result, msgSelf});

} catch (error) {
Expand All @@ -43,8 +43,9 @@ const messageController = {
}

if (index > 0) await delayMS(delay);
const newMsg = { text : ` \n Following msg was sent to the ${jid.slice(2,12)} \n \n ${message.text}` }
const result = await session.sendMessage(jid, message, options);
const selfMsgresult = await session.sendMessage(session.user.id, message, options);
const selfMsgresult = await session.sendMessage(session.user.id, newMsg, options);
results.push({ index, result });
selfMsgResults.push({ index, selfMsgresult });
} catch (e) {
Expand Down

0 comments on commit 99a093c

Please sign in to comment.