Skip to content

Commit e508c06

Browse files
hitalinclaude
andcommitted
feat: 残り全エンドポイントの専用メソッド追加
検索(users/search, hashtags/search), AP解決(ap/show), サーバー情報(meta detail, stats), 実績(users/achievements), ユーザーノート(フィルタ付き, featured-notes), ページ(pages CRUD + like/unlike), ギャラリー(gallery/posts + like/unlike), Flash(flash CRUD + like/unlike) の専用メソッドを追加。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a5be06b commit e508c06

1 file changed

Lines changed: 250 additions & 0 deletions

File tree

src/api.rs

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,256 @@ impl MisskeyClient {
13081308
Ok(())
13091309
}
13101310

1311+
// --- Search ---
1312+
1313+
pub async fn search_users_by_query(
1314+
&self,
1315+
host: &str,
1316+
token: &str,
1317+
query: &str,
1318+
limit: i64,
1319+
) -> Result<Value, NoteDeckError> {
1320+
self.request(
1321+
host,
1322+
token,
1323+
"users/search",
1324+
json!({ "query": query, "limit": limit }),
1325+
)
1326+
.await
1327+
}
1328+
1329+
pub async fn search_hashtags(
1330+
&self,
1331+
host: &str,
1332+
token: &str,
1333+
query: &str,
1334+
limit: i64,
1335+
) -> Result<Vec<String>, NoteDeckError> {
1336+
let data = self
1337+
.request(
1338+
host,
1339+
token,
1340+
"hashtags/search",
1341+
json!({ "query": query, "limit": limit }),
1342+
)
1343+
.await?;
1344+
let tags: Vec<String> = serde_json::from_value(data)?;
1345+
Ok(tags)
1346+
}
1347+
1348+
// --- ActivityPub resolve ---
1349+
1350+
pub async fn ap_show(
1351+
&self,
1352+
host: &str,
1353+
token: &str,
1354+
uri: &str,
1355+
) -> Result<Value, NoteDeckError> {
1356+
self.request(host, token, "ap/show", json!({ "uri": uri }))
1357+
.await
1358+
}
1359+
1360+
// --- Server stats ---
1361+
1362+
pub async fn get_server_stats(
1363+
&self,
1364+
host: &str,
1365+
token: &str,
1366+
) -> Result<Value, NoteDeckError> {
1367+
self.request(host, token, "stats", json!({})).await
1368+
}
1369+
1370+
pub async fn get_meta_detail(
1371+
&self,
1372+
host: &str,
1373+
token: &str,
1374+
) -> Result<Value, NoteDeckError> {
1375+
self.request(host, token, "meta", json!({ "detail": true }))
1376+
.await
1377+
}
1378+
1379+
// --- User achievements ---
1380+
1381+
pub async fn get_user_achievements(
1382+
&self,
1383+
host: &str,
1384+
token: &str,
1385+
user_id: &str,
1386+
) -> Result<Value, NoteDeckError> {
1387+
self.request(
1388+
host,
1389+
token,
1390+
"users/achievements",
1391+
json!({ "userId": user_id }),
1392+
)
1393+
.await
1394+
}
1395+
1396+
// --- User notes (with filters) ---
1397+
1398+
pub async fn get_user_notes_filtered(
1399+
&self,
1400+
host: &str,
1401+
token: &str,
1402+
params: Value,
1403+
) -> Result<Value, NoteDeckError> {
1404+
self.request(host, token, "users/notes", params).await
1405+
}
1406+
1407+
pub async fn get_user_featured_notes(
1408+
&self,
1409+
host: &str,
1410+
token: &str,
1411+
user_id: &str,
1412+
limit: i64,
1413+
until_id: Option<&str>,
1414+
) -> Result<Value, NoteDeckError> {
1415+
let mut params = json!({ "userId": user_id, "limit": limit });
1416+
if let Some(id) = until_id {
1417+
params["untilId"] = json!(id);
1418+
}
1419+
self.request(host, token, "users/featured-notes", params)
1420+
.await
1421+
}
1422+
1423+
// --- Pages ---
1424+
1425+
pub async fn get_pages(
1426+
&self,
1427+
host: &str,
1428+
token: &str,
1429+
endpoint: &str,
1430+
limit: i64,
1431+
) -> Result<Value, NoteDeckError> {
1432+
self.request(host, token, endpoint, json!({ "limit": limit }))
1433+
.await
1434+
}
1435+
1436+
pub async fn get_page(
1437+
&self,
1438+
host: &str,
1439+
token: &str,
1440+
page_id: &str,
1441+
) -> Result<Value, NoteDeckError> {
1442+
self.request(host, token, "pages/show", json!({ "pageId": page_id }))
1443+
.await
1444+
}
1445+
1446+
pub async fn like_page(
1447+
&self,
1448+
host: &str,
1449+
token: &str,
1450+
page_id: &str,
1451+
) -> Result<(), NoteDeckError> {
1452+
self.request(host, token, "pages/like", json!({ "pageId": page_id }))
1453+
.await?;
1454+
Ok(())
1455+
}
1456+
1457+
pub async fn unlike_page(
1458+
&self,
1459+
host: &str,
1460+
token: &str,
1461+
page_id: &str,
1462+
) -> Result<(), NoteDeckError> {
1463+
self.request(host, token, "pages/unlike", json!({ "pageId": page_id }))
1464+
.await?;
1465+
Ok(())
1466+
}
1467+
1468+
// --- Gallery ---
1469+
1470+
pub async fn get_gallery_posts(
1471+
&self,
1472+
host: &str,
1473+
token: &str,
1474+
limit: i64,
1475+
until_id: Option<&str>,
1476+
) -> Result<Value, NoteDeckError> {
1477+
let mut params = json!({ "limit": limit });
1478+
if let Some(id) = until_id {
1479+
params["untilId"] = json!(id);
1480+
}
1481+
self.request(host, token, "gallery/posts", params).await
1482+
}
1483+
1484+
pub async fn like_gallery_post(
1485+
&self,
1486+
host: &str,
1487+
token: &str,
1488+
post_id: &str,
1489+
) -> Result<(), NoteDeckError> {
1490+
self.request(
1491+
host,
1492+
token,
1493+
"gallery/posts/like",
1494+
json!({ "postId": post_id }),
1495+
)
1496+
.await?;
1497+
Ok(())
1498+
}
1499+
1500+
pub async fn unlike_gallery_post(
1501+
&self,
1502+
host: &str,
1503+
token: &str,
1504+
post_id: &str,
1505+
) -> Result<(), NoteDeckError> {
1506+
self.request(
1507+
host,
1508+
token,
1509+
"gallery/posts/unlike",
1510+
json!({ "postId": post_id }),
1511+
)
1512+
.await?;
1513+
Ok(())
1514+
}
1515+
1516+
// --- Flash (Play) ---
1517+
1518+
pub async fn get_flashes(
1519+
&self,
1520+
host: &str,
1521+
token: &str,
1522+
endpoint: &str,
1523+
limit: i64,
1524+
) -> Result<Value, NoteDeckError> {
1525+
self.request(host, token, endpoint, json!({ "limit": limit }))
1526+
.await
1527+
}
1528+
1529+
pub async fn get_flash(
1530+
&self,
1531+
host: &str,
1532+
token: &str,
1533+
flash_id: &str,
1534+
) -> Result<Value, NoteDeckError> {
1535+
self.request(host, token, "flash/show", json!({ "flashId": flash_id }))
1536+
.await
1537+
}
1538+
1539+
pub async fn like_flash(
1540+
&self,
1541+
host: &str,
1542+
token: &str,
1543+
flash_id: &str,
1544+
) -> Result<(), NoteDeckError> {
1545+
self.request(host, token, "flash/like", json!({ "flashId": flash_id }))
1546+
.await?;
1547+
Ok(())
1548+
}
1549+
1550+
pub async fn unlike_flash(
1551+
&self,
1552+
host: &str,
1553+
token: &str,
1554+
flash_id: &str,
1555+
) -> Result<(), NoteDeckError> {
1556+
self.request(host, token, "flash/unlike", json!({ "flashId": flash_id }))
1557+
.await?;
1558+
Ok(())
1559+
}
1560+
13111561
// --- Chat API ---
13121562

13131563
pub async fn get_chat_history(

0 commit comments

Comments
 (0)