mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27:59 +01:00
fix conversation controller
This commit is contained in:
parent
3f6322ca81
commit
50759774f6
2 changed files with 2 additions and 5 deletions
|
@ -48,6 +48,7 @@ defmodule Philomena.Conversations.Conversation do
|
|||
|> set_slug()
|
||||
|> set_last_message()
|
||||
|> cast_assoc(:messages, with: {Message, :creation_changeset, [from]})
|
||||
|> validate_length(:messages, is: 1)
|
||||
end
|
||||
|
||||
defp set_slug(changeset) do
|
||||
|
|
|
@ -62,11 +62,7 @@ defmodule PhilomenaWeb.ConversationController do
|
|||
render(conn, "new.html", changeset: changeset)
|
||||
end
|
||||
|
||||
# Somewhat annoying, cast_assoc has no "limit" validation so we force it
|
||||
# here to require exactly 1
|
||||
def create(conn, %{"conversation" => %{"messages" => %{"0" => message_params} = messages_params} = conversation_params})
|
||||
when %{"0" => message_params} == messages_params
|
||||
do
|
||||
def create(conn, %{"conversation" => conversation_params}) do
|
||||
user = conn.assigns.current_user
|
||||
|
||||
case Conversations.create_conversation(user, conversation_params) do
|
||||
|
|
Loading…
Reference in a new issue