(
State(state): State<Arc<ServerState>>,
Path((session_id, msg_id)): Path<(String, String)>,
Json(req): Json<AddPartRequest>,
)
| 1195 | } |
| 1196 | |
| 1197 | async fn add_message_part( |
| 1198 | State(state): State<Arc<ServerState>>, |
| 1199 | Path((session_id, msg_id)): Path<(String, String)>, |
| 1200 | Json(req): Json<AddPartRequest>, |
| 1201 | ) -> Result<Json<serde_json::Value>> { |
| 1202 | let mut sessions = state.sessions.lock().await; |
| 1203 | let session = sessions |
| 1204 | .get_mut(&session_id) |
| 1205 | .ok_or_else(|| ApiError::SessionNotFound(session_id.clone()))?; |
| 1206 | let message = session |
| 1207 | .get_message_mut(&msg_id) |
| 1208 | .ok_or_else(|| ApiError::NotFound(format!("Message not found: {}", msg_id)))?; |
| 1209 | |
| 1210 | let part = build_message_part(req, &msg_id)?; |
| 1211 | let part_id = part.id.clone(); |
| 1212 | message.parts.push(part); |
| 1213 | session.touch(); |
| 1214 | drop(sessions); |
| 1215 | persist_sessions_if_enabled(&state).await; |
| 1216 | |
| 1217 | Ok(Json(serde_json::json!({ |
| 1218 | "added": true, |
| 1219 | "session_id": session_id, |
| 1220 | "message_id": msg_id, |
| 1221 | "part_id": part_id, |
| 1222 | }))) |
| 1223 | } |
| 1224 | |
| 1225 | async fn delete_part( |
| 1226 | State(state): State<Arc<ServerState>>, |
nothing calls this directly
no test coverage detected