How to mark read messages?

50 views Asked by At

I'm implementing a messaging app in SailsJS, but I need to mark an specific message when has been read.

Right now users need to click on the conversation and browser will load the messages related. How Can I do that?

This is my Conversation model:

module.exports = {
  attributes: {
    subject: 'STRING',
    related_product_id: 'INTEGER',
    related_product_name: 'STRING',
    related_product_price: 'STRING',
    starter_name: 'STRING',
    recipients: {
        collection: 'recipient',
        via: 'conversation'
    },
    messages: {
        collection: 'message',
        via: 'conversation'
    }
  }
};

And this is my Message model:

module.exports = {
  attributes: {
      body: 'string',
      sender_uid: 'string',
      file: 'string',
      conversation: {
           model: 'conversation'
      },
      read : {
          type : "boolean",
          defaultsTo : false
      }
  }
};

I have put on the attr read on Message model, and this will be the field that I need to change to True when is read.

0

There are 0 answers