Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

# Runs on PRs and pushes to the default branch. We use `pull_request` (never
# `pull_request_target`), so secrets are NOT exposed to pull requests from forks.
on:
pull_request:
push:
branches: [main, master]

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
env:
FASTCOMMENTS_API_KEY: ${{ secrets.FASTCOMMENTS_API_KEY }}
FASTCOMMENTS_TENANT_ID: ${{ secrets.FASTCOMMENTS_TENANT_ID }}
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ serde_with = { version = "^3.8", default-features = false, features = ["base64",
serde_json = "^1.0"
serde_repr = "^0.1"

# Date/time (required by generated models with date-time fields)
chrono = { version = "^0.4", features = ["serde"] }

# HTTP client
reqwest = { version = "^0.12", features = ["json", "multipart", "stream"] }
url = "^2.5"
Expand Down
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ The SDK requires Rust 2021 edition or later.

The FastComments Rust SDK consists of several modules:

- **Client Module** - Auto-generated API client for FastComments REST APIs
- **Client Module** - API client for FastComments REST APIs
- Complete type definitions for all API models
- Both authenticated (`DefaultApi`) and public (`PublicApi`) endpoints
- Three API clients covering all FastComments methods:
- `default_api` (**DefaultApi**) - API-key-authenticated methods for server-side use
- `public_api` (**PublicApi**) - public, no-API-key methods that are safe to call from browsers and mobile apps
- `moderation_api` (**ModerationApi**) - methods backing the moderator dashboard, including comment moderation (list, count, search, logs, export), moderation actions (remove/restore, flag, set review/spam/approval status, votes, reopen/close thread), bans (ban from a comment, undo, pre-ban summaries, ban status/preferences, banned-user counts), and badges & trust (award/remove badges, manual badges, get/set trust factor, user internal profile). Every Moderation method accepts an `sso` parameter so the call can be made on behalf of an SSO-authenticated moderator.
- Full async/await support with tokio
- See [client/README.md](client/README.md) for detailed API documentation

Expand Down Expand Up @@ -133,6 +136,44 @@ async fn main() {
}
```

### Using the Moderation API

The moderation methods back the moderator dashboard. They use an API-key `Configuration` just like the authenticated API, and each method accepts an optional `sso` token so the call can be made on behalf of an SSO-authenticated moderator.

```rust
use fastcomments_sdk::client::apis::configuration::{ApiKey, Configuration};
use fastcomments_sdk::client::apis::moderation_api;

#[tokio::main]
async fn main() {
// Create configuration with API key
let mut config = Configuration::new();
config.api_key = Some(ApiKey {
prefix: None,
key: "your-api-key".to_string(),
});

// Count comments waiting in the moderation queue
let result = moderation_api::get_count(
&config,
moderation_api::GetCountParams {
text_search: None,
by_ip_from_comment: None,
filter: None,
search_filters: None,
demo: None,
sso: None, // pass an SSO token to act as an SSO-authenticated moderator
},
)
.await;

match result {
Ok(response) => println!("Comments to moderate: {}", response.count),
Err(e) => eprintln!("Error: {:?}", e),
}
}
```

### Using SSO for Authentication

```rust
Expand Down
Loading
Loading