-
Notifications
You must be signed in to change notification settings - Fork 85
Closed
Description
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.
In order to do that, we need a create endpoint
Subtasks
- implement
create_changeset- we keep putting this into the schema module, but I really think that does not fit well with the context paradigm, so I'm open to suggestions on where to put it. I'm thinking
Messages.ConversationPart. Could even be private - casts
[:body, :author_id, :conversation_id] - ensures author and conversation exist
:read_atis null initially
- we keep putting this into the schema module, but I really think that does not fit well with the context paradigm, so I'm open to suggestions on where to put it. I'm thinking
- test
create_changeset, or testingMessages.create_conversation_part/1might be enough - implement
Policy.ConversationPart.create?current_useris authorized ifcurrent_user.id == params["author_id"]current_useris authorized ifcurrent_user.id == (params |> get_conversation).user_idcurrent_useris authorized ifcurrent_user.id == (params |> get_message).author_idcurrent_useris authorized if admin or higher on(params |> get_project)
- write tests for
Policy.ConversationPart.create? - implement
Messages.create_conversation_part(params)- probably delegates to
Messages.ConversationPart.create - uses
create_changeset
- probably delegates to
- test
Messages.create_conversation_part(params)- if
create_changesetis private, make sure to test casting behavior to
- if
- implement
ConversationPartController:createendpoint- authorizes using policy
- creates record using
Messages.create_conversation_part
- write tests for
:createendpoint