feat: add account avatars and a deployable image
Accounts get a profile page with an uploaded picture, shown in the sidebar, the room bar, and every human message. Pictures live in the SQLite database and are served through an authenticated route. Hardening from the security audit: preview hosts expire after 24 hours and carry no-referrer; removing a member or archiving a room ends their event feed, presence socket, and terminal within seconds; previews and the terminal pin the SSH host key; invites are claimed atomically; missing accounts spend the same argon2 time as wrong passwords; registration is closed by default; WebSockets check the origin; and the master key is created with mode 0600. The Dockerfile builds one image with the static client and the server. The Helm chart runs a single replica with a SQLite volume, a wildcard preview ingress, and the proxy settings the event feed and uploads need. It refuses more than one replica because state is in process.
This commit is contained in:
1 parent
7e7a1d2bb6
commit
3b82719d56
38 files changed
+1307
-106
No files matched your search
+20
-3
@@ -8,7 +8,8 @@ use serde::Deserialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::auth::{
|
||||
self, AuthUser, clean_display_name, hash_password, valid_handle, verify_password,
|
||||
self, AuthUser, clean_display_name, dummy_password_hash, hash_password, valid_handle,
|
||||
verify_password,
|
||||
};
|
||||
use crate::error::{AppError, AppResult};
|
||||
use crate::models::User;
|
||||
@@ -109,6 +110,7 @@ pub async fn setup(
|
||||
handle,
|
||||
display_name,
|
||||
kind: "user".into(),
|
||||
avatar_updated_at: None,
|
||||
}),
|
||||
))
|
||||
}
|
||||
@@ -176,6 +178,7 @@ pub async fn register(
|
||||
handle,
|
||||
display_name,
|
||||
kind: "user".into(),
|
||||
avatar_updated_at: None,
|
||||
}),
|
||||
))
|
||||
}
|
||||
@@ -196,7 +199,9 @@ pub async fn login(
|
||||
.db
|
||||
.conn()
|
||||
.query_row(
|
||||
"SELECT id, handle, display_name, kind, password_hash FROM accounts
|
||||
"SELECT id, handle, display_name, kind, password_hash,
|
||||
(SELECT updated_at FROM avatars WHERE account_id = accounts.id)
|
||||
FROM accounts
|
||||
WHERE handle = ?1 OR (email IS NOT NULL AND email = ?1)
|
||||
LIMIT 1",
|
||||
rusqlite::params![identifier],
|
||||
@@ -207,11 +212,22 @@ pub async fn login(
|
||||
row.get::<_, String>(2)?,
|
||||
row.get::<_, String>(3)?,
|
||||
row.get::<_, Option<String>>(4)?,
|
||||
row.get::<_, Option<i64>>(5)?,
|
||||
))
|
||||
},
|
||||
)
|
||||
.ok();
|
||||
let Some((id, handle, display_name, kind, Some(password_hash))) = row else {
|
||||
let (id, handle, display_name, kind, password_hash, avatar_updated_at) = match row {
|
||||
Some(row) => row,
|
||||
None => {
|
||||
// Spend the same argon2 work as a real check so the response
|
||||
// time does not reveal whether the handle exists.
|
||||
let _ = verify_password(dummy_password_hash(), &body.password);
|
||||
return Err(AppError::unauthorized("wrong handle or password"));
|
||||
}
|
||||
};
|
||||
let Some(password_hash) = password_hash else {
|
||||
let _ = verify_password(dummy_password_hash(), &body.password);
|
||||
return Err(AppError::unauthorized("wrong handle or password"));
|
||||
};
|
||||
if !verify_password(&password_hash, &body.password) {
|
||||
@@ -227,6 +243,7 @@ pub async fn login(
|
||||
handle,
|
||||
display_name,
|
||||
kind,
|
||||
avatar_updated_at,
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
||||
+9
-1
@@ -6,6 +6,7 @@ use std::time::Duration;
|
||||
use axum::Json;
|
||||
use axum::extract::ws::WebSocketUpgrade;
|
||||
use axum::extract::{Path, Query, State};
|
||||
use axum::http::HeaderMap;
|
||||
use axum::response::Response;
|
||||
use rhema_sandbox::Sandbox;
|
||||
use rhema_sandbox::exec_util::shquote;
|
||||
@@ -233,9 +234,16 @@ pub async fn terminal(
|
||||
user: AuthUser,
|
||||
State(state): State<Shared>,
|
||||
Path(room): Path<String>,
|
||||
headers: HeaderMap,
|
||||
ws: WebSocketUpgrade,
|
||||
) -> AppResult<Response> {
|
||||
if !super::websocket_origin_ok(&state.config, &headers) {
|
||||
return Err(AppError::forbidden("websocket origin does not match"));
|
||||
}
|
||||
member_of(&state, &room, &user.user.id)?;
|
||||
let (workspace, target) = room_workspace(&state, &room)?;
|
||||
Ok(ws.on_upgrade(move |socket| crate::ssh::terminal(socket, state, workspace, target)))
|
||||
let account = user.user.id.clone();
|
||||
Ok(ws.on_upgrade(move |socket| {
|
||||
crate::ssh::terminal(socket, state, room, account, workspace, target)
|
||||
}))
|
||||
}
|
||||
+59
-14
@@ -7,6 +7,7 @@ use std::time::Duration;
|
||||
use axum::Json;
|
||||
use axum::extract::ws::{Message as WsMessage, WebSocket, WebSocketUpgrade};
|
||||
use axum::extract::{Path, Query, State};
|
||||
use axum::http::HeaderMap;
|
||||
use axum::response::Response;
|
||||
use axum::response::sse::{Event as SseEvent, KeepAlive, KeepAliveStream, Sse};
|
||||
use futures::{SinkExt, Stream, StreamExt};
|
||||
@@ -130,7 +131,15 @@ pub async fn events(
|
||||
Query(query): Query<Since>,
|
||||
) -> AppResult<Sse<KeepAliveStream<EventStream>>> {
|
||||
member_of(&state, &room, &user.user.id)?;
|
||||
let since = query.since.unwrap_or(0) as i64;
|
||||
let requested = query.since.unwrap_or(0).min(i64::MAX as u64) as i64;
|
||||
let max_seq: i64 = state.db.scalar(
|
||||
"SELECT COALESCE(MAX(seq), 0) FROM events WHERE room_id = ?1",
|
||||
rusqlite::params![room],
|
||||
)?;
|
||||
// A client asking for a future sequence must not skip everything
|
||||
// that arrives after it.
|
||||
let since = requested.min(max_seq);
|
||||
let user_id = user.user.id.clone();
|
||||
// Subscribe before reading the backlog: an event that lands between
|
||||
// the two is then either in the backlog or on the feed, never lost.
|
||||
let mut rx = state.hub.subscribe(&state.db, &room);
|
||||
@@ -161,21 +170,37 @@ pub async fn events(
|
||||
let data = serde_json::to_string(&envelope).unwrap_or_else(|_| "{}".into());
|
||||
yield Ok(SseEvent::default().id(envelope.seq.to_string()).data(data));
|
||||
}
|
||||
let mut access = tokio::time::interval(Duration::from_secs(2));
|
||||
loop {
|
||||
match rx.recv().await {
|
||||
Ok(envelope) => {
|
||||
if envelope.seq <= last {
|
||||
continue;
|
||||
tokio::select! {
|
||||
_ = access.tick() => {
|
||||
if member_of(&state, &room, &user_id).is_err() {
|
||||
break;
|
||||
}
|
||||
last = envelope.seq;
|
||||
let data = serde_json::to_string(&envelope).unwrap_or_else(|_| "{}".into());
|
||||
yield Ok(SseEvent::default().id(envelope.seq.to_string()).data(data));
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => {
|
||||
let data = json!({ "seq": last, "kind": "lag", "data": {} }).to_string();
|
||||
yield Ok(SseEvent::default().event("lag").data(data));
|
||||
message = rx.recv() => {
|
||||
match message {
|
||||
Ok(envelope) => {
|
||||
if member_of(&state, &room, &user_id).is_err() {
|
||||
break;
|
||||
}
|
||||
if envelope.seq <= last {
|
||||
continue;
|
||||
}
|
||||
last = envelope.seq;
|
||||
let data = serde_json::to_string(&envelope).unwrap_or_else(|_| "{}".into());
|
||||
yield Ok(SseEvent::default().id(envelope.seq.to_string()).data(data));
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Lagged(_)) => {
|
||||
if member_of(&state, &room, &user_id).is_err() {
|
||||
break;
|
||||
}
|
||||
let data = json!({ "seq": last, "kind": "lag", "data": {} }).to_string();
|
||||
yield Ok(SseEvent::default().event("lag").data(data));
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Closed) => break,
|
||||
}
|
||||
}
|
||||
Err(tokio::sync::broadcast::error::RecvError::Closed) => break,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,13 +217,24 @@ pub async fn presence(
|
||||
user: AuthUser,
|
||||
State(state): State<Shared>,
|
||||
Path(room): Path<String>,
|
||||
headers: HeaderMap,
|
||||
ws: WebSocketUpgrade,
|
||||
) -> AppResult<Response> {
|
||||
if !super::websocket_origin_ok(&state.config, &headers) {
|
||||
return Err(AppError::forbidden("websocket origin does not match"));
|
||||
}
|
||||
let member = member_of(&state, &room, &user.user.id)?;
|
||||
Ok(ws.on_upgrade(move |socket| presence_loop(socket, state, room, member)))
|
||||
let account = user.user.id.clone();
|
||||
Ok(ws.on_upgrade(move |socket| presence_loop(socket, state, room, account, member)))
|
||||
}
|
||||
|
||||
async fn presence_loop(socket: WebSocket, state: Shared, room: String, member: Membership) {
|
||||
async fn presence_loop(
|
||||
socket: WebSocket,
|
||||
state: Shared,
|
||||
room: String,
|
||||
account: String,
|
||||
member: Membership,
|
||||
) {
|
||||
let (mut sink, mut source) = socket.split();
|
||||
let peer = Peer {
|
||||
member_id: member.id.clone(),
|
||||
@@ -209,8 +245,14 @@ async fn presence_loop(socket: WebSocket, state: Shared, room: String, member: M
|
||||
let (id, snapshot, mut updates) = state.presence.join(&room, peer);
|
||||
let _ = send_presence(&mut sink, &snapshot).await;
|
||||
let mut ping = tokio::time::interval(Duration::from_secs(25));
|
||||
let mut access = tokio::time::interval(Duration::from_secs(2));
|
||||
loop {
|
||||
tokio::select! {
|
||||
_ = access.tick() => {
|
||||
if member_of(&state, &room, &account).is_err() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
message = source.next() => {
|
||||
match message {
|
||||
Some(Ok(WsMessage::Text(text))) => {
|
||||
@@ -230,6 +272,9 @@ async fn presence_loop(socket: WebSocket, state: Shared, room: String, member: M
|
||||
}
|
||||
}
|
||||
_ = ping.tick() => {
|
||||
if member_of(&state, &room, &account).is_err() {
|
||||
break;
|
||||
}
|
||||
if sink.send(WsMessage::Ping(Vec::new().into())).await.is_err() {
|
||||
break;
|
||||
}
|
||||
|
||||
+37
-2
@@ -4,13 +4,14 @@
|
||||
pub mod auth;
|
||||
pub mod files;
|
||||
pub mod messages;
|
||||
pub mod profile;
|
||||
pub mod rooms;
|
||||
pub mod settings;
|
||||
|
||||
use axum::Router;
|
||||
use axum::body::Body;
|
||||
use axum::extract::{Request, State};
|
||||
use axum::http::{HeaderValue, StatusCode, Uri, header};
|
||||
use axum::extract::{DefaultBodyLimit, Request, State};
|
||||
use axum::http::{HeaderMap, HeaderValue, StatusCode, Uri, header};
|
||||
use axum::middleware::{self, Next};
|
||||
use axum::response::{Html, IntoResponse, Response};
|
||||
use axum::routing::{delete, get, post};
|
||||
@@ -28,6 +29,13 @@ pub fn router(state: Shared) -> Router {
|
||||
.route("/register", post(auth::register))
|
||||
.route("/login", post(auth::login))
|
||||
.route("/logout", post(auth::logout))
|
||||
.route(
|
||||
"/profile/avatar",
|
||||
post(profile::upload_avatar)
|
||||
.delete(profile::delete_avatar)
|
||||
.layer(DefaultBodyLimit::max(profile::MAX_AVATAR_BYTES + 64 * 1024)),
|
||||
)
|
||||
.route("/avatars/{account}", get(profile::get_avatar))
|
||||
.route(
|
||||
"/provider-configs",
|
||||
get(settings::list_providers).post(settings::create_provider),
|
||||
@@ -72,6 +80,27 @@ pub fn router(state: Shared) -> Router {
|
||||
.with_state(state)
|
||||
}
|
||||
|
||||
/// Whether a browser WebSocket handshake came from the app's origin.
|
||||
/// A client that sends no `Origin` is not a browser page and is left to
|
||||
/// the cookie check.
|
||||
pub(crate) fn websocket_origin_ok(config: &crate::config::Config, headers: &HeaderMap) -> bool {
|
||||
let Some(origin) = headers
|
||||
.get(header::ORIGIN)
|
||||
.and_then(|value| value.to_str().ok())
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
let origin = origin.trim_end_matches('/');
|
||||
let public = config.public_url.trim_end_matches('/');
|
||||
if origin == public {
|
||||
return true;
|
||||
}
|
||||
// The Nuxt dev server proxies the sockets from port 3000 while the
|
||||
// API keeps its own port. Both are loopback, so accept that pair.
|
||||
let loopback = public.starts_with("http://localhost") || public.starts_with("http://127.0.0.1");
|
||||
loopback && (origin.starts_with("http://localhost:") || origin.starts_with("http://127.0.0.1:"))
|
||||
}
|
||||
|
||||
/// Rejects a mutating API request without the matching CSRF header.
|
||||
/// Setup, login, registration, and joining with an invite happen before
|
||||
/// the client has a CSRF cookie.
|
||||
@@ -122,6 +151,12 @@ async fn headers(State(state): State<Shared>, request: Request, next: Next) -> R
|
||||
HeaderValue::from_static("strict-origin-when-cross-origin"),
|
||||
);
|
||||
h.insert(header::X_FRAME_OPTIONS, HeaderValue::from_static("DENY"));
|
||||
if state.config.secure_cookies() {
|
||||
h.insert(
|
||||
header::STRICT_TRANSPORT_SECURITY,
|
||||
HeaderValue::from_static("max-age=31536000"),
|
||||
);
|
||||
}
|
||||
let frame_src = match state.config.preview_frame_source() {
|
||||
Some(source) => format!("'self' {source}"),
|
||||
None => "'self'".to_owned(),
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
//! The account's picture: a small image served back to rooms and the
|
||||
//! sidebar. The client resizes before upload; the server checks the
|
||||
//! magic bytes and the size so a crafted request cannot store markup.
|
||||
|
||||
use axum::Json;
|
||||
use axum::body::Bytes;
|
||||
use axum::extract::{Path, State};
|
||||
use axum::http::{HeaderValue, StatusCode, header};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
|
||||
use crate::auth::AuthUser;
|
||||
use crate::error::{AppError, AppResult};
|
||||
use crate::models::User;
|
||||
use crate::state::Shared;
|
||||
use crate::util::now_ms;
|
||||
|
||||
/// Two megabytes fits a 512px JPEG many times over.
|
||||
pub const MAX_AVATAR_BYTES: usize = 2 * 1024 * 1024;
|
||||
|
||||
/// The image type named by the file's first bytes. SVG is deliberately
|
||||
/// absent: it can carry script when opened as a document.
|
||||
fn image_mime(bytes: &[u8]) -> Option<&'static str> {
|
||||
if bytes.starts_with(b"\x89PNG\r\n\x1a\n") {
|
||||
Some("image/png")
|
||||
} else if bytes.starts_with(&[0xFF, 0xD8, 0xFF]) {
|
||||
Some("image/jpeg")
|
||||
} else if bytes.starts_with(b"GIF87a") || bytes.starts_with(b"GIF89a") {
|
||||
Some("image/gif")
|
||||
} else if bytes.len() >= 12 && bytes.starts_with(b"RIFF") && &bytes[8..12] == b"WEBP" {
|
||||
Some("image/webp")
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The stored picture. Any signed-in account may read one.
|
||||
pub async fn get_avatar(
|
||||
_user: AuthUser,
|
||||
State(state): State<Shared>,
|
||||
Path(account): Path<String>,
|
||||
) -> AppResult<Response> {
|
||||
let row = state
|
||||
.db
|
||||
.conn()
|
||||
.query_row(
|
||||
"SELECT mime, bytes FROM avatars WHERE account_id = ?1",
|
||||
rusqlite::params![account],
|
||||
|row| Ok((row.get::<_, String>(0)?, row.get::<_, Vec<u8>>(1)?)),
|
||||
)
|
||||
.ok();
|
||||
let Some((mime, bytes)) = row else {
|
||||
return Err(AppError::not_found("no picture for this account"));
|
||||
};
|
||||
let mut response = bytes.into_response();
|
||||
let headers = response.headers_mut();
|
||||
headers.insert(
|
||||
header::CONTENT_TYPE,
|
||||
HeaderValue::from_static(match mime.as_str() {
|
||||
"image/png" => "image/png",
|
||||
"image/jpeg" => "image/jpeg",
|
||||
"image/gif" => "image/gif",
|
||||
"image/webp" => "image/webp",
|
||||
_ => "application/octet-stream",
|
||||
}),
|
||||
);
|
||||
headers.insert(
|
||||
header::CACHE_CONTROL,
|
||||
HeaderValue::from_static("private, max-age=300"),
|
||||
);
|
||||
headers.insert(
|
||||
header::X_CONTENT_TYPE_OPTIONS,
|
||||
HeaderValue::from_static("nosniff"),
|
||||
);
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
/// Replaces the caller's picture with the raw request body.
|
||||
pub async fn upload_avatar(
|
||||
user: AuthUser,
|
||||
State(state): State<Shared>,
|
||||
body: Bytes,
|
||||
) -> AppResult<Json<User>> {
|
||||
if body.is_empty() {
|
||||
return Err(AppError::bad_request("the picture is empty"));
|
||||
}
|
||||
if body.len() > MAX_AVATAR_BYTES {
|
||||
return Err(AppError::new(
|
||||
StatusCode::PAYLOAD_TOO_LARGE,
|
||||
"the picture must be 2 MB or smaller",
|
||||
));
|
||||
}
|
||||
let mime = image_mime(&body).ok_or_else(|| {
|
||||
AppError::bad_request("the picture must be a PNG, JPEG, GIF, or WebP image")
|
||||
})?;
|
||||
let mut account = user.user;
|
||||
let now = now_ms();
|
||||
state.db.conn().execute(
|
||||
"INSERT INTO avatars (account_id, mime, bytes, updated_at)
|
||||
VALUES (?1, ?2, ?3, ?4)
|
||||
ON CONFLICT(account_id) DO UPDATE SET
|
||||
mime = excluded.mime,
|
||||
bytes = excluded.bytes,
|
||||
updated_at = excluded.updated_at",
|
||||
rusqlite::params![&account.id, mime, body.as_ref(), now],
|
||||
)?;
|
||||
account.avatar_updated_at = Some(now);
|
||||
Ok(Json(account))
|
||||
}
|
||||
|
||||
/// Removes the caller's picture and falls the avatar back to initials.
|
||||
pub async fn delete_avatar(user: AuthUser, State(state): State<Shared>) -> AppResult<Json<User>> {
|
||||
let mut account = user.user;
|
||||
state.db.conn().execute(
|
||||
"DELETE FROM avatars WHERE account_id = ?1",
|
||||
rusqlite::params![&account.id],
|
||||
)?;
|
||||
account.avatar_updated_at = None;
|
||||
Ok(Json(account))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::image_mime;
|
||||
|
||||
#[test]
|
||||
fn recognizes_the_four_image_types() {
|
||||
assert_eq!(image_mime(b"\x89PNG\r\n\x1a\nrest"), Some("image/png"));
|
||||
assert_eq!(image_mime(&[0xFF, 0xD8, 0xFF, 0xE0]), Some("image/jpeg"));
|
||||
assert_eq!(image_mime(b"GIF89a..."), Some("image/gif"));
|
||||
assert_eq!(image_mime(b"RIFF\0\0\0\0WEBPVP8 "), Some("image/webp"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_markup_and_unknown_bytes() {
|
||||
assert_eq!(
|
||||
image_mime(b"<svg xmlns=\"http://www.w3.org/2000/svg\">"),
|
||||
None
|
||||
);
|
||||
assert_eq!(image_mime(b"RIFF\0\0\0\0WAVEfmt "), None);
|
||||
assert_eq!(image_mime(b""), None);
|
||||
}
|
||||
}
|
||||
+20
-4
@@ -88,8 +88,10 @@ fn load_members(state: &Shared, room: &str) -> AppResult<Vec<Member>> {
|
||||
let online = state.presence.online(room);
|
||||
let conn = state.db.conn();
|
||||
let mut stmt = conn.prepare(
|
||||
"SELECT id, account_id, display_name, role, color FROM members
|
||||
WHERE room_id = ?1 ORDER BY created_at ASC",
|
||||
"SELECT m.id, m.account_id, m.display_name, m.role, m.color,
|
||||
(SELECT updated_at FROM avatars WHERE account_id = m.account_id)
|
||||
FROM members m
|
||||
WHERE m.room_id = ?1 ORDER BY m.created_at ASC",
|
||||
)?;
|
||||
let rows = stmt.query_map(rusqlite::params![room], |row| {
|
||||
Ok(Member {
|
||||
@@ -98,6 +100,7 @@ fn load_members(state: &Shared, room: &str) -> AppResult<Vec<Member>> {
|
||||
display_name: row.get(2)?,
|
||||
role: row.get(3)?,
|
||||
color: row.get(4)?,
|
||||
avatar_updated_at: row.get(5)?,
|
||||
online: false,
|
||||
})
|
||||
})?;
|
||||
@@ -504,6 +507,18 @@ pub async fn join(
|
||||
return Err(AppError::gone("this invite has expired"));
|
||||
}
|
||||
let display_name = clean_display_name(&body.display_name)?;
|
||||
// Claim the invite before creating an account or a member. The
|
||||
// conditional update is atomic, so two requests racing with the
|
||||
// same link cannot both redeem it.
|
||||
let token_hash = sha256_hex(token.as_bytes());
|
||||
let claimed = state.db.conn().execute(
|
||||
"UPDATE invites SET used_at = ?1
|
||||
WHERE token_hash = ?2 AND used_at IS NULL AND expires_at >= ?1",
|
||||
rusqlite::params![now_ms(), &token_hash],
|
||||
)?;
|
||||
if claimed == 0 {
|
||||
return Err(AppError::gone("this invite was already used"));
|
||||
}
|
||||
let existing = auth::user_from_headers(&state, &headers);
|
||||
let mut new_session = false;
|
||||
let account = match existing {
|
||||
@@ -522,6 +537,7 @@ pub async fn join(
|
||||
handle,
|
||||
display_name,
|
||||
kind: "guest".into(),
|
||||
avatar_updated_at: None,
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -559,8 +575,8 @@ pub async fn join(
|
||||
}
|
||||
};
|
||||
state.db.conn().execute(
|
||||
"UPDATE invites SET used_at = ?1, used_by = ?2 WHERE token_hash = ?3",
|
||||
rusqlite::params![now_ms(), account.id, sha256_hex(token.as_bytes())],
|
||||
"UPDATE invites SET used_by = ?1 WHERE token_hash = ?2",
|
||||
rusqlite::params![account.id, token_hash],
|
||||
)?;
|
||||
let cookies = if new_session {
|
||||
let raw = auth::create_session(&state, &account.id)?;
|
||||
|
||||
@@ -257,6 +257,7 @@ pub async fn delete_target(
|
||||
"DELETE FROM sandbox_targets WHERE id = ?1 AND account_id = ?2",
|
||||
rusqlite::params![id, user.user.id],
|
||||
)?;
|
||||
state.previews.forget(&id);
|
||||
Ok(Json(json!({ "ok": true })))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user