mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-12-19 02:37:53 +00:00
Added usermanagement in TG admin
This commit is contained in:
@@ -12,27 +12,10 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(Users::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Users::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Users::Name)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Users::Comment)
|
||||
.text()
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Users::TelegramId)
|
||||
.big_integer()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(Users::Id).uuid().not_null().primary_key())
|
||||
.col(ColumnDef::new(Users::Name).string_len(255).not_null())
|
||||
.col(ColumnDef::new(Users::Comment).text().null())
|
||||
.col(ColumnDef::new(Users::TelegramId).big_integer().null())
|
||||
.col(
|
||||
ColumnDef::new(Users::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
@@ -108,12 +91,7 @@ impl MigrationTrait for Migration {
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(
|
||||
Index::drop()
|
||||
.if_exists()
|
||||
.name("idx_users_name")
|
||||
.to_owned(),
|
||||
)
|
||||
.drop_index(Index::drop().if_exists().name("idx_users_name").to_owned())
|
||||
.await?;
|
||||
|
||||
// Drop table
|
||||
@@ -132,4 +110,4 @@ enum Users {
|
||||
TelegramId,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,21 +32,9 @@ impl MigrationTrait for Migration {
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Certificates::CertData)
|
||||
.blob()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Certificates::KeyData)
|
||||
.blob()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Certificates::ChainData)
|
||||
.blob()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(Certificates::CertData).blob().not_null())
|
||||
.col(ColumnDef::new(Certificates::KeyData).blob().not_null())
|
||||
.col(ColumnDef::new(Certificates::ChainData).blob().null())
|
||||
.col(
|
||||
ColumnDef::new(Certificates::ExpiresAt)
|
||||
.timestamp_with_time_zone()
|
||||
@@ -117,4 +105,4 @@ enum Certificates {
|
||||
AutoRenew,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,7 @@ impl MigrationTrait for Migration {
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(InboundTemplates::Description)
|
||||
.text()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(InboundTemplates::Description).text().null())
|
||||
.col(
|
||||
ColumnDef::new(InboundTemplates::Protocol)
|
||||
.string_len(50)
|
||||
@@ -152,4 +148,4 @@ enum InboundTemplates {
|
||||
IsActive,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,44 +11,23 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(Servers::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Servers::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Servers::Name)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Servers::Hostname)
|
||||
.string_len(255)
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(Servers::Id).uuid().not_null().primary_key())
|
||||
.col(ColumnDef::new(Servers::Name).string_len(255).not_null())
|
||||
.col(ColumnDef::new(Servers::Hostname).string_len(255).not_null())
|
||||
.col(
|
||||
ColumnDef::new(Servers::GrpcPort)
|
||||
.integer()
|
||||
.default(2053)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Servers::ApiCredentials)
|
||||
.text()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(Servers::ApiCredentials).text().null())
|
||||
.col(
|
||||
ColumnDef::new(Servers::Status)
|
||||
.string_len(50)
|
||||
.default("unknown")
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Servers::DefaultCertificateId)
|
||||
.uuid()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(Servers::DefaultCertificateId).uuid().null())
|
||||
.col(
|
||||
ColumnDef::new(Servers::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
@@ -133,4 +112,4 @@ enum Servers {
|
||||
enum Certificates {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,8 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(ServerInbounds::ServerId)
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(ServerInbounds::TemplateId)
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(ServerInbounds::ServerId).uuid().not_null())
|
||||
.col(ColumnDef::new(ServerInbounds::TemplateId).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(ServerInbounds::Tag)
|
||||
.string_len(255)
|
||||
@@ -37,11 +29,7 @@ impl MigrationTrait for Migration {
|
||||
.integer()
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(ServerInbounds::CertificateId)
|
||||
.uuid()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(ServerInbounds::CertificateId).uuid().null())
|
||||
.col(
|
||||
ColumnDef::new(ServerInbounds::VariableValues)
|
||||
.json()
|
||||
@@ -192,4 +180,4 @@ enum InboundTemplates {
|
||||
enum Certificates {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,41 +17,17 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::UserId)
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::ServerId)
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(UserAccess::UserId).uuid().not_null())
|
||||
.col(ColumnDef::new(UserAccess::ServerId).uuid().not_null())
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::ServerInboundId)
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::XrayUserId)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::XrayEmail)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::Level)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::IsActive)
|
||||
.boolean()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(UserAccess::XrayUserId).string().not_null())
|
||||
.col(ColumnDef::new(UserAccess::XrayEmail).string().not_null())
|
||||
.col(ColumnDef::new(UserAccess::Level).integer().not_null())
|
||||
.col(ColumnDef::new(UserAccess::IsActive).boolean().not_null())
|
||||
.col(
|
||||
ColumnDef::new(UserAccess::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
@@ -193,4 +169,4 @@ enum Servers {
|
||||
enum ServerInbounds {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,21 +22,9 @@ impl MigrationTrait for Migration {
|
||||
.uuid()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(InboundUsers::Username)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(InboundUsers::Email)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(InboundUsers::XrayUserId)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(InboundUsers::Username).string().not_null())
|
||||
.col(ColumnDef::new(InboundUsers::Email).string().not_null())
|
||||
.col(ColumnDef::new(InboundUsers::XrayUserId).string().not_null())
|
||||
.col(
|
||||
ColumnDef::new(InboundUsers::Level)
|
||||
.integer()
|
||||
@@ -122,4 +110,4 @@ enum InboundUsers {
|
||||
enum ServerInbounds {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,22 +36,18 @@ impl MigrationTrait for Migration {
|
||||
ColumnDef::new(InboundUsers::UserId)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.default(Expr::val("00000000-0000-0000-0000-000000000000"))
|
||||
.default(Expr::val("00000000-0000-0000-0000-000000000000")),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Add password column
|
||||
// Add password column
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(InboundUsers::Table)
|
||||
.add_column(
|
||||
ColumnDef::new(InboundUsers::Password)
|
||||
.string()
|
||||
.null()
|
||||
)
|
||||
.add_column(ColumnDef::new(InboundUsers::Password).string().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
@@ -83,7 +79,7 @@ impl MigrationTrait for Migration {
|
||||
.from(InboundUsers::Table, InboundUsers::UserId)
|
||||
.to(Users::Table, Users::Id)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
.to_owned()
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -153,7 +149,7 @@ impl MigrationTrait for Migration {
|
||||
ColumnDef::new(InboundUsers::Username)
|
||||
.string()
|
||||
.not_null()
|
||||
.default("")
|
||||
.default(""),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
@@ -167,7 +163,7 @@ impl MigrationTrait for Migration {
|
||||
ColumnDef::new(InboundUsers::Email)
|
||||
.string()
|
||||
.not_null()
|
||||
.default("")
|
||||
.default(""),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
@@ -239,4 +235,4 @@ enum InboundUsers {
|
||||
enum Users {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ impl MigrationTrait for Migration {
|
||||
|
||||
// Update existing servers: set grpc_hostname to hostname value
|
||||
let db = manager.get_connection();
|
||||
|
||||
|
||||
// Use raw SQL to copy hostname to grpc_hostname for existing records
|
||||
// Handle both empty strings and default empty values
|
||||
db.execute_unprepared("UPDATE servers SET grpc_hostname = hostname WHERE grpc_hostname = '' OR grpc_hostname IS NULL")
|
||||
@@ -47,4 +47,4 @@ impl MigrationTrait for Migration {
|
||||
enum Servers {
|
||||
Table,
|
||||
GrpcHostname,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,11 +27,7 @@ impl MigrationTrait for Migration {
|
||||
.string_len(50)
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(DnsProviders::ApiToken)
|
||||
.text()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(DnsProviders::ApiToken).text().not_null())
|
||||
.col(
|
||||
ColumnDef::new(DnsProviders::IsActive)
|
||||
.boolean()
|
||||
@@ -93,4 +89,4 @@ enum DnsProviders {
|
||||
IsActive,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,23 +11,29 @@ impl MigrationTrait for Migration {
|
||||
Table::create()
|
||||
.table(TelegramConfig::Table)
|
||||
.if_not_exists()
|
||||
.col(ColumnDef::new(TelegramConfig::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key())
|
||||
.col(ColumnDef::new(TelegramConfig::BotToken)
|
||||
.string()
|
||||
.not_null())
|
||||
.col(ColumnDef::new(TelegramConfig::IsActive)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false))
|
||||
.col(ColumnDef::new(TelegramConfig::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null())
|
||||
.col(ColumnDef::new(TelegramConfig::UpdatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null())
|
||||
.col(
|
||||
ColumnDef::new(TelegramConfig::Id)
|
||||
.uuid()
|
||||
.not_null()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(TelegramConfig::BotToken).string().not_null())
|
||||
.col(
|
||||
ColumnDef::new(TelegramConfig::IsActive)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(TelegramConfig::CreatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(TelegramConfig::UpdatedAt)
|
||||
.timestamp_with_time_zone()
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
@@ -48,4 +54,4 @@ pub enum TelegramConfig {
|
||||
IsActive,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl MigrationTrait for Migration {
|
||||
ColumnDef::new(Users::IsTelegramAdmin)
|
||||
.boolean()
|
||||
.not_null()
|
||||
.default(false)
|
||||
.default(false),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
@@ -37,4 +37,4 @@ impl MigrationTrait for Migration {
|
||||
enum Users {
|
||||
Table,
|
||||
IsTelegramAdmin,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,7 @@ impl MigrationTrait for Migration {
|
||||
.default(Expr::cust("gen_random_uuid()")),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserRequests::UserId)
|
||||
.uuid()
|
||||
.null(), // Can be null if user doesn't exist yet
|
||||
ColumnDef::new(UserRequests::UserId).uuid().null(), // Can be null if user doesn't exist yet
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserRequests::TelegramId)
|
||||
@@ -51,16 +49,8 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.default("pending"), // pending, approved, declined
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserRequests::RequestMessage)
|
||||
.text()
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(UserRequests::ResponseMessage)
|
||||
.text()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(UserRequests::RequestMessage).text().null())
|
||||
.col(ColumnDef::new(UserRequests::ResponseMessage).text().null())
|
||||
.col(
|
||||
ColumnDef::new(UserRequests::ProcessedByUserId)
|
||||
.uuid()
|
||||
@@ -190,4 +180,4 @@ enum UserRequests {
|
||||
enum Users {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ impl MigrationTrait for Migration {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl MigrationTrait for Migration {
|
||||
.add_column(
|
||||
ColumnDef::new(UserRequests::Language)
|
||||
.string()
|
||||
.default("en") // Default to English
|
||||
.default("en"), // Default to English
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
@@ -38,4 +38,4 @@ impl MigrationTrait for Migration {
|
||||
enum UserRequests {
|
||||
Table,
|
||||
Language,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,4 +39,4 @@ impl MigratorTrait for Migrator {
|
||||
Box::new(m20251018_000003_add_language_to_user_requests::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user