Implement client joined rooms endpoint
Track which rooms a local account has joined Add some documentation to modules
This commit is contained in:
parent
9d40f8bc8b
commit
6f8c224d50
8 changed files with 95 additions and 11 deletions
lib/matrix_server/schema
|
@ -3,7 +3,7 @@ defmodule MatrixServer.Account do
|
|||
|
||||
import Ecto.{Changeset, Query}
|
||||
|
||||
alias MatrixServer.{Repo, Account, Device}
|
||||
alias MatrixServer.{Repo, Account, Device, Room, JoinedRoom}
|
||||
alias MatrixServerWeb.Client.Request.{Register, Login}
|
||||
alias Ecto.Multi
|
||||
|
||||
|
@ -17,6 +17,11 @@ defmodule MatrixServer.Account do
|
|||
schema "accounts" do
|
||||
field :password_hash, :string, redact: true
|
||||
has_many :devices, Device, foreign_key: :localpart
|
||||
|
||||
many_to_many :joined_rooms, Room,
|
||||
join_through: JoinedRoom,
|
||||
join_keys: [localpart: :localpart, room_id: :id]
|
||||
|
||||
timestamps(updated_at: false)
|
||||
end
|
||||
|
||||
|
|
16
lib/matrix_server/schema/joined_room.ex
Normal file
16
lib/matrix_server/schema/joined_room.ex
Normal file
|
@ -0,0 +1,16 @@
|
|||
defmodule MatrixServer.JoinedRoom do
|
||||
use Ecto.Schema
|
||||
|
||||
alias MatrixServer.{Account, Room}
|
||||
|
||||
@primary_key false
|
||||
schema "joined_rooms" do
|
||||
belongs_to :account, Account,
|
||||
foreign_key: :localpart,
|
||||
references: :localpart,
|
||||
type: :string,
|
||||
primary_key: true
|
||||
|
||||
belongs_to :room, Room, primary_key: true, type: :string
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue