Skip to content

Commit 54bb578

Browse files
authored
Merge pull request #14 from FastComments/regen-moderation-api
Add Moderation API and stable response types
2 parents 4be9e99 + 956627c commit 54bb578

821 files changed

Lines changed: 81433 additions & 49971 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CI
2+
3+
# Runs on PRs and pushes to the default branch. We use `pull_request` (never
4+
# `pull_request_target`), so secrets are NOT exposed to pull requests from forks.
5+
on:
6+
pull_request:
7+
push:
8+
branches: [main, master]
9+
10+
permissions:
11+
contents: read
12+
13+
concurrency:
14+
group: ci-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
test:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
- uses: actions/setup-java@v4
23+
with:
24+
distribution: temurin
25+
java-version: '17'
26+
# Run the core module's tests from the repo root (multi-module settings.gradle) so the
27+
# generated client builds as a dependency and the hand-written SSO unit + integration
28+
# tests run. Running from inside core/ resolves to the wrong (client) project.
29+
- name: Run tests
30+
run: |
31+
chmod +x core/gradlew
32+
./core/gradlew :core:test --no-daemon
33+
env:
34+
FASTCOMMENTS_API_KEY: ${{ secrets.FASTCOMMENTS_API_KEY }}
35+
FASTCOMMENTS_TENANT_ID: ${{ secrets.FASTCOMMENTS_TENANT_ID }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ gradle-app.setting
1919
.project
2020
# JDT-specific (Eclipse Java Development Tools)
2121
.classpath
22+
# Eclipse Buildship (Gradle) project settings
23+
.settings/
2224

2325
.idea
26+
openapi-generator-cli.jar

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,14 @@ to make working with the API easier, and the `pubsub` module which is a library
7979

8080
### Public vs Secured APIs
8181

82-
For the API client, there are two classes, `DefaultApi` and `PublicApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains api calls
82+
For the API client, there are three classes, `DefaultApi`, `PublicApi`, and `ModerationApi`. The `DefaultApi` contains methods that require your API key, and `PublicApi` contains methods
8383
that can be made directly from a browser/mobile device/etc without authentication.
8484

85+
The `ModerationApi` powers the moderator dashboard. It contains methods for comment moderation (list, count, search, logs, and export), moderation actions (remove/restore,
86+
flag, set review/spam/approval status, votes, and reopen/close thread), bans (ban from comment, undo a ban, pre-ban summaries, ban status and preferences, and banned-user counts),
87+
and badges & trust (award/remove a badge, manual badges, get/set trust factor, and user internal profile). Every `ModerationApi` method accepts an `sso` parameter so the call can be
88+
performed on behalf of an SSO-authenticated moderator.
89+
8590
## Quick Start
8691

8792
### Using Authenticated APIs (DefaultApi)
@@ -146,6 +151,28 @@ try {
146151
}
147152
```
148153

154+
### Using Moderation APIs (ModerationApi)
155+
156+
The `ModerationApi` drives the moderator dashboard. Each method accepts an `sso` parameter identifying the SSO-authenticated moderator on whose behalf the request is made:
157+
158+
```java
159+
import com.fastcomments.api.ModerationApi;
160+
import com.fastcomments.invoker.ApiException;
161+
import com.fastcomments.model.*;
162+
163+
ModerationApi moderationApi = new ModerationApi();
164+
165+
try {
166+
// List comments awaiting moderation
167+
ModerationAPIGetCommentsResponse response = moderationApi.getApiComments()
168+
.sso("YOUR_SSO_TOKEN")
169+
.execute();
170+
System.out.println(response);
171+
} catch (ApiException e) {
172+
e.printStackTrace();
173+
}
174+
```
175+
149176
### Common Issues
150177

151178
1. **401 "missing-api-key" error**: Make sure you call `apiClient.setApiKey("YOUR_KEY")` before creating the DefaultApi instance.

0 commit comments

Comments
 (0)