mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Impl /auth/token/delete
This commit is contained in:
@@ -220,6 +220,12 @@ impl PixivDownloaderSqlite {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
fn _delete_token(tx: &Transaction, id: u64) -> Result<(), SqliteError> {
|
||||
tx.execute("DELETE FROM token WHERE id = ?;", [id])?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
fn _delete_user(tx: &Transaction, id: u64) -> Result<bool, SqliteError> {
|
||||
let af = tx.execute("DELETE FROM users WHERE id = ?;", [id])?;
|
||||
@@ -594,6 +600,15 @@ impl PixivDownloaderDb for PixivDownloaderSqlite {
|
||||
.expect("User not found:"))
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
async fn delete_token(&self, id: u64) -> Result<(), PixivDownloaderDbError> {
|
||||
let mut db = self.db.lock().await;
|
||||
let mut tx = db.transaction()?;
|
||||
Self::_delete_token(&mut tx, id)?;
|
||||
tx.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "server")]
|
||||
async fn delete_user(&self, id: u64) -> Result<bool, PixivDownloaderDbError> {
|
||||
let mut db = self.db.lock().await;
|
||||
|
||||
@@ -55,6 +55,10 @@ pub trait PixivDownloaderDb {
|
||||
is_admin: bool,
|
||||
) -> Result<User, PixivDownloaderDbError>;
|
||||
#[cfg(feature = "server")]
|
||||
/// Delete a token
|
||||
/// * `id` - The token ID
|
||||
async fn delete_token(&self, id: u64) -> Result<(), PixivDownloaderDbError>;
|
||||
#[cfg(feature = "server")]
|
||||
/// Delete a user
|
||||
/// * `id` - User ID
|
||||
/// # Note
|
||||
|
||||
Reference in New Issue
Block a user