Improve primary keys usage
This commit is contained in:
parent
232df26b85
commit
40f3eeff7c
16 changed files with 66 additions and 48 deletions
|
@ -40,7 +40,7 @@ defmodule ArchitexWeb.Client.LoginController do
|
|||
case Account.login(input) |> Repo.transaction() do
|
||||
{:ok,
|
||||
{%Account{localpart: localpart},
|
||||
%Device{access_token: access_token, device_id: device_id}}} ->
|
||||
%Device{access_token: access_token, id: device_id}}} ->
|
||||
data = %{
|
||||
user_id: Architex.get_mxid(localpart),
|
||||
access_token: access_token,
|
||||
|
|
|
@ -24,7 +24,7 @@ defmodule ArchitexWeb.Client.RegisterController do
|
|||
{:ok,
|
||||
%{
|
||||
account: %Account{localpart: localpart},
|
||||
device: %Device{device_id: device_id, access_token: access_token}
|
||||
device: %Device{id: device_id, access_token: access_token}
|
||||
}} ->
|
||||
data = %{user_id: Architex.get_mxid(localpart)}
|
||||
|
||||
|
|
|
@ -232,4 +232,13 @@ defmodule ArchitexWeb.Client.RoomController do
|
|||
put_error(conn, :not_found, "The given room was not found.")
|
||||
end
|
||||
end
|
||||
|
||||
# GET /_matrix/client/r0/rooms/!atYDsyowueiToUvuqY:localhost:4000/messages
|
||||
# Parameters: %{"dir" => "b", "from" => "", "limit" => "727", "path" => ["_matrix", "client", "r0", "rooms", "!atYDsyowueiToUvuqY:localhost:4000", "messages"]}
|
||||
def message(conn, params) do
|
||||
|
||||
conn
|
||||
|> send_resp(400, [])
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule ArchitexWeb.Federation.EventController do
|
|||
def event(%Plug.Conn{assigns: %{origin: origin}} = conn, %{"event_id" => event_id}) do
|
||||
query =
|
||||
Event
|
||||
|> where([e], e.event_id == ^event_id)
|
||||
|> where([e], e.id == ^event_id)
|
||||
|> preload(:room)
|
||||
|
||||
case Repo.one(query) do
|
||||
|
@ -82,7 +82,7 @@ defmodule ArchitexWeb.Federation.EventController do
|
|||
defp get_state_or_state_ids(conn, state_or_state_ids, origin, event_id, room_id) do
|
||||
query =
|
||||
Event
|
||||
|> where([e], e.event_id == ^event_id and e.room_id == ^room_id)
|
||||
|> where([e], e.id == ^event_id and e.room_id == ^room_id)
|
||||
|> preload(:room)
|
||||
|
||||
case Repo.one(query) do
|
||||
|
|
|
@ -67,6 +67,7 @@ defmodule ArchitexWeb.Router do
|
|||
post "/ban", RoomController, :ban
|
||||
post "/unban", RoomController, :unban
|
||||
put "/send/:event_type/:txn_id", RoomController, :send_message
|
||||
get "/messages", RoomController, :messages
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue