mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
feat: blocking api interfaces
This commit is contained in:
@@ -54,3 +54,17 @@ export async function patch_user(
|
||||
): Promise<void> {
|
||||
await invoke('plugin:users|patch_user', { userId, patch })
|
||||
}
|
||||
|
||||
export async function block_user(userId: string): Promise<void> {
|
||||
await invoke('plugin:users|block_user', { userId })
|
||||
}
|
||||
|
||||
export async function unblock_user(userId: string): Promise<void> {
|
||||
await invoke('plugin:users|unblock_user', { userId })
|
||||
}
|
||||
|
||||
export async function get_blocked_users(): Promise<Labrinth.BlockedUsers.v3.BlockedUserId[]> {
|
||||
return await invoke<Labrinth.BlockedUsers.v3.BlockedUserId[]>(
|
||||
'plugin:users|get_blocked_users',
|
||||
)
|
||||
}
|
||||
|
||||
@@ -285,6 +285,9 @@ fn main() {
|
||||
"get_user_organizations",
|
||||
"get_user_collections",
|
||||
"patch_user",
|
||||
"block_user",
|
||||
"unblock_user",
|
||||
"get_blocked_users",
|
||||
])
|
||||
.default_permission(
|
||||
DefaultPermissionRule::AllowAllCommands,
|
||||
|
||||
@@ -32,6 +32,21 @@ pub async fn patch_user(user_id: &str, patch: Value) -> Result<()> {
|
||||
Ok(theseus::users::patch_user(user_id, patch).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn block_user(user_id: &str) -> Result<()> {
|
||||
Ok(theseus::users::block_user(user_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn unblock_user(user_id: &str) -> Result<()> {
|
||||
Ok(theseus::users::unblock_user(user_id).await?)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_blocked_users() -> Result<Vec<String>> {
|
||||
Ok(theseus::users::get_blocked_users().await?)
|
||||
}
|
||||
|
||||
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
tauri::plugin::Builder::new("users")
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
@@ -41,6 +56,9 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
|
||||
get_user_organizations,
|
||||
get_user_collections,
|
||||
patch_user,
|
||||
block_user,
|
||||
unblock_user,
|
||||
get_blocked_users,
|
||||
])
|
||||
.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user