new functions
This commit is contained in:
+65
-1
@@ -41,7 +41,8 @@ fn bearer_token(headers: &HeaderMap) -> Option<&str> {
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct PublishResponse {
|
||||
url: String,
|
||||
url: Option<String>,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
@@ -83,6 +84,7 @@ pub struct PublishRequest {
|
||||
allow_task_updates: bool,
|
||||
#[serde(default)]
|
||||
unprotect_page: bool,
|
||||
enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -153,11 +155,16 @@ pub struct NoteInfo {
|
||||
note_protected: bool,
|
||||
allow_public_task_updates: bool,
|
||||
public_page_unprotected: bool,
|
||||
public_page_enabled: bool,
|
||||
private: bool,
|
||||
created_at: String,
|
||||
updated_at: String,
|
||||
can_delete_files: bool,
|
||||
global_color: Option<String>,
|
||||
note_color: Option<String>,
|
||||
authorship_mode: String,
|
||||
colors_enabled: bool,
|
||||
can_save_editor_settings: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -165,6 +172,44 @@ pub struct EditorColorRequest {
|
||||
color: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct EditorSettingsRequest {
|
||||
authorship_mode: String,
|
||||
colors_enabled: bool,
|
||||
}
|
||||
|
||||
async fn editor_settings(state: &SharedState, kind: &str, slug: &str) -> Result<(String, bool), ApiError> {
|
||||
let row: Option<(String, i64)> = sqlx::query_as(queries::get(
|
||||
state.db.kind(),
|
||||
queries::RESOURCE_EDITOR_SETTINGS_SELECT,
|
||||
))
|
||||
.bind(kind)
|
||||
.bind(slug)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await?;
|
||||
Ok(row.map(|(mode, colors)| (if mode == "full" { "full".into() } else { "simple".into() }, colors != 0))
|
||||
.unwrap_or_else(|| ("simple".into(), true)))
|
||||
}
|
||||
|
||||
async fn save_editor_settings(
|
||||
state: &SharedState, headers: &HeaderMap, permission_kind: &str, permission_slug: &str,
|
||||
settings_kind: &str, settings_slug: &str, payload: EditorSettingsRequest,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let permission = crate::auth::resource_permission(state, permission_kind, permission_slug, bearer_token(headers))
|
||||
.await.map_err(|e| ApiError::forbidden(&e.message))?;
|
||||
if permission.as_deref() != Some("rw") {
|
||||
return Err(ApiError::forbidden("Read and write access is required to save editor settings"));
|
||||
}
|
||||
let mode = match payload.authorship_mode.as_str() { "simple" => "simple", "full" | "advanced" => "full", _ => return Err(ApiError::bad_request("Invalid authorship mode")) };
|
||||
let mut tx = state.db.pool().begin().await?;
|
||||
sqlx::query(queries::get(state.db.kind(), queries::RESOURCE_EDITOR_SETTINGS_DELETE))
|
||||
.bind(settings_kind).bind(settings_slug).execute(&mut *tx).await?;
|
||||
sqlx::query(queries::get(state.db.kind(), queries::RESOURCE_EDITOR_SETTINGS_INSERT))
|
||||
.bind(settings_kind).bind(settings_slug).bind(mode).bind(payload.colors_enabled).execute(&mut *tx).await?;
|
||||
tx.commit().await?;
|
||||
Ok(Json(serde_json::json!({"authorship_mode": mode, "colors_enabled": payload.colors_enabled})))
|
||||
}
|
||||
|
||||
pub async fn create_workspace(
|
||||
State(state): State<SharedState>,
|
||||
headers: HeaderMap,
|
||||
@@ -439,7 +484,12 @@ pub async fn note_info(
|
||||
.ok_or_else(ApiError::not_found_note)?;
|
||||
let color_slug = format!("{}/{}", workspace_slug, note_slug);
|
||||
let (global_color, note_color) = editor_colors(&state, &headers, "note", &color_slug).await?;
|
||||
let (authorship_mode, colors_enabled) = editor_settings(&state, "note", &color_slug).await?;
|
||||
let can_save_editor_settings = crate::auth::resource_permission(&state, "workspace", &workspace_slug, bearer_token(&headers)).await.ok().flatten().as_deref() == Some("rw");
|
||||
|
||||
if workspace.is_private == 0 && !db::note_public_page_disabled(&state.db, note.id).await? && !db::note_public_page_enabled(&state.db, note.id).await? {
|
||||
db::publish_note(&state.db, note.id).await?;
|
||||
}
|
||||
Ok(Json(NoteInfo {
|
||||
workspace_slug: workspace.slug,
|
||||
workspace_title: workspace.title,
|
||||
@@ -449,6 +499,8 @@ pub async fn note_info(
|
||||
note_protected: note.protected,
|
||||
allow_public_task_updates: db::note_public_task_updates(&state.db, note.id).await?,
|
||||
public_page_unprotected: db::note_public_page_unprotected(&state.db, note.id).await?,
|
||||
public_page_enabled: db::note_public_page_enabled(&state.db, note.id).await?,
|
||||
private: workspace.is_private != 0,
|
||||
created_at: db::normalize_timestamp(¬e.created_at),
|
||||
updated_at: db::normalize_timestamp(¬e.updated_at),
|
||||
can_delete_files: {
|
||||
@@ -474,9 +526,21 @@ pub async fn note_info(
|
||||
},
|
||||
global_color,
|
||||
note_color,
|
||||
authorship_mode,
|
||||
colors_enabled,
|
||||
can_save_editor_settings,
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn set_note_editor_settings(
|
||||
State(state): State<SharedState>, headers: HeaderMap,
|
||||
Path((workspace_slug, note_slug)): Path<(String, String)>,
|
||||
Json(payload): Json<EditorSettingsRequest>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let settings_slug = format!("{}/{}", workspace_slug, note_slug);
|
||||
save_editor_settings(&state, &headers, "workspace", &workspace_slug, "note", &settings_slug, payload).await
|
||||
}
|
||||
|
||||
pub async fn history(
|
||||
State(state): State<SharedState>,
|
||||
headers: HeaderMap,
|
||||
|
||||
+38
-2
@@ -20,11 +20,16 @@ pub struct PadInfo {
|
||||
protected: bool,
|
||||
allow_public_task_updates: bool,
|
||||
public_page_unprotected: bool,
|
||||
public_page_enabled: bool,
|
||||
private: bool,
|
||||
created_at: String,
|
||||
updated_at: String,
|
||||
can_delete_files: bool,
|
||||
global_color: Option<String>,
|
||||
note_color: Option<String>,
|
||||
authorship_mode: String,
|
||||
colors_enabled: bool,
|
||||
can_save_editor_settings: bool,
|
||||
}
|
||||
|
||||
pub async fn create_pad(
|
||||
@@ -78,12 +83,19 @@ pub async fn pad_info(
|
||||
)
|
||||
.await?;
|
||||
let (global_color, note_color) = editor_colors(&state, &headers, "pad", &slug).await?;
|
||||
let (authorship_mode, colors_enabled) = editor_settings(&state, "pad", &slug).await?;
|
||||
let can_save_editor_settings = crate::auth::resource_permission(&state, "pad", &slug, bearer_token(&headers)).await.ok().flatten().as_deref() == Some("rw");
|
||||
if pad.is_private == 0 && !db::pad_public_page_disabled(&state.db, pad.id).await? && !db::pad_public_page_enabled(&state.db, pad.id).await? {
|
||||
db::publish_pad(&state.db, pad.id).await?;
|
||||
}
|
||||
Ok(Json(PadInfo {
|
||||
slug: pad.slug,
|
||||
title: pad.title,
|
||||
protected: pad.password_hash.is_some(),
|
||||
allow_public_task_updates: db::pad_public_task_updates(&state.db, pad.id).await?,
|
||||
public_page_unprotected: db::pad_public_page_unprotected(&state.db, pad.id).await?,
|
||||
public_page_enabled: db::pad_public_page_enabled(&state.db, pad.id).await?,
|
||||
private: pad.is_private != 0,
|
||||
created_at: db::normalize_timestamp(&pad.created_at),
|
||||
updated_at: db::normalize_timestamp(&pad.updated_at),
|
||||
can_delete_files: crate::auth::is_resource_owner(
|
||||
@@ -96,9 +108,19 @@ pub async fn pad_info(
|
||||
.unwrap_or(false),
|
||||
global_color,
|
||||
note_color,
|
||||
authorship_mode,
|
||||
colors_enabled,
|
||||
can_save_editor_settings,
|
||||
}))
|
||||
}
|
||||
|
||||
pub async fn set_pad_editor_settings(
|
||||
State(state): State<SharedState>, headers: HeaderMap, Path(slug): Path<String>,
|
||||
Json(payload): Json<EditorSettingsRequest>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
save_editor_settings(&state, &headers, "pad", &slug, "pad", &slug, payload).await
|
||||
}
|
||||
|
||||
pub async fn pad_editor_color(
|
||||
State(state): State<SharedState>,
|
||||
headers: HeaderMap,
|
||||
@@ -181,11 +203,18 @@ pub async fn publish_pad_page(
|
||||
.await?
|
||||
};
|
||||
require_write(level)?;
|
||||
let enabled = payload.enabled.unwrap_or(true);
|
||||
if !enabled {
|
||||
db::unpublish_pad(&state.db, pad.id).await?;
|
||||
db::set_pad_public_page_disabled(&state.db, pad.id, true).await?;
|
||||
return Ok(Json(PublishResponse { url: None, enabled: false }));
|
||||
}
|
||||
db::set_pad_public_page_disabled(&state.db, pad.id, false).await?;
|
||||
let token = db::publish_pad(&state.db, pad.id).await?;
|
||||
db::set_pad_public_task_updates(&state.db, pad.id, payload.allow_task_updates).await?;
|
||||
db::set_pad_public_page_unprotected(&state.db, pad.id, payload.unprotect_page).await?;
|
||||
Ok(Json(PublishResponse {
|
||||
url: format!("/s/{token}"),
|
||||
url: Some(format!("/s/{token}")), enabled: true,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -219,11 +248,18 @@ pub async fn publish_note_page(
|
||||
.await?
|
||||
};
|
||||
require_write(level)?;
|
||||
let enabled = payload.enabled.unwrap_or(true);
|
||||
if !enabled {
|
||||
db::unpublish_note(&state.db, note.id).await?;
|
||||
db::set_note_public_page_disabled(&state.db, note.id, true).await?;
|
||||
return Ok(Json(PublishResponse { url: None, enabled: false }));
|
||||
}
|
||||
db::set_note_public_page_disabled(&state.db, note.id, false).await?;
|
||||
let token = db::publish_note(&state.db, note.id).await?;
|
||||
db::set_note_public_task_updates(&state.db, note.id, payload.allow_task_updates).await?;
|
||||
db::set_note_public_page_unprotected(&state.db, note.id, payload.unprotect_page).await?;
|
||||
Ok(Json(PublishResponse {
|
||||
url: format!("/s/{token}"),
|
||||
url: Some(format!("/s/{token}")), enabled: true,
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ pub fn router(
|
||||
"/api/pads/{slug}/editor-color",
|
||||
get(api::pad_editor_color).post(api::set_pad_editor_color),
|
||||
)
|
||||
.route("/api/pads/{slug}/editor-settings", post(api::set_pad_editor_settings))
|
||||
.route("/api/pads/{slug}/publish", post(api::publish_pad_page))
|
||||
.route("/api/pads/{slug}/restore", post(api::pad_restore))
|
||||
.route(
|
||||
@@ -146,6 +147,7 @@ pub fn router(
|
||||
"/api/workspaces/{workspace_slug}/notes/{note_slug}/editor-color",
|
||||
get(api::note_editor_color).post(api::set_note_editor_color),
|
||||
)
|
||||
.route("/api/workspaces/{workspace_slug}/notes/{note_slug}/editor-settings", post(api::set_note_editor_settings))
|
||||
.route(
|
||||
"/api/workspaces/{workspace_slug}/notes/{note_slug}/publish",
|
||||
post(api::publish_note_page),
|
||||
|
||||
@@ -94,6 +94,28 @@ pub async fn publish_note(pool: &Database, note_id: i64) -> Result<String, sqlx:
|
||||
Ok(token)
|
||||
}
|
||||
|
||||
pub async fn pad_public_page_enabled(pool: &Database, pad_id: i64) -> Result<bool, sqlx::Error> {
|
||||
Ok(sqlx::query_scalar::<_, String>(queries::get(pool.kind(), queries::Q017))
|
||||
.bind(pad_id).fetch_optional(pool.pool()).await?.is_some())
|
||||
}
|
||||
|
||||
pub async fn note_public_page_enabled(pool: &Database, note_id: i64) -> Result<bool, sqlx::Error> {
|
||||
Ok(sqlx::query_scalar::<_, String>(queries::get(pool.kind(), queries::Q019))
|
||||
.bind(note_id).fetch_optional(pool.pool()).await?.is_some())
|
||||
}
|
||||
|
||||
pub async fn unpublish_pad(pool: &Database, pad_id: i64) -> Result<(), sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "DELETE FROM published_pages WHERE pad_id = $1", _ => "DELETE FROM published_pages WHERE pad_id = ?" };
|
||||
sqlx::query(sql).bind(pad_id).execute(pool.pool()).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn unpublish_note(pool: &Database, note_id: i64) -> Result<(), sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "DELETE FROM published_pages WHERE note_id = $1", _ => "DELETE FROM published_pages WHERE note_id = ?" };
|
||||
sqlx::query(sql).bind(note_id).execute(pool.pool()).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn find_published_page(
|
||||
pool: &Database,
|
||||
token: &str,
|
||||
@@ -342,3 +364,29 @@ impl<'r> sqlx::FromRow<'r, AnyRow> for PostgresPublishedPageRow {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn pad_public_page_disabled(pool: &Database, pad_id: i64) -> Result<bool, sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "SELECT public_page_disabled FROM pads WHERE id = $1", _ => "SELECT public_page_disabled FROM pads WHERE id = ?" };
|
||||
if pool.kind() == DatabaseKind::Postgres { return Ok(sqlx::query_scalar::<_, bool>(sql).bind(pad_id).fetch_one(pool.pool()).await?); }
|
||||
Ok(sqlx::query_scalar::<_, i64>(sql).bind(pad_id).fetch_one(pool.pool()).await? != 0)
|
||||
}
|
||||
|
||||
pub async fn note_public_page_disabled(pool: &Database, note_id: i64) -> Result<bool, sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "SELECT public_page_disabled FROM notes WHERE id = $1", _ => "SELECT public_page_disabled FROM notes WHERE id = ?" };
|
||||
if pool.kind() == DatabaseKind::Postgres { return Ok(sqlx::query_scalar::<_, bool>(sql).bind(note_id).fetch_one(pool.pool()).await?); }
|
||||
Ok(sqlx::query_scalar::<_, i64>(sql).bind(note_id).fetch_one(pool.pool()).await? != 0)
|
||||
}
|
||||
|
||||
pub async fn set_pad_public_page_disabled(pool: &Database, pad_id: i64, disabled: bool) -> Result<(), sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "UPDATE pads SET public_page_disabled = $1 WHERE id = $2", _ => "UPDATE pads SET public_page_disabled = ? WHERE id = ?" };
|
||||
let mut query = sqlx::query(sql);
|
||||
query = if pool.kind() == DatabaseKind::Postgres { query.bind(disabled) } else { query.bind(if disabled { 1i64 } else { 0i64 }) };
|
||||
query.bind(pad_id).execute(pool.pool()).await?; Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_note_public_page_disabled(pool: &Database, note_id: i64, disabled: bool) -> Result<(), sqlx::Error> {
|
||||
let sql = match pool.kind() { DatabaseKind::Postgres => "UPDATE notes SET public_page_disabled = $1 WHERE id = $2", _ => "UPDATE notes SET public_page_disabled = ? WHERE id = ?" };
|
||||
let mut query = sqlx::query(sql);
|
||||
query = if pool.kind() == DatabaseKind::Postgres { query.bind(disabled) } else { query.bind(if disabled { 1i64 } else { 0i64 }) };
|
||||
query.bind(note_id).execute(pool.pool()).await?; Ok(())
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@ pub enum Query {
|
||||
RESOURCE_COLOR_BY_USER,
|
||||
RESOURCE_COLOR_DELETE,
|
||||
RESOURCE_COLOR_INSERT,
|
||||
RESOURCE_EDITOR_SETTINGS_SELECT,
|
||||
RESOURCE_EDITOR_SETTINGS_DELETE,
|
||||
RESOURCE_EDITOR_SETTINGS_INSERT,
|
||||
AUTH_ACCOUNT_ACTION_BY_TOKEN,
|
||||
AUTH_CONSUME_ACCOUNT_ACTION,
|
||||
AUTH_UPDATE_EMAIL,
|
||||
@@ -160,6 +163,9 @@ pub const AUTH_EDITOR_COLOR_BY_USER: Query = Query::AUTH_EDITOR_COLOR_BY_USER;
|
||||
pub const RESOURCE_COLOR_BY_USER: Query = Query::RESOURCE_COLOR_BY_USER;
|
||||
pub const RESOURCE_COLOR_DELETE: Query = Query::RESOURCE_COLOR_DELETE;
|
||||
pub const RESOURCE_COLOR_INSERT: Query = Query::RESOURCE_COLOR_INSERT;
|
||||
pub const RESOURCE_EDITOR_SETTINGS_SELECT: Query = Query::RESOURCE_EDITOR_SETTINGS_SELECT;
|
||||
pub const RESOURCE_EDITOR_SETTINGS_DELETE: Query = Query::RESOURCE_EDITOR_SETTINGS_DELETE;
|
||||
pub const RESOURCE_EDITOR_SETTINGS_INSERT: Query = Query::RESOURCE_EDITOR_SETTINGS_INSERT;
|
||||
pub const AUTH_ACCOUNT_ACTION_BY_TOKEN: Query = Query::AUTH_ACCOUNT_ACTION_BY_TOKEN;
|
||||
pub const AUTH_CONSUME_ACCOUNT_ACTION: Query = Query::AUTH_CONSUME_ACCOUNT_ACTION;
|
||||
pub const AUTH_UPDATE_EMAIL: Query = Query::AUTH_UPDATE_EMAIL;
|
||||
|
||||
@@ -15,6 +15,9 @@ pub fn get(query: Query) -> &'static str {
|
||||
Query::AUTH_EDITOR_COLOR_BY_USER => r#"SELECT editor_color FROM users WHERE id = ?"#,
|
||||
Query::RESOURCE_COLOR_BY_USER => r#"SELECT color FROM user_resource_colors WHERE user_id = ? AND resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_COLOR_DELETE => r#"DELETE FROM user_resource_colors WHERE user_id = ? AND resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_SELECT => r#"SELECT authorship_mode, CASE WHEN colors_enabled THEN 1 ELSE 0 END FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_DELETE => r#"DELETE FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_INSERT => r#"INSERT INTO resource_editor_settings (resource_kind, resource_slug, authorship_mode, colors_enabled) VALUES (?, ?, ?, ?)"#,
|
||||
Query::RESOURCE_COLOR_INSERT => r#"INSERT INTO user_resource_colors (user_id, resource_kind, resource_slug, color) VALUES (?, ?, ?, ?)"#,
|
||||
Query::AUTH_ACCOUNT_ACTION_BY_TOKEN => r#"SELECT user_id, action, CAST(payload AS CHAR CHARACTER SET utf8mb4) AS payload, expires_at, used_at FROM account_action_tokens WHERE token = ?"#,
|
||||
Query::AUTH_CONSUME_ACCOUNT_ACTION => r#"UPDATE account_action_tokens SET used_at = ? WHERE token = ? AND used_at IS NULL"#,
|
||||
|
||||
@@ -15,6 +15,9 @@ pub fn get(query: Query) -> &'static str {
|
||||
Query::AUTH_EDITOR_COLOR_BY_USER => r#"SELECT editor_color FROM users WHERE id = $1"#,
|
||||
Query::RESOURCE_COLOR_BY_USER => r#"SELECT color FROM user_resource_colors WHERE user_id = $1 AND resource_kind = $2 AND resource_slug = $3"#,
|
||||
Query::RESOURCE_COLOR_DELETE => r#"DELETE FROM user_resource_colors WHERE user_id = $1 AND resource_kind = $2 AND resource_slug = $3"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_SELECT => r#"SELECT authorship_mode, (CASE WHEN colors_enabled THEN 1 ELSE 0 END)::BIGINT FROM resource_editor_settings WHERE resource_kind = $1 AND resource_slug = $2"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_DELETE => r#"DELETE FROM resource_editor_settings WHERE resource_kind = $1 AND resource_slug = $2"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_INSERT => r#"INSERT INTO resource_editor_settings (resource_kind, resource_slug, authorship_mode, colors_enabled) VALUES ($1, $2, $3, $4)"#,
|
||||
Query::RESOURCE_COLOR_INSERT => r#"INSERT INTO user_resource_colors (user_id, resource_kind, resource_slug, color) VALUES ($1, $2, $3, $4)"#,
|
||||
Query::AUTH_ACCOUNT_ACTION_BY_TOKEN => r#"SELECT user_id, action, payload, expires_at, used_at FROM account_action_tokens WHERE token = $1"#,
|
||||
Query::AUTH_CONSUME_ACCOUNT_ACTION => r#"UPDATE account_action_tokens SET used_at = $1 WHERE token = $2 AND used_at IS NULL"#,
|
||||
|
||||
@@ -15,6 +15,9 @@ pub fn get(query: Query) -> &'static str {
|
||||
Query::AUTH_EDITOR_COLOR_BY_USER => r#"SELECT editor_color FROM users WHERE id = ?"#,
|
||||
Query::RESOURCE_COLOR_BY_USER => r#"SELECT color FROM user_resource_colors WHERE user_id = ? AND resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_COLOR_DELETE => r#"DELETE FROM user_resource_colors WHERE user_id = ? AND resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_SELECT => r#"SELECT authorship_mode, CASE WHEN colors_enabled THEN 1 ELSE 0 END FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_DELETE => r#"DELETE FROM resource_editor_settings WHERE resource_kind = ? AND resource_slug = ?"#,
|
||||
Query::RESOURCE_EDITOR_SETTINGS_INSERT => r#"INSERT INTO resource_editor_settings (resource_kind, resource_slug, authorship_mode, colors_enabled) VALUES (?, ?, ?, ?)"#,
|
||||
Query::RESOURCE_COLOR_INSERT => r#"INSERT INTO user_resource_colors (user_id, resource_kind, resource_slug, color) VALUES (?, ?, ?, ?)"#,
|
||||
Query::AUTH_ACCOUNT_ACTION_BY_TOKEN => r#"SELECT user_id, action, payload, expires_at, used_at FROM account_action_tokens WHERE token = ?"#,
|
||||
Query::AUTH_CONSUME_ACCOUNT_ACTION => r#"UPDATE account_action_tokens SET used_at = ? WHERE token = ? AND used_at IS NULL"#,
|
||||
|
||||
Reference in New Issue
Block a user