refactor(bridge): split handlers.rs into modules

- handlers/mod.rs: public handler functions
- handlers/helpers.rs: utility functions (get_client, get_token, etc.)
- handlers/enrich.rs: post enrichment (display names, files)
- Fix FileInfo export in mm-core

feat(ui): preserve collapsed state on dashboard refresh

- Track collapsed team IDs in buffer-local mattermost--collapsed-teams
- Save collapse state before re-rendering (define-derived-mode resets locals)
- Restore collapse state after re-rendering
- Reset dashboard buffer on mattermost-reset-state
This commit is contained in:
Ivan I. Ovchinnikov
2026-11-21 12:13:57 +03:00
parent 452005b98c
commit b5777565d7
8 changed files with 359 additions and 157 deletions
+30 -2
View File
@@ -1,6 +1,6 @@
use crate::error::ClientError;
use crate::tls;
use mm_core::{Channel, ChannelId, Post, User};
use mm_core::{Channel, ChannelId, FileInfo, Post, User};
use reqwest::header::AUTHORIZATION;
use std::path::Path;
@@ -84,7 +84,6 @@ impl MattermostClient {
Ok(user)
}
/// Batch-fetch users by their IDs. Mattermost limit is 1000 per request.
pub async fn get_users_by_ids(
&self,
token: &str,
@@ -220,6 +219,35 @@ impl MattermostClient {
Ok(posts)
}
/// Fetch file metadata for a post.
pub async fn get_post_files(
&self,
token: &str,
post_id: &str,
) -> Result<Vec<FileInfo>, ClientError> {
let url = format!("{}/api/v4/posts/{}/files/info", self.base_url, post_id);
let response = self
.client
.get(&url)
.header(AUTHORIZATION, format!("Bearer {}", token))
.send()
.await
.map_err(ClientError::Http)?;
if !response.status().is_success() {
return Err(api_error(response).await);
}
#[derive(serde::Deserialize)]
struct FilesResponse {
#[serde(default)]
file_infos: Vec<FileInfo>,
}
let data: FilesResponse = response.json().await.map_err(ClientError::Http)?;
Ok(data.file_infos)
}
pub async fn create_post(
&self,
token: &str,