mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-08-29 05:52:08 -04:00
fix bugs
This commit is contained in:
@@ -324,7 +324,7 @@ pub fn register_routes(state: AppState) -> Router<()> {
|
||||
.route("/v1/server/push", post(server_push_user_traffic))
|
||||
.route("/v1/server/status", post(server_push_status))
|
||||
.route("/v1/server/user", get(get_server_user_list))
|
||||
.route("/v2/server/:server_id", get(query_server_protocol_config))
|
||||
.route("/v2/server/{server_id}", get(query_server_protocol_config))
|
||||
.route("/v1/subscribe/config", get(subscribe_handler))
|
||||
.route("/", get(pan_domain_subscribe_handler))
|
||||
.route("/v1/telegram", post(telegram_handler));
|
||||
|
||||
+14
-8
@@ -14,7 +14,12 @@ mod mysql_migrations {
|
||||
|
||||
mod postgres_migrations {
|
||||
#![allow(unused)]
|
||||
pub(super) const MIGRATOR: sqlx::migrate::Migrator = sqlx::migrate!("migrations/postgres");
|
||||
pub(super) fn migrator() -> sqlx::migrate::Migrator {
|
||||
let mut m = sqlx::migrate!("migrations/postgres");
|
||||
m.set_locking(false);
|
||||
m.no_tx = true;
|
||||
m
|
||||
}
|
||||
}
|
||||
|
||||
pub use crate::repository::Dialect;
|
||||
@@ -24,7 +29,7 @@ use crate::repository::Db;
|
||||
/// Run all pending migrations for the detected database dialect.
|
||||
pub async fn run_migrations(db: &Db) -> Result<(), sqlx::migrate::MigrateError> {
|
||||
match db {
|
||||
Db::Postgres(pool) => postgres_migrations::MIGRATOR.run(pool).await,
|
||||
Db::Postgres(pool) => postgres_migrations::migrator().run(pool).await,
|
||||
Db::Mysql(pool) => mysql_migrations::MIGRATOR.run(pool).await,
|
||||
}
|
||||
}
|
||||
@@ -60,6 +65,7 @@ async fn create_admin_user_pg(
|
||||
}
|
||||
|
||||
let now = chrono::Utc::now().timestamp_millis();
|
||||
let now_ts = chrono::Utc::now(); // chrono::DateTime<Utc> -> PG timestamp
|
||||
let password_hash = hash_password_pbkdf2(password);
|
||||
let refer_code = generate_invite_code();
|
||||
|
||||
@@ -68,12 +74,12 @@ async fn create_admin_user_pg(
|
||||
gift_amount, enable, enable_balance_notify,
|
||||
enable_login_notify, enable_subscribe_notify,
|
||||
enable_trade_notify, created_at, updated_at)
|
||||
VALUES ($1, 'default', 1, $2, 0, 0, 0, 1, 1, 1, 1, 1, $3, $4)"#,
|
||||
VALUES ($1, 'default', TRUE, $2, 0, 0, 0, TRUE, TRUE, TRUE, TRUE, TRUE, $3, $4)"#,
|
||||
)
|
||||
.bind(&password_hash)
|
||||
.bind(&refer_code)
|
||||
.bind(now)
|
||||
.bind(now)
|
||||
.bind(now_ts)
|
||||
.bind(now_ts)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
@@ -93,12 +99,12 @@ async fn create_admin_user_pg(
|
||||
|
||||
sqlx::query(
|
||||
r#"INSERT INTO user_auth_methods (user_id, auth_type, auth_identifier, verified, created_at, updated_at)
|
||||
VALUES ($1, 'email', $2, 1, $3, $4)"#,
|
||||
VALUES ($1, 'email', $2, TRUE, $3, $4)"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(email)
|
||||
.bind(now)
|
||||
.bind(now)
|
||||
.bind(now_ts)
|
||||
.bind(now_ts)
|
||||
.execute(pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Service {
|
||||
Self::register(
|
||||
&scheduler,
|
||||
types::SCHEDULER_CHECK_SUBSCRIPTION,
|
||||
"@every 60s",
|
||||
"*/30 * * * * *",
|
||||
"default",
|
||||
)
|
||||
.await?;
|
||||
@@ -47,7 +47,7 @@ impl Service {
|
||||
Self::register(
|
||||
&scheduler,
|
||||
types::SCHEDULER_RESET_TRAFFIC,
|
||||
"30 0 * * *",
|
||||
"0 30 0 * * *",
|
||||
"default",
|
||||
)
|
||||
.await?;
|
||||
@@ -56,7 +56,7 @@ impl Service {
|
||||
Self::register(
|
||||
&scheduler,
|
||||
types::SCHEDULER_TRAFFIC_STAT,
|
||||
"0 0 * * *",
|
||||
"0 0 0 * * *",
|
||||
"default",
|
||||
)
|
||||
.await?;
|
||||
@@ -65,7 +65,7 @@ impl Service {
|
||||
Self::register(
|
||||
&scheduler,
|
||||
types::FORTHWITH_QUOTA_TASK,
|
||||
"0 1 * * *",
|
||||
"0 0 1 * * *",
|
||||
"default",
|
||||
)
|
||||
.await?;
|
||||
|
||||
Reference in New Issue
Block a user