feat: add teleport

This commit is contained in:
Evan Carroll 2026-01-19 11:48:12 -06:00
parent 226c2e02b5
commit 32e5e42462
11 changed files with 603 additions and 16 deletions

View file

@ -489,6 +489,7 @@ pub struct Realm {
pub thumbnail_path: Option<String>,
pub max_users: i32,
pub allow_guest_access: bool,
pub allow_user_teleport: bool,
pub default_scene_id: Option<Uuid>,
pub member_count: i32,
pub current_user_count: i32,
@ -516,6 +517,7 @@ pub struct CreateRealmRequest {
pub is_nsfw: bool,
pub max_users: i32,
pub allow_guest_access: bool,
pub allow_user_teleport: bool,
pub theme_color: Option<String>,
}
@ -1361,6 +1363,7 @@ pub struct RealmDetail {
pub thumbnail_path: Option<String>,
pub max_users: i32,
pub allow_guest_access: bool,
pub allow_user_teleport: bool,
pub member_count: i32,
pub current_user_count: i32,
pub created_at: DateTime<Utc>,
@ -1377,6 +1380,7 @@ pub struct UpdateRealmRequest {
pub is_nsfw: bool,
pub max_users: i32,
pub allow_guest_access: bool,
pub allow_user_teleport: bool,
pub theme_color: Option<String>,
}

View file

@ -254,6 +254,7 @@ pub async fn get_realm_by_slug(pool: &PgPool, slug: &str) -> Result<RealmDetail,
r.thumbnail_path,
r.max_users,
r.allow_guest_access,
r.allow_user_teleport,
r.member_count,
COALESCE((
SELECT COUNT(*)::INTEGER
@ -294,9 +295,10 @@ pub async fn update_realm(
is_nsfw = $5,
max_users = $6,
allow_guest_access = $7,
theme_color = $8,
allow_user_teleport = $8,
theme_color = $9,
updated_at = now()
WHERE id = $9
WHERE id = $10
"#,
)
.bind(&req.name)
@ -306,6 +308,7 @@ pub async fn update_realm(
.bind(req.is_nsfw)
.bind(req.max_users)
.bind(req.allow_guest_access)
.bind(req.allow_user_teleport)
.bind(&req.theme_color)
.bind(realm_id)
.execute(pool)
@ -331,6 +334,7 @@ pub async fn update_realm(
r.thumbnail_path,
r.max_users,
r.allow_guest_access,
r.allow_user_teleport,
r.member_count,
COALESCE((
SELECT COUNT(*)::INTEGER

View file

@ -17,9 +17,9 @@ pub async fn create_realm(
r#"
INSERT INTO realm.realms (
name, slug, description, tagline, owner_id,
privacy, is_nsfw, max_users, allow_guest_access, theme_color
privacy, is_nsfw, max_users, allow_guest_access, allow_user_teleport, theme_color
)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
RETURNING
id,
name,
@ -35,6 +35,7 @@ pub async fn create_realm(
thumbnail_path,
max_users,
allow_guest_access,
allow_user_teleport,
default_scene_id,
member_count,
current_user_count,
@ -51,6 +52,7 @@ pub async fn create_realm(
.bind(req.is_nsfw)
.bind(req.max_users)
.bind(req.allow_guest_access)
.bind(req.allow_user_teleport)
.bind(&req.theme_color)
.fetch_one(pool)
.await?;
@ -91,6 +93,7 @@ pub async fn get_realm_by_slug<'e>(
r.thumbnail_path,
r.max_users,
r.allow_guest_access,
r.allow_user_teleport,
r.default_scene_id,
r.member_count,
COALESCE((
@ -131,6 +134,7 @@ pub async fn get_realm_by_id(pool: &PgPool, id: Uuid) -> Result<Option<Realm>, A
r.thumbnail_path,
r.max_users,
r.allow_guest_access,
r.allow_user_teleport,
r.default_scene_id,
r.member_count,
COALESCE((

View file

@ -76,6 +76,12 @@ pub enum ClientMessage {
/// Request to broadcast avatar appearance to other users.
SyncAvatar,
/// Request to teleport to a different scene.
Teleport {
/// Scene ID to teleport to.
scene_id: Uuid,
},
}
/// Server-to-client WebSocket messages.
@ -212,4 +218,12 @@ pub enum ServerMessage {
/// Updated avatar render data.
avatar: AvatarRenderData,
},
/// Teleport approved - client should disconnect and reconnect to new scene.
TeleportApproved {
/// Scene ID to navigate to.
scene_id: Uuid,
/// Scene slug for URL.
scene_slug: String,
},
}