code-corps / code-corps-api

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

Add ConversationPartController with index endpoint and scope #1289

Closed begedin closed 6 years ago

begedin commented 6 years ago

Problem

See #1286 for an explanation of how a Message system works.

Once we have created a Message and it's associated Conversation, any side of the conversation can post a reply.

Each of these replies then creates a ConversationPart containing its contents

To be able to fetch ConversationPart records from the client asynchronously, we need a working index endpoint

Subtasks

# Example implementation

def scope(query, current_user) do
  conversation_scope = Conversation |> Policy.Conversation.scope(current_user)

  query 
  |> join(:right, [cp], c in subquery(conversation_scope), cp.conversation_id == c.id)
end