Fightpandemics: Messaging: Create Private Message Object in DB

Created on 26 Aug 2020  路  10Comments  路  Source: FightPandemics/FightPandemics

As a user, I want to be able to have a private message between me and the author of a post regarding a post so that I can share private information securely.

This story should create the DB objects to allow for the "private message."
This can leverage the comment data model, so this story is to extend Backend to allow for next level of "nested comment."

Requirements:

  • These should be Identified as "Private".
  • These should be linked to the Post.
  • These should be linked between Author of Post and User adding the first private.
  • These need an indicator for tracking whether the private message has been "Read" by the recipient. This will be used on the front-end to bold or unbold in the inbox: https://github.com/FightPandemics/FightPandemics/issues/1435
  • New "private messages" will need to trigger notifications, so will need an identifier separate from comments so notification knows it is a "private message" instead of a comment. (maybe just the "private" attribute?) > notification not in scope for this story.
  • All "private messages" (these new objects) should be linked to a given user so that on the front end, we can create an "inbox" showing all threads of messages across all posts to which the user has sent a "private message."

Note: please review with Front End developer necessary to make sure they can leverage for displaying a "Message" button under Post, to display the private message exchange between Post Author and private messenger, and to create an "inbox." https://github.com/FightPandemics/FightPandemics/issues/1435

Spike for reference: https://www.notion.so/fightpandemics/Spike-Architecture-and-Database-Design-for-Direct-messaging-17def264151844278671bae00ec2ebec#a0ba11188cb243e8b6fb3e23b6254fcc

BACKEND P1 馃敟 p_Messaging

Most helpful comment

@manualzuru @Naraujo13 yeah we've decided to nix the private comment and go with a message model. We can do websockets later for something more like FB messenger, slack etc but for feasibility of timely implementation start with standard REST API over HTTP. We could even use polling on the inbox page to make it real time enough but we need to get the inbox working at all to begin with.

All 10 comments

From backend perspective:

  • We can extend the comment model for this. I would say a private and read booleans should be sufficient.
  • Adding/updating the queries within posts/users/organisations endpoints will be the more complicated part:

    • Update endpoint schemas need to accept these for comments

    • We need to properly handle private comments in both those returned & included in count with a post

    • We need add ability to use author as query param to get comments endpoint.

    • Likely some others TBD

I think we should add also add something like recipientId on the comment model so we can more easily query ALL the comments that should be in a user's inbox.

The other things we need - like with create post is organisationId so the author can be an organisation when they "change context" or toggle - https://github.com/FightPandemics/FightPandemics/blob/1e4944b1db27826ca1accb07798dd622b51577e4/backend/lib/endpoints/posts.js#L286

But we can add this later. I will create a separate ticket and work on it so we can have some kind of middleware/decorator as that logic will be repeated in a lot of places.

@joshmorel - do we need a to track some id associated to the thread?

User1 Posts X
User2 sends message to User1
threadID= unique to post and between User2 and User1
?

Would that help with data migration to future direct message solution?

I'm not sure that using the same model for private messages and comments is a good choice for this.
This might bloat comments collections (probably performance problems here, would need to shard it) and be hard to iterate, since we would have two very different features on the same collection.

I'm not sure how compromised we're into this, but I can take a look later today and try to sketch how to include this in our data model if no one is taking this

@Naraujo13 please give us a hand here. We really need to get this started. Also have a chat with @lmpeixoto and @Zaydme who want to work on this.

@manualzuru is this the real time messaging feature or just private comments? I am very confused.
Are these two separate features or the same? If different, which one we are working with here?

@Zaydme @Naraujo13 we discussed in Slack and a meeting today. Were definitely going with a new model. We agreed to just do REST calls via HTTP for the launch. We can add bidirectional real time aspects with websockets post launch. I'll add more details to my proposal for backend endpoints in Slack first for feedback hopefully tomorrow. Wednesday at the latest.

Ok, REST calls should be enough for a basic MVP and good starting point. I'm looking at the specs and will sketch something up from the data model perspective and them we can merge them

@manualzuru is this the real time messaging feature or just private comments? I am very confused.
Are these two separate features or the same? If different, which one we are working with here?

I think the feature is real-time messaging.
The confusion is probably because earlier, it was proposed to be implemented as an MVP as a private comment to try to reuse the comment code we already have.

Anyway, we seem to be going towards the opposite direction now, implementing a "real-time" chat with a new model and HTTP requests and then migrating to real real-time with sockets (and keeping the models).

@manualzuru @Naraujo13 yeah we've decided to nix the private comment and go with a message model. We can do websockets later for something more like FB messenger, slack etc but for feasibility of timely implementation start with standard REST API over HTTP. We could even use polling on the inbox page to make it real time enough but we need to get the inbox working at all to begin with.

Was this page helpful?
0 / 5 - 0 ratings