Skip to content

Commit 3799a3f

Browse files
hitalinclaude
andcommitted
fix: ゲスト時のチャンネル候補不足をchannels/searchで補完
トークンが空(ゲスト)の場合、認証必須のchannels/followed, my-favorites, ownedをスキップし、認証不要のchannels/featured + channels/search(query="")で全非アーカイブチャンネルを取得する。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 60fd27a commit 3799a3f

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

src/api.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,28 @@ impl MisskeyClient {
330330
host: &str,
331331
token: &str,
332332
) -> Result<Vec<Channel>, NoteDeckError> {
333-
let (followed, favorites, owned, featured) = tokio::join!(
334-
self.request(host, token, "channels/followed", json!({"limit": 100})),
335-
self.request(host, token, "channels/my-favorites", json!({"limit": 100})),
336-
self.request(host, token, "channels/owned", json!({"limit": 100})),
337-
self.request(host, token, "channels/featured", json!({})),
338-
);
333+
let search_fut = self.request(host, token, "channels/search", json!({"query": "", "limit": 100}));
334+
let featured_fut = self.request(host, token, "channels/featured", json!({}));
335+
336+
let (followed, favorites, owned, featured, search) = if token.is_empty() {
337+
let (fe, s) = tokio::join!(featured_fut, search_fut);
338+
(None, None, None, Some(fe), Some(s))
339+
} else {
340+
let (fo, fa, o, fe, s) = tokio::join!(
341+
self.request(host, token, "channels/followed", json!({"limit": 100})),
342+
self.request(host, token, "channels/my-favorites", json!({"limit": 100})),
343+
self.request(host, token, "channels/owned", json!({"limit": 100})),
344+
featured_fut,
345+
search_fut,
346+
);
347+
(Some(fo), Some(fa), Some(o), Some(fe), Some(s))
348+
};
339349

340350
let mut seen = std::collections::HashSet::with_capacity(128);
341351
let mut channels = Vec::with_capacity(128);
342352

343-
// User's own channels first, then featured as fallback
344-
for data in [followed, favorites, owned, featured].into_iter().flatten() {
353+
// User's own channels first, then public channels
354+
for data in [followed, favorites, owned, featured, search].into_iter().flatten().flatten() {
345355
if let Ok(list) = serde_json::from_value::<Vec<Channel>>(data) {
346356
for ch in list {
347357
if seen.insert(ch.id.clone()) {

0 commit comments

Comments
 (0)