fixed ownership tranfer
This commit is contained in:
@@ -10,6 +10,7 @@ INSERT INTO room_ (owner, name, global, uuid) VALUES
|
|||||||
|
|
||||||
INSERT INTO membership_ (user_id, room) VALUES
|
INSERT INTO membership_ (user_id, room) VALUES
|
||||||
(1, 1), -- Alice in General Discussion
|
(1, 1), -- Alice in General Discussion
|
||||||
|
(1, 2), -- Alice in Tech Talk
|
||||||
(2, 2), -- Bob in Tech Talk
|
(2, 2), -- Bob in Tech Talk
|
||||||
(3, 1), -- Carol in General Discussion
|
(3, 1), -- Carol in General Discussion
|
||||||
(1, 3); -- Alice in Random Memes
|
(1, 3); -- Alice in Random Memes
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub struct AcceptRoomInvitePayload {
|
|||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
pub struct TransferOwnershipPayload {
|
pub struct TransferOwnershipPayload {
|
||||||
pub room_uuid: Uuid,
|
pub room_uuid: Uuid,
|
||||||
pub new_owner_uuid: Option<Uuid>,
|
pub new_owner_uuid: Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes() -> Router {
|
pub fn routes() -> Router {
|
||||||
@@ -670,8 +670,10 @@ async fn transfer_ownership(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let new_owner_id = user_id_from_uuid(&db, payload.new_owner_uuid).await?;
|
||||||
|
|
||||||
sqlx::query("UPDATE room_ SET owner = $1 WHERE id = $2")
|
sqlx::query("UPDATE room_ SET owner = $1 WHERE id = $2")
|
||||||
.bind(payload.new_owner_uuid)
|
.bind(new_owner_id)
|
||||||
.bind(room_id)
|
.bind(room_id)
|
||||||
.execute(&db)
|
.execute(&db)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user