chore: remove features that don't compile
add: posts "circle" column
This commit is contained in:
parent
0310418837
commit
50704d27a9
42 changed files with 71 additions and 365 deletions
61
Cargo.lock
generated
61
Cargo.lock
generated
|
@ -787,18 +787,6 @@ version = "0.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
|
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fallible-iterator"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fallible-streaming-iterator"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "1.9.0"
|
version = "1.9.0"
|
||||||
|
@ -839,12 +827,6 @@ version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "foldhash"
|
|
||||||
version = "0.1.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "foreign-types"
|
name = "foreign-types"
|
||||||
version = "0.3.2"
|
version = "0.3.2"
|
||||||
|
@ -1112,18 +1094,6 @@ name = "hashbrown"
|
||||||
version = "0.15.4"
|
version = "0.15.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5"
|
||||||
dependencies = [
|
|
||||||
"foldhash",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hashlink"
|
|
||||||
version = "0.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
|
||||||
dependencies = [
|
|
||||||
"hashbrown",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
|
@ -1697,16 +1667,6 @@ version = "0.2.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libsqlite3-sys"
|
|
||||||
version = "0.34.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "91632f3b4fb6bd1d72aa3d78f41ffecfcf2b1a6648d8c241dbe7dbfaf4875e15"
|
|
||||||
dependencies = [
|
|
||||||
"pkg-config",
|
|
||||||
"vcpkg",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libwebp-sys"
|
name = "libwebp-sys"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
|
@ -2033,7 +1993,6 @@ checksum = "99b097052e28781d560587373845626a85460969a55d180fc418aecd58f6fef3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bb8-postgres",
|
"bb8-postgres",
|
||||||
"redis",
|
"redis",
|
||||||
"rusqlite",
|
|
||||||
"serde",
|
"serde",
|
||||||
"tokio-postgres",
|
"tokio-postgres",
|
||||||
]
|
]
|
||||||
|
@ -2290,7 +2249,7 @@ dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
"fallible-iterator 0.2.0",
|
"fallible-iterator",
|
||||||
"hmac",
|
"hmac",
|
||||||
"md-5",
|
"md-5",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -2306,7 +2265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "613283563cd90e1dfc3518d548caee47e0e725455ed619881f5cf21f36de4b48"
|
checksum = "613283563cd90e1dfc3518d548caee47e0e725455ed619881f5cf21f36de4b48"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fallible-iterator 0.2.0",
|
"fallible-iterator",
|
||||||
"postgres-protocol",
|
"postgres-protocol",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2725,20 +2684,6 @@ dependencies = [
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rusqlite"
|
|
||||||
version = "0.36.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3de23c3319433716cf134eed225fe9986bc24f63bed9be9f20c329029e672dc7"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.1",
|
|
||||||
"fallible-iterator 0.3.0",
|
|
||||||
"fallible-streaming-iterator",
|
|
||||||
"hashlink",
|
|
||||||
"libsqlite3-sys",
|
|
||||||
"smallvec",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-demangle"
|
name = "rustc-demangle"
|
||||||
version = "0.1.24"
|
version = "0.1.24"
|
||||||
|
@ -3527,7 +3472,7 @@ dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
"fallible-iterator 0.2.0",
|
"fallible-iterator",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -10,10 +10,10 @@ Make sure you have AT LEAST rustc version 1.89.0-nightly.
|
||||||
Everything Tetratto needs will be built into the main binary. You can build Tetratto with the following command:
|
Everything Tetratto needs will be built into the main binary. You can build Tetratto with the following command:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cargo build -r --no-default-features --features=redis,sqlite
|
cargo build
|
||||||
```
|
```
|
||||||
|
|
||||||
You can replace `sqlite` in the above command with `postgres`, if you'd like. Redis (or a Redis fork) is required for features such as chats and (realtime) notifications!
|
Tetratto **requires** a PostgreSQL server, as well as a Redis (or Redis fork) instance.
|
||||||
|
|
||||||
You can then take the binary and place it somewhere else (highly recommended; the binary will create a fair number of files!). You can do this to move it to a directory just called "tetratto" in the parent directory:
|
You can then take the binary and place it somewhere else (highly recommended; the binary will create a fair number of files!). You can do this to move it to a directory just called "tetratto" in the parent directory:
|
||||||
|
|
||||||
|
|
|
@ -3,12 +3,6 @@ name = "tetratto"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[features]
|
|
||||||
postgres = ["tetratto-core/postgres"]
|
|
||||||
sqlite = ["tetratto-core/sqlite"]
|
|
||||||
redis = ["tetratto-core/redis"]
|
|
||||||
default = ["sqlite", "redis"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pathbufd = "0.1.4"
|
pathbufd = "0.1.4"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
@ -21,9 +15,7 @@ tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
|
||||||
axum-extra = { version = "0.10.1", features = ["cookie", "multipart"] }
|
axum-extra = { version = "0.10.1", features = ["cookie", "multipart"] }
|
||||||
ammonia = "4.1.0"
|
ammonia = "4.1.0"
|
||||||
tetratto-shared = { path = "../shared" }
|
tetratto-shared = { path = "../shared" }
|
||||||
tetratto-core = { path = "../core", features = [
|
tetratto-core = { path = "../core" }
|
||||||
"redis",
|
|
||||||
], default-features = false }
|
|
||||||
tetratto-l10n = { path = "../l10n" }
|
tetratto-l10n = { path = "../l10n" }
|
||||||
|
|
||||||
image = "0.25.6"
|
image = "0.25.6"
|
||||||
|
|
|
@ -17,7 +17,6 @@ use tetratto_core::{
|
||||||
auth::{DefaultTimelineChoice, User},
|
auth::{DefaultTimelineChoice, User},
|
||||||
permissions::FinePermission,
|
permissions::FinePermission,
|
||||||
},
|
},
|
||||||
PUBSUB_ENABLED,
|
|
||||||
};
|
};
|
||||||
use tetratto_l10n::LangFile;
|
use tetratto_l10n::LangFile;
|
||||||
use tetratto_shared::hash::salt;
|
use tetratto_shared::hash::salt;
|
||||||
|
@ -468,7 +467,7 @@ pub(crate) async fn initial_context(
|
||||||
) -> Context {
|
) -> Context {
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
ctx.insert("config", &config);
|
ctx.insert("config", &config);
|
||||||
ctx.insert("pubsub", &PUBSUB_ENABLED);
|
ctx.insert("pubsub", &true);
|
||||||
|
|
||||||
ctx.insert("user", &user);
|
ctx.insert("user", &user);
|
||||||
ctx.insert("use_user_theme", &true);
|
ctx.insert("use_user_theme", &true);
|
||||||
|
|
|
@ -144,7 +144,9 @@
|
||||||
(text "{{ macros::timelines_nav_options(selected=selected) }}")
|
(text "{{ macros::timelines_nav_options(selected=selected) }}")
|
||||||
|
|
||||||
; secondary nav desktop only
|
; secondary nav desktop only
|
||||||
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected) }}"))
|
(text "{% if posts and questions -%}")
|
||||||
|
(text "{{ macros::timelines_secondary_nav(posts=posts, questions=questions, selected=secondary_selected) }}")
|
||||||
|
(text "{%- endif %}"))
|
||||||
(text "{%- endmacro %}")
|
(text "{%- endmacro %}")
|
||||||
|
|
||||||
(text "{% macro timelines_nav_options(selected=\"\") -%}")
|
(text "{% macro timelines_nav_options(selected=\"\") -%}")
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
("class" "card small flex items-center justify-between gap-2")
|
("class" "card small flex items-center justify-between gap-2")
|
||||||
(div
|
(div
|
||||||
("class" "flex items-center gap-2")
|
("class" "flex items-center gap-2")
|
||||||
(text "{{ icon \"list\" }}")
|
(a
|
||||||
|
("href" "/api/v1/auth/user/find/{{ stack.owner }}")
|
||||||
|
(text "{{ components::avatar(username=stack.owner, selector_type=\"id\") }}"))
|
||||||
(span
|
(span
|
||||||
(text "{{ stack.name }}")))
|
(text "{{ stack.name }}")))
|
||||||
(text "{% if user and user.id == stack.owner -%}")
|
(text "{% if user and user.id == stack.owner -%}")
|
||||||
|
|
|
@ -28,8 +28,6 @@ use tetratto_core::{
|
||||||
},
|
},
|
||||||
DataManager,
|
DataManager,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
use tetratto_core::cache::redis::Commands;
|
use tetratto_core::cache::redis::Commands;
|
||||||
use tetratto_shared::{
|
use tetratto_shared::{
|
||||||
hash::{self, random_id},
|
hash::{self, random_id},
|
||||||
|
@ -534,7 +532,6 @@ pub async fn has_totp_enabled_request(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handle a subscription to the websocket.
|
/// Handle a subscription to the websocket.
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub async fn subscription_handler(
|
pub async fn subscription_handler(
|
||||||
jar: CookieJar,
|
jar: CookieJar,
|
||||||
ws: WebSocketUpgrade,
|
ws: WebSocketUpgrade,
|
||||||
|
@ -557,7 +554,6 @@ pub async fn subscription_handler(
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub async fn handle_socket(socket: WebSocket, db: DataManager, user_id: String, stream_id: String) {
|
pub async fn handle_socket(socket: WebSocket, db: DataManager, user_id: String, stream_id: String) {
|
||||||
let (mut sink, mut stream) = socket.split();
|
let (mut sink, mut stream) = socket.split();
|
||||||
let socket_id = tetratto_shared::hash::salt();
|
let socket_id = tetratto_shared::hash::salt();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod apps;
|
pub mod apps;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
|
pub mod channels;
|
||||||
pub mod communities;
|
pub mod communities;
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
pub mod reactions;
|
pub mod reactions;
|
||||||
|
@ -9,9 +10,6 @@ pub mod stacks;
|
||||||
pub mod uploads;
|
pub mod uploads;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub mod channels;
|
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
routing::{any, delete, get, post, put},
|
routing::{any, delete, get, post, put},
|
||||||
Router,
|
Router,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
|
pub mod chats;
|
||||||
pub mod communities;
|
pub mod communities;
|
||||||
pub mod developer;
|
pub mod developer;
|
||||||
pub mod forge;
|
pub mod forge;
|
||||||
|
@ -7,9 +8,6 @@ pub mod mod_panel;
|
||||||
pub mod profile;
|
pub mod profile;
|
||||||
pub mod stacks;
|
pub mod stacks;
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub mod chats;
|
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
Router,
|
Router,
|
||||||
|
|
|
@ -3,12 +3,6 @@ name = "tetratto-core"
|
||||||
version = "7.0.0"
|
version = "7.0.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[features]
|
|
||||||
postgres = ["oiseau/postgres"]
|
|
||||||
sqlite = ["oiseau/sqlite"]
|
|
||||||
redis = ["oiseau/redis"]
|
|
||||||
default = ["sqlite", "redis"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
pathbufd = "0.1.4"
|
pathbufd = "0.1.4"
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.219", features = ["derive"] }
|
||||||
|
@ -25,4 +19,4 @@ base16ct = { version = "0.2.0", features = ["alloc"] }
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
emojis = "0.6.4"
|
emojis = "0.6.4"
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
oiseau = { version = "0.1.2", default-features = false }
|
oiseau = { version = "0.1.2", default-features = false, features = ["postgres", "redis"] }
|
||||||
|
|
|
@ -8,20 +8,13 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`ThirdPartyApp`] from an SQL row.
|
/// Get a [`ThirdPartyApp`] from an SQL row.
|
||||||
pub(crate) fn get_app_from_row(
|
pub(crate) fn get_app_from_row(x: &PostgresRow) -> ThirdPartyApp {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> ThirdPartyApp {
|
|
||||||
ThirdPartyApp {
|
ThirdPartyApp {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -2,20 +2,13 @@ use oiseau::cache::Cache;
|
||||||
use crate::model::{Error, Result, auth::User, moderation::AuditLogEntry, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, moderation::AuditLogEntry, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get an [`AuditLogEntry`] from an SQL row.
|
/// Get an [`AuditLogEntry`] from an SQL row.
|
||||||
pub(crate) fn get_audit_log_entry_from_row(
|
pub(crate) fn get_audit_log_entry_from_row(x: &PostgresRow) -> AuditLogEntry {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> AuditLogEntry {
|
|
||||||
AuditLogEntry {
|
AuditLogEntry {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -16,20 +16,13 @@ use tetratto_shared::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, params};
|
use oiseau::{execute, get, query_row, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`User`] from an SQL row.
|
/// Get a [`User`] from an SQL row.
|
||||||
pub(crate) fn get_user_from_row(
|
pub(crate) fn get_user_from_row(x: &PostgresRow) -> User {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> User {
|
|
||||||
User {
|
User {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -6,20 +6,11 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Channel`] from an SQL row.
|
/// Get a [`Channel`] from an SQL row.
|
||||||
pub(crate) fn get_channel_from_row(
|
pub(crate) fn get_channel_from_row(x: &PostgresRow) -> Channel {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Channel {
|
|
||||||
Channel {
|
Channel {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
community: get!(x->1(i64)) as usize,
|
community: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -14,20 +14,11 @@ use pathbufd::PathBufD;
|
||||||
use std::fs::{exists, remove_file};
|
use std::fs::{exists, remove_file};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Community`] from an SQL row.
|
/// Get a [`Community`] from an SQL row.
|
||||||
pub(crate) fn get_community_from_row(
|
pub(crate) fn get_community_from_row(x: &PostgresRow) -> Community {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Community {
|
|
||||||
Community {
|
Community {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
@ -139,15 +130,10 @@ impl DataManager {
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
let empty = [];
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
let empty = &[];
|
|
||||||
|
|
||||||
let res = query_rows!(
|
let res = query_rows!(
|
||||||
&conn,
|
&conn,
|
||||||
"SELECT * FROM communities WHERE NOT context LIKE '%\"is_nsfw\":true%' ORDER BY member_count DESC LIMIT 12",
|
"SELECT * FROM communities WHERE NOT context LIKE '%\"is_nsfw\":true%' ORDER BY member_count DESC LIMIT 12",
|
||||||
empty,
|
params![],
|
||||||
|x| { Self::get_community_from_row(x) }
|
|x| { Self::get_community_from_row(x) }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -3,20 +3,13 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::User, communities::PostDraft, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, communities::PostDraft, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`PostDraft`] from an SQL row.
|
/// Get a [`PostDraft`] from an SQL row.
|
||||||
pub(crate) fn get_draft_from_row(
|
pub(crate) fn get_draft_from_row(x: &PostgresRow) -> PostDraft {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> PostDraft {
|
|
||||||
PostDraft {
|
PostDraft {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -2,13 +2,7 @@ pub mod common;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use tetratto_l10n::{read_langs, LangFile};
|
use tetratto_l10n::{read_langs, LangFile};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::sqlite::{DataManager as OiseauManager, Result};
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::postgres::{DataManager as OiseauManager, Result};
|
use oiseau::postgres::{DataManager as OiseauManager, Result};
|
||||||
|
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -17,5 +17,6 @@ CREATE TABLE IF NOT EXISTS posts (
|
||||||
tsvector_content tsvector GENERATED ALWAYS AS (to_tsvector ('english', coalesce(content, ''))) STORED,
|
tsvector_content tsvector GENERATED ALWAYS AS (to_tsvector ('english', coalesce(content, ''))) STORED,
|
||||||
poll_id BIGINT NOT NULL,
|
poll_id BIGINT NOT NULL,
|
||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
is_open INT NOT NULL DEFAULT 1
|
is_open INT NOT NULL DEFAULT 1,
|
||||||
|
circle BIGINT NOT NULL
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,20 +7,11 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`CustomEmoji`] from an SQL row.
|
/// Get a [`CustomEmoji`] from an SQL row.
|
||||||
pub(crate) fn get_emoji_from_row(
|
pub(crate) fn get_emoji_from_row(x: &PostgresRow) -> CustomEmoji {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> CustomEmoji {
|
|
||||||
CustomEmoji {
|
CustomEmoji {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
owner: get!(x->1(i64)) as usize,
|
owner: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,20 +4,11 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::IpBan, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::IpBan, auth::User, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`IpBan`] from an SQL row.
|
/// Get a [`IpBan`] from an SQL row.
|
||||||
pub(crate) fn get_ipban_from_row(
|
pub(crate) fn get_ipban_from_row(x: &PostgresRow) -> IpBan {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> IpBan {
|
|
||||||
IpBan {
|
IpBan {
|
||||||
ip: get!(x->0(String)),
|
ip: get!(x->0(String)),
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -2,20 +2,13 @@ use oiseau::cache::Cache;
|
||||||
use crate::model::{Error, Result, auth::User, auth::IpBlock, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, auth::IpBlock, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, params};
|
use oiseau::{execute, get, query_row, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get an [`IpBlock`] from an SQL row.
|
/// Get an [`IpBlock`] from an SQL row.
|
||||||
pub(crate) fn get_ipblock_from_row(
|
pub(crate) fn get_ipblock_from_row(x: &PostgresRow) -> IpBlock {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> IpBlock {
|
|
||||||
IpBlock {
|
IpBlock {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -10,20 +10,11 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`CommunityMembership`] from an SQL row.
|
/// Get a [`CommunityMembership`] from an SQL row.
|
||||||
pub(crate) fn get_membership_from_row(
|
pub(crate) fn get_membership_from_row(x: &PostgresRow) -> CommunityMembership {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> CommunityMembership {
|
|
||||||
CommunityMembership {
|
CommunityMembership {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -11,14 +11,7 @@ use serde::Serialize;
|
||||||
use tetratto_shared::unix_epoch_timestamp;
|
use tetratto_shared::unix_epoch_timestamp;
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
use oiseau::{PostgresRow, cache::redis::Commands};
|
||||||
use oiseau::cache::redis::Commands;
|
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
|
@ -29,10 +22,7 @@ struct DeleteMessageEvent {
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Message`] from an SQL row.
|
/// Get a [`Message`] from an SQL row.
|
||||||
pub(crate) fn get_message_from_row(
|
pub(crate) fn get_message_from_row(x: &PostgresRow) -> Message {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Message {
|
|
||||||
Message {
|
Message {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
channel: get!(x->1(i64)) as usize,
|
channel: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
mod apps;
|
mod apps;
|
||||||
mod audit_log;
|
mod audit_log;
|
||||||
mod auth;
|
mod auth;
|
||||||
|
mod channels;
|
||||||
mod common;
|
mod common;
|
||||||
mod communities;
|
mod communities;
|
||||||
pub mod connections;
|
pub mod connections;
|
||||||
|
@ -10,6 +11,7 @@ mod emojis;
|
||||||
mod ipbans;
|
mod ipbans;
|
||||||
mod ipblocks;
|
mod ipblocks;
|
||||||
mod memberships;
|
mod memberships;
|
||||||
|
mod messages;
|
||||||
mod notifications;
|
mod notifications;
|
||||||
mod polls;
|
mod polls;
|
||||||
mod pollvotes;
|
mod pollvotes;
|
||||||
|
@ -25,9 +27,4 @@ mod user_warnings;
|
||||||
mod userblocks;
|
mod userblocks;
|
||||||
mod userfollows;
|
mod userfollows;
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
mod channels;
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
mod messages;
|
|
||||||
|
|
||||||
pub use drivers::DataManager;
|
pub use drivers::DataManager;
|
||||||
|
|
|
@ -3,23 +3,13 @@ use crate::model::socket::{CrudMessageType, PacketType, SocketMessage, SocketMet
|
||||||
use crate::model::{Error, Result, auth::Notification, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::Notification, auth::User, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
use oiseau::{PostgresRow, cache::redis::Commands};
|
||||||
use oiseau::cache::redis::Commands;
|
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Notification`] from an SQL row.
|
/// Get a [`Notification`] from an SQL row.
|
||||||
pub(crate) fn get_notification_from_row(
|
pub(crate) fn get_notification_from_row(x: &PostgresRow) -> Notification {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Notification {
|
|
||||||
Notification {
|
Notification {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,20 +4,13 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Poll`] from an SQL row.
|
/// Get a [`Poll`] from an SQL row.
|
||||||
pub(crate) fn get_poll_from_row(
|
pub(crate) fn get_poll_from_row(x: &PostgresRow) -> Poll {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Poll {
|
|
||||||
Poll {
|
Poll {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
owner: get!(x->1(i64)) as usize,
|
owner: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -5,20 +5,13 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, params};
|
use oiseau::{execute, get, query_row, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`PollVote`] from an SQL row.
|
/// Get a [`PollVote`] from an SQL row.
|
||||||
pub(crate) fn get_pollvote_from_row(
|
pub(crate) fn get_pollvote_from_row(x: &PostgresRow) -> PollVote {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> PollVote {
|
|
||||||
PollVote {
|
PollVote {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
owner: get!(x->1(i64)) as usize,
|
owner: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -15,15 +15,7 @@ use crate::model::{
|
||||||
use tetratto_shared::unix_epoch_timestamp;
|
use tetratto_shared::unix_epoch_timestamp;
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, cache::redis::Commands};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
use oiseau::cache::redis::Commands;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
use oiseau::{execute, get, query_row, query_rows, params};
|
||||||
|
|
||||||
pub type FullPost = (
|
pub type FullPost = (
|
||||||
|
@ -101,10 +93,7 @@ macro_rules! private_post_replying {
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Post`] from an SQL row.
|
/// Get a [`Post`] from an SQL row.
|
||||||
pub(crate) fn get_post_from_row(
|
pub(crate) fn get_post_from_row(x: &PostgresRow) -> Post {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Post {
|
|
||||||
Post {
|
Post {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
@ -125,6 +114,7 @@ impl DataManager {
|
||||||
poll_id: get!(x->13(i64)) as usize,
|
poll_id: get!(x->13(i64)) as usize,
|
||||||
title: get!(x->14(String)),
|
title: get!(x->14(String)),
|
||||||
is_open: get!(x->15(i32)) as i8 == 1,
|
is_open: get!(x->15(i32)) as i8 == 1,
|
||||||
|
circle: get!(x->16(i64)) as usize,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,7 +1610,7 @@ impl DataManager {
|
||||||
|
|
||||||
let res = execute!(
|
let res = execute!(
|
||||||
&conn,
|
&conn,
|
||||||
"INSERT INTO posts VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, DEFAULT, $13, $14, $15)",
|
"INSERT INTO posts VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, DEFAULT, $13, $14, $15, $16)",
|
||||||
params![
|
params![
|
||||||
&(data.id as i64),
|
&(data.id as i64),
|
||||||
&(data.created as i64),
|
&(data.created as i64),
|
||||||
|
@ -1641,6 +1631,7 @@ impl DataManager {
|
||||||
&(data.poll_id as i64),
|
&(data.poll_id as i64),
|
||||||
&data.title,
|
&data.title,
|
||||||
&{ if data.is_open { 1 } else { 0 } },
|
&{ if data.is_open { 1 } else { 0 } },
|
||||||
|
&(data.circle as i64),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -11,20 +11,13 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Question`] from an SQL row.
|
/// Get a [`Question`] from an SQL row.
|
||||||
pub(crate) fn get_question_from_row(
|
pub(crate) fn get_question_from_row(x: &PostgresRow) -> Question {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Question {
|
|
||||||
Question {
|
Question {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -7,20 +7,11 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Reaction`] from an SQL row.
|
/// Get a [`Reaction`] from an SQL row.
|
||||||
pub(crate) fn get_reaction_from_row(
|
pub(crate) fn get_reaction_from_row(x: &PostgresRow) -> Reaction {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Reaction {
|
|
||||||
Reaction {
|
Reaction {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -3,20 +3,13 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::User, moderation::Report, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, moderation::Report, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`Report`] from an SQL row.
|
/// Get a [`Report`] from an SQL row.
|
||||||
pub(crate) fn get_report_from_row(
|
pub(crate) fn get_report_from_row(x: &PostgresRow) -> Report {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> Report {
|
|
||||||
Report {
|
Report {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -3,20 +3,11 @@ use crate::model::requests::ActionType;
|
||||||
use crate::model::{Error, Result, requests::ActionRequest, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, requests::ActionRequest, auth::User, permissions::FinePermission};
|
||||||
use crate::DataManager;
|
use crate::DataManager;
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get an [`ActionRequest`] from an SQL row.
|
/// Get an [`ActionRequest`] from an SQL row.
|
||||||
pub(crate) fn get_request_from_row(
|
pub(crate) fn get_request_from_row(x: &PostgresRow) -> ActionRequest {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> ActionRequest {
|
|
||||||
ActionRequest {
|
ActionRequest {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -3,20 +3,13 @@ use crate::model::stacks::StackPrivacy;
|
||||||
use crate::model::{Error, Result, auth::User, stacks::StackBlock, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, stacks::StackBlock, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, params, query_row, query_rows};
|
use oiseau::{execute, get, params, query_row, query_rows};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`StackBlock`] from an SQL row.
|
/// Get a [`StackBlock`] from an SQL row.
|
||||||
pub(crate) fn get_stackblock_from_row(
|
pub(crate) fn get_stackblock_from_row(x: &PostgresRow) -> StackBlock {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> StackBlock {
|
|
||||||
StackBlock {
|
StackBlock {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -8,20 +8,13 @@ use crate::model::{
|
||||||
};
|
};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`UserStack`] from an SQL row.
|
/// Get a [`UserStack`] from an SQL row.
|
||||||
pub(crate) fn get_stack_from_row(
|
pub(crate) fn get_stack_from_row(x: &PostgresRow) -> UserStack {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> UserStack {
|
|
||||||
UserStack {
|
UserStack {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,20 +4,13 @@ use crate::model::permissions::FinePermission;
|
||||||
use crate::model::{Error, Result, uploads::MediaUpload};
|
use crate::model::{Error, Result, uploads::MediaUpload};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
use oiseau::PostgresRow;
|
||||||
|
|
||||||
use oiseau::{execute, get, query_rows, params};
|
use oiseau::{execute, get, query_rows, params};
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`MediaUpload`] from an SQL row.
|
/// Get a [`MediaUpload`] from an SQL row.
|
||||||
pub(crate) fn get_upload_from_row(
|
pub(crate) fn get_upload_from_row(x: &PostgresRow) -> MediaUpload {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> MediaUpload {
|
|
||||||
MediaUpload {
|
MediaUpload {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,20 +4,11 @@ use crate::model::moderation::AuditLogEntry;
|
||||||
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`UserWarning`] from an SQL row.
|
/// Get a [`UserWarning`] from an SQL row.
|
||||||
pub(crate) fn get_user_warning_from_row(
|
pub(crate) fn get_user_warning_from_row(x: &PostgresRow) -> UserWarning {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> UserWarning {
|
|
||||||
UserWarning {
|
UserWarning {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -2,20 +2,11 @@ use oiseau::cache::Cache;
|
||||||
use crate::model::{Error, Result, auth::User, auth::UserBlock, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, auth::UserBlock, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`UserBlock`] from an SQL row.
|
/// Get a [`UserBlock`] from an SQL row.
|
||||||
pub(crate) fn get_userblock_from_row(
|
pub(crate) fn get_userblock_from_row(x: &PostgresRow) -> UserBlock {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> UserBlock {
|
|
||||||
UserBlock {
|
UserBlock {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,20 +4,11 @@ use crate::model::requests::{ActionRequest, ActionType};
|
||||||
use crate::model::{Error, Result, auth::User, auth::UserFollow, permissions::FinePermission};
|
use crate::model::{Error, Result, auth::User, auth::UserFollow, permissions::FinePermission};
|
||||||
use crate::{auto_method, DataManager};
|
use crate::{auto_method, DataManager};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite")]
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
use oiseau::SqliteRow;
|
|
||||||
|
|
||||||
#[cfg(feature = "postgres")]
|
|
||||||
use oiseau::PostgresRow;
|
|
||||||
|
|
||||||
use oiseau::{execute, get, query_row, query_rows, params};
|
|
||||||
|
|
||||||
impl DataManager {
|
impl DataManager {
|
||||||
/// Get a [`UserFollow`] from an SQL row.
|
/// Get a [`UserFollow`] from an SQL row.
|
||||||
pub(crate) fn get_userfollow_from_row(
|
pub(crate) fn get_userfollow_from_row(x: &PostgresRow) -> UserFollow {
|
||||||
#[cfg(feature = "sqlite")] x: &SqliteRow<'_>,
|
|
||||||
#[cfg(feature = "postgres")] x: &PostgresRow,
|
|
||||||
) -> UserFollow {
|
|
||||||
UserFollow {
|
UserFollow {
|
||||||
id: get!(x->0(i64)) as usize,
|
id: get!(x->0(i64)) as usize,
|
||||||
created: get!(x->1(i64)) as usize,
|
created: get!(x->1(i64)) as usize,
|
||||||
|
|
|
@ -4,10 +4,3 @@ pub mod model;
|
||||||
|
|
||||||
pub use database::DataManager;
|
pub use database::DataManager;
|
||||||
pub use oiseau::cache;
|
pub use oiseau::cache;
|
||||||
|
|
||||||
/// Tells us if pubsub capabilities are provided (via Redis).
|
|
||||||
///
|
|
||||||
/// If we have access to pubsub, community channels/messages will be available.
|
|
||||||
///
|
|
||||||
/// This is mostly used a flag for the UI.
|
|
||||||
pub const PUBSUB_ENABLED: bool = cfg!(feature = "redis");
|
|
||||||
|
|
|
@ -260,6 +260,10 @@ pub struct Post {
|
||||||
pub title: String,
|
pub title: String,
|
||||||
/// If the post is "open". Posts can act as tickets in a forge community.
|
/// If the post is "open". Posts can act as tickets in a forge community.
|
||||||
pub is_open: bool,
|
pub is_open: bool,
|
||||||
|
/// The ID of the circle this post belongs to. 0 means no circle is connected.
|
||||||
|
///
|
||||||
|
/// If circle is not 0, community should be 0 (and vice versa).
|
||||||
|
pub circle: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Post {
|
impl Post {
|
||||||
|
@ -287,6 +291,7 @@ impl Post {
|
||||||
poll_id,
|
poll_id,
|
||||||
title: String::new(),
|
title: String::new(),
|
||||||
is_open: true,
|
is_open: true,
|
||||||
|
circle: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod addr;
|
pub mod addr;
|
||||||
pub mod apps;
|
pub mod apps;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
|
pub mod channels;
|
||||||
pub mod communities;
|
pub mod communities;
|
||||||
pub mod communities_permissions;
|
pub mod communities_permissions;
|
||||||
pub mod moderation;
|
pub mod moderation;
|
||||||
|
@ -8,15 +9,10 @@ pub mod oauth;
|
||||||
pub mod permissions;
|
pub mod permissions;
|
||||||
pub mod reactions;
|
pub mod reactions;
|
||||||
pub mod requests;
|
pub mod requests;
|
||||||
|
pub mod socket;
|
||||||
pub mod stacks;
|
pub mod stacks;
|
||||||
pub mod uploads;
|
pub mod uploads;
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub mod channels;
|
|
||||||
|
|
||||||
#[cfg(feature = "redis")]
|
|
||||||
pub mod socket;
|
|
||||||
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
2
sql_changes/posts_circle.sql
Normal file
2
sql_changes/posts_circle.sql
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE posts
|
||||||
|
ADD COLUMN circle BIGINT NOT NULL DEFAULT 0;
|
Loading…
Add table
Add a link
Reference in a new issue