fixed errors

This commit is contained in:
Ren Amamiya
2023-04-05 15:24:44 +07:00
parent 0d94313b45
commit 5da94e091f
10 changed files with 147 additions and 53 deletions

View File

@@ -37,6 +37,11 @@ struct GetFollowData {
account_id: i32,
}
#[derive(Deserialize, Type)]
struct GetFollowPubkeyData {
pubkey: String,
}
#[derive(Deserialize, Type)]
struct CreateFollowData {
pubkey: String,
@@ -105,6 +110,19 @@ async fn get_follows(db: DbState<'_>, data: GetFollowData) -> Result<Vec<follow:
.map_err(|_| ())
}
#[tauri::command]
#[specta::specta]
async fn get_follow_by_pubkey(
db: DbState<'_>,
data: GetFollowPubkeyData,
) -> Result<Option<follow::Data>, ()> {
db.follow()
.find_first(vec![follow::pubkey::equals(data.pubkey)])
.exec()
.await
.map_err(|_| ())
}
#[tauri::command]
#[specta::specta]
async fn create_follow(db: DbState<'_>, data: CreateFollowData) -> Result<follow::Data, ()> {
@@ -198,6 +216,7 @@ async fn main() {
get_accounts,
create_account,
get_follows,
get_follow_by_pubkey,
create_follow,
create_note,
get_notes,
@@ -238,6 +257,7 @@ async fn main() {
get_accounts,
create_account,
get_follows,
get_follow_by_pubkey,
create_follow,
create_note,
get_notes,