Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 13m53s
## HTTP Client Refactoring - Create unified HttpClient module (src/http_client.rs) - Refactor 24 files to use shared HTTP client - Replace .unwrap() with proper error handling - Eliminate code duplication in HTTP requests ## Project Restructuring - Rename package: ai → aibot - Add dual binary support: aibot (main) + ai (compatibility alias) - Migrate config directory: ~/.config/ai/ → ~/.config/syui/ai/bot/ - Implement backward compatibility with automatic migration ## Testing Infrastructure - Add unit tests for HttpClient - Create test infrastructure with cargo-make - Add test commands: test, test-quick, test-verbose ## Documentation - Complete migration guide with step-by-step instructions - Updated development guide with new structure - HTTP client API reference documentation - Comprehensive refactoring summary ## Files Changed - Modified: 24 source files (HTTP client integration) - Added: src/http_client.rs, src/alias.rs, src/tests/ - Added: 5 documentation files in docs/ - Added: migration setup script 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
69 lines
1.8 KiB
Rust
69 lines
1.8 KiB
Rust
use crate::http_client::HttpClient;
|
|
use crate::data_toml;
|
|
use crate::url;
|
|
use iso8601_timestamp::Timestamp;
|
|
use serde_json::json;
|
|
|
|
pub async fn post_request(
|
|
m: String,
|
|
link: String,
|
|
cid: String,
|
|
uri: String,
|
|
cid_root: String,
|
|
uri_root: String,
|
|
img: String,
|
|
title: String,
|
|
description: String,
|
|
) -> String {
|
|
let did = data_toml(&"did");
|
|
let handle = data_toml(&"handle");
|
|
let url = url(&"record_create");
|
|
let col = "app.bsky.feed.post".to_string();
|
|
|
|
let d = Timestamp::now_utc();
|
|
let d = d.to_string();
|
|
|
|
let post = json!({
|
|
"repo": handle.to_string(),
|
|
"did": did.to_string(),
|
|
"collection": col.to_string(),
|
|
"record": {
|
|
"createdAt": d.to_string(),
|
|
"text": m.to_string(),
|
|
"embed": {
|
|
"$type": "app.bsky.embed.external",
|
|
"external": {
|
|
"uri": link.to_string(),
|
|
"thumb": {
|
|
"$type": "blob",
|
|
"ref": {
|
|
"$link": img.to_string()
|
|
},
|
|
"mimeType": "image/jpeg",
|
|
"size": 0
|
|
},
|
|
"title": title.to_string(),
|
|
"description": description.to_string()
|
|
}
|
|
},
|
|
"reply": {
|
|
"root": {
|
|
"cid": cid_root.to_string(),
|
|
"uri": uri_root.to_string()
|
|
},
|
|
"parent": {
|
|
"cid": cid.to_string(),
|
|
"uri": uri.to_string()
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
let client = HttpClient::new();
|
|
|
|
match client.post_json_with_auth(&url, &post).await {
|
|
Ok(response) => response,
|
|
Err(e) => format!("Error: {}", e),
|
|
}
|
|
}
|