Giter VIP home page Giter VIP logo

scam-chat's People

Contributors

charlotte-wt avatar clairverbot avatar emmaneugene avatar

Stargazers

 avatar  avatar

Forkers

emmaneugene

scam-chat's Issues

Bug where senderId may not be contactId

If the canary account is the last to send a message, the the senderId will be the canary account's ID instead of the contact's ID.

      const totalMsgs = msgs.total;
      const sender = await msgs[0].getSender();
      const contactName = sender.firstName;

      const chat = new ChatModel({
        phone_num: req.params.phone_num,
        contact_name: contactName,
        total_msgs: totalMsgs,
        chat_id: chatId
      });

Full test flow

  • Full test suite with setup and teardown to demonstrate session management

Session assignment

To avoid dealing with complex race conditions, assignment of new sessions will be performed by the SessionController object, instead of allowing users to choose or input handles for initiating chats

New session creation

A new session should be created whenever a new chatId is identified within a canary account's list of chats

TODO modify updateChatList() in chat_list.controller.js

Performance issue with retrieving chats / messages

  1. $in operator is not necessary if we are matching only one phone number
  2. More efficient to have a latestMessage field in the chats collection, which would allow us to retrieve just the latest message for each chat without having to retrieve all the chat messages
  3. Currently, we’re manually grouping the chat messages on the frontend based on the dates, doing it through mongodb’s aggregation pipeline might be faster and cleaner. Group the results before returning the data and sort too.
    Notion:
    https://www.notion.so/UI-Layout-for-Chat-43feabaa9f494c4f89f87bcd4d1acb53?pvs=4
try {
    const chatDetails = await ChatModel.find({
      phone_num: req.params.phone_num

    }).sort({updatedAt: -1});
}
  res.status(200).json(chatDetails);
} catch (error) {
  res.status(500).json(error);
}

Bug where all telegram users are returned instead of the specific one

Routing issue in scam_chat/app/routes/tele_user.route.js

// Retrieve a single user with number
router.get('/:user_id', getUserByNum);

According to the code in scam_chat/app/controllers/tele_user.controller.js it should be

// Retrieve a single user with number
router.get('/:phone_num', getUserByNum);

Additionally, able to refactor to not use in for a single user in scam_chat/app/controllers/tele_user.controller.js.

Original Code:

// Find a single User by phone_num
export const getUserByNum = async (req, res) => {
  try {
    const user = await UserModel.find({
      members: { $in: [req.params.phone_num] }
    });
    res.status(200).json(user);
  } catch (error) {
    res.status(500).json(error);
  }
};

Refactored Code:

// Find a single User by phone_num
export const getUserByNum = async (req, res) => {
  try {
    const user = await UserModel.find({
      phone_num: req.params.phone_num
    });
    res.status(200).json(user);
  } catch (error) {
    res.status(500).json(error);
  }
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.