code-corps / code-corps-api

Elixir/Phoenix API for Code Corps.
https://www.codecorps.org
MIT License
234 stars 86 forks source link

Discussion: Best way to create Conversations when creating Message #1293

Closed begedin closed 6 years ago

begedin commented 6 years ago

Problem

Our MessageController :create endpoint, implemented in #1278 is not enough.

It needs to support creating associated Conversation records alongside the created Message record, for each user specified as the recipient when a project admin is starting the thread.

When a user is starting the thread, a single Conversation record needs to be created for that user.

The question is, which side is the smart one here? Do we specify these associations on the client as directly as possible, the way we do with user skills, for example, or do we specify them dumbly and let the API inferr the correct information?

My vote would go for smarter client, simply because it allows for more flexibility.

When starting a thread as a project

When starting a thread as a user

The only alternative that I can think of is

When starting thread as project admin

When starting thread as user

This alternative makes for a more fragmented codebase and is more difficult to follow, in my opinion, which is why I prefer the first approach.

Subtasks

@joshsmith What do you think?

joshsmith commented 6 years ago

I don't think we even need to support targeting multiple users at first with the messages. Simplest is 1:1 on both sides and expand it later to support more.