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
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
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: jiro4989/setup-nim-action@v2
with:
nim-version: 'stable'
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: nimble install -dy
- name: Run unit tests
run: nim c -r tests/test_sso.nim
- name: Run integration tests
run: nim c -d:ssl -r tests/test_sso_integration.nim
env:
FASTCOMMENTS_API_KEY: ${{ secrets.FASTCOMMENTS_API_KEY }}
FASTCOMMENTS_TENANT_ID: ${{ secrets.FASTCOMMENTS_TENANT_ID }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ tests/test_sso_integration
# OpenAPI Generator metadata
.openapi-generator/
.openapi-generator-ignore
openapi-generator-cli.jar
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ This library contains the generated API client and the SSO utilities to make wor

### Public vs Secured APIs

For the API client, there are two API modules, `api_default` and `api_public`. The `api_default` contains methods that require your API key, and `api_public` contains api calls
that can be made directly from a browser/mobile device/etc without authentication.
For the API client, there are three API modules, `api_default`, `api_public`, and `api_moderation`. The `api_default` contains methods that require your API key, and `api_public` contains api calls
that can be made directly from a browser/mobile device/etc without authentication. The `api_moderation` module contains methods for the moderator dashboard.

The `api_moderation` methods cover listing, counting, searching, and exporting comments and their logs; moderation actions like removing/restoring comments, flagging, setting review/spam/approval status, adjusting votes, and reopening/closing threads; bans (banning a user from a comment, undoing a ban, pre-ban summaries, ban status and preferences, and banned-user counts); and badges & trust (awarding/removing a badge, listing manual badges, getting/setting a user's trust factor, and fetching a user's internal profile). Every `api_moderation` method accepts an `sso` parameter so the call is authenticated as an SSO moderator.

## Quick Start

Expand Down Expand Up @@ -122,10 +124,40 @@ if response.isSome:
echo "Found ", resp.comments.get().len, " comments"
```

### Using Moderation APIs (ModerationAPI)

Moderation endpoints power the moderator dashboard and are authenticated with an SSO token for the acting moderator:

```nim
import httpclient
import fastcomments
import fastcomments/apis/api_moderation

let client = newHttpClient()

# List comments in the moderation dashboard
let (response, httpResponse) = getApiComments(
httpClient = client,
page = 0,
count = 30,
textSearch = "",
byIPFromComment = "",
filters = "",
searchFilters = "",
sorts = "",
demo = false,
sso = "your-sso-token"
)

if response.isSome:
let resp = response.get()
echo "Found ", resp.comments.len, " comments"
```

### Common Issues

1. **401 authentication error**: Make sure you set the `x-api-key` header on your HttpClient before making DefaultAPI requests: `client.headers["x-api-key"] = "your-api-key"`
2. **Wrong API class**: Use `api_default` for server-side authenticated requests, `api_public` for client-side/public requests.
2. **Wrong API class**: Use `api_default` for server-side authenticated requests, `api_public` for client-side/public requests, and `api_moderation` for moderator dashboard requests.

## Making API Calls

Expand Down
64 changes: 62 additions & 2 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ No description provided (generated by Openapi Generator https://github.com/opena
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.

- API version: 0.0.0
- Package version: 1.1.0
- Generator version: 7.19.0-SNAPSHOT
- Package version: 1.1.1
- Generator version: 7.23.0-SNAPSHOT
- Build package: org.openapitools.codegen.languages.NimClientCodegen

## Installation
Expand Down Expand Up @@ -139,26 +139,86 @@ api_default | updateTenant | **PATCH** /api/v1/tenants/{id} |
api_default | updateTenantPackage | **PATCH** /api/v1/tenant-packages/{id} |
api_default | updateTenantUser | **PATCH** /api/v1/tenant-users/{id} |
api_default | updateUserBadge | **PUT** /api/v1/user-badges/{id} |
api_moderation | deleteModerationVote | **DELETE** /auth/my-account/moderate-comments/vote/{commentId}/{voteId} |
api_moderation | getApiComments | **GET** /auth/my-account/moderate-comments/api/comments |
api_moderation | getApiExportStatus | **GET** /auth/my-account/moderate-comments/api/export/status |
api_moderation | getApiIds | **GET** /auth/my-account/moderate-comments/api/ids |
api_moderation | getBanUsersFromComment | **GET** /auth/my-account/moderate-comments/ban-users/from-comment/{commentId} |
api_moderation | getCommentBanStatus | **GET** /auth/my-account/moderate-comments/get-comment-ban-status/{commentId} |
api_moderation | getCommentChildren | **GET** /auth/my-account/moderate-comments/comment-children/{commentId} |
api_moderation | getCount | **GET** /auth/my-account/moderate-comments/count |
api_moderation | getCounts | **GET** /auth/my-account/moderate-comments/banned-users/counts |
api_moderation | getLogs | **GET** /auth/my-account/moderate-comments/logs/{commentId} |
api_moderation | getManualBadges | **GET** /auth/my-account/moderate-comments/get-manual-badges |
api_moderation | getManualBadgesForUser | **GET** /auth/my-account/moderate-comments/get-manual-badges-for-user |
api_moderation | getModerationComment | **GET** /auth/my-account/moderate-comments/comment/{commentId} |
api_moderation | getModerationCommentText | **GET** /auth/my-account/moderate-comments/get-comment-text/{commentId} |
api_moderation | getPreBanSummary | **GET** /auth/my-account/moderate-comments/pre-ban-summary/{commentId} |
api_moderation | getSearchCommentsSummary | **GET** /auth/my-account/moderate-comments/search/comments/summary |
api_moderation | getSearchPages | **GET** /auth/my-account/moderate-comments/search/pages |
api_moderation | getSearchSites | **GET** /auth/my-account/moderate-comments/search/sites |
api_moderation | getSearchSuggest | **GET** /auth/my-account/moderate-comments/search/suggest |
api_moderation | getSearchUsers | **GET** /auth/my-account/moderate-comments/search/users |
api_moderation | getTrustFactor | **GET** /auth/my-account/moderate-comments/get-trust-factor |
api_moderation | getUserBanPreference | **GET** /auth/my-account/moderate-comments/user-ban-preference |
api_moderation | getUserInternalProfile | **GET** /auth/my-account/moderate-comments/get-user-internal-profile |
api_moderation | postAdjustCommentVotes | **POST** /auth/my-account/moderate-comments/adjust-comment-votes/{commentId} |
api_moderation | postApiExport | **POST** /auth/my-account/moderate-comments/api/export |
api_moderation | postBanUserFromComment | **POST** /auth/my-account/moderate-comments/ban-user/from-comment/{commentId} |
api_moderation | postBanUserUndo | **POST** /auth/my-account/moderate-comments/ban-user/undo |
api_moderation | postBulkPreBanSummary | **POST** /auth/my-account/moderate-comments/bulk-pre-ban-summary |
api_moderation | postCommentsByIds | **POST** /auth/my-account/moderate-comments/comments-by-ids |
api_moderation | postFlagComment | **POST** /auth/my-account/moderate-comments/flag-comment/{commentId} |
api_moderation | postRemoveComment | **POST** /auth/my-account/moderate-comments/remove-comment/{commentId} |
api_moderation | postRestoreDeletedComment | **POST** /auth/my-account/moderate-comments/restore-deleted-comment/{commentId} |
api_moderation | postSetCommentApprovalStatus | **POST** /auth/my-account/moderate-comments/set-comment-approval-status/{commentId} |
api_moderation | postSetCommentReviewStatus | **POST** /auth/my-account/moderate-comments/set-comment-review-status/{commentId} |
api_moderation | postSetCommentSpamStatus | **POST** /auth/my-account/moderate-comments/set-comment-spam-status/{commentId} |
api_moderation | postSetCommentText | **POST** /auth/my-account/moderate-comments/set-comment-text/{commentId} |
api_moderation | postUnFlagComment | **POST** /auth/my-account/moderate-comments/un-flag-comment/{commentId} |
api_moderation | postVote | **POST** /auth/my-account/moderate-comments/vote/{commentId} |
api_moderation | putAwardBadge | **PUT** /auth/my-account/moderate-comments/award-badge |
api_moderation | putCloseThread | **PUT** /auth/my-account/moderate-comments/close-thread |
api_moderation | putRemoveBadge | **PUT** /auth/my-account/moderate-comments/remove-badge |
api_moderation | putReopenThread | **PUT** /auth/my-account/moderate-comments/reopen-thread |
api_moderation | setTrustFactor | **PUT** /auth/my-account/moderate-comments/set-trust-factor |
api_public | blockFromCommentPublic | **POST** /block-from-comment/{commentId} |
api_public | checkedCommentsForBlocked | **GET** /check-blocked-comments |
api_public | createCommentPublic | **POST** /comments/{tenantId} |
api_public | createFeedPostPublic | **POST** /feed-posts/{tenantId} |
api_public | createV1PageReact | **POST** /page-reacts/v1/likes/{tenantId} |
api_public | createV2PageReact | **POST** /page-reacts/v2/{tenantId} |
api_public | deleteCommentPublic | **DELETE** /comments/{tenantId}/{commentId} |
api_public | deleteCommentVote | **DELETE** /comments/{tenantId}/{commentId}/vote/{voteId} |
api_public | deleteFeedPostPublic | **DELETE** /feed-posts/{tenantId}/{postId} |
api_public | deleteV1PageReact | **DELETE** /page-reacts/v1/likes/{tenantId} |
api_public | deleteV2PageReact | **DELETE** /page-reacts/v2/{tenantId} |
api_public | flagCommentPublic | **POST** /flag-comment/{commentId} |
api_public | getCommentText | **GET** /comments/{tenantId}/{commentId}/text |
api_public | getCommentVoteUserNames | **GET** /comments/{tenantId}/{commentId}/votes |
api_public | getCommentsForUser | **GET** /comments-for-user |
api_public | getCommentsPublic | **GET** /comments/{tenantId} |
api_public | getEventLog | **GET** /event-log/{tenantId} |
api_public | getFeedPostsPublic | **GET** /feed-posts/{tenantId} |
api_public | getFeedPostsStats | **GET** /feed-posts/{tenantId}/stats |
api_public | getGifLarge | **GET** /gifs/get-large/{tenantId} |
api_public | getGifsSearch | **GET** /gifs/search/{tenantId} |
api_public | getGifsTrending | **GET** /gifs/trending/{tenantId} |
api_public | getGlobalEventLog | **GET** /event-log/global/{tenantId} |
api_public | getOfflineUsers | **GET** /pages/{tenantId}/users/offline |
api_public | getOnlineUsers | **GET** /pages/{tenantId}/users/online |
api_public | getPagesPublic | **GET** /pages/{tenantId} |
api_public | getTranslations | **GET** /translations/{namespace}/{component} |
api_public | getUserNotificationCount | **GET** /user-notifications/get-count |
api_public | getUserNotifications | **GET** /user-notifications |
api_public | getUserPresenceStatuses | **GET** /user-presence-status |
api_public | getUserReactsPublic | **GET** /feed-posts/{tenantId}/user-reacts |
api_public | getUsersInfo | **GET** /pages/{tenantId}/users/info |
api_public | getV1PageLikes | **GET** /page-reacts/v1/likes/{tenantId} |
api_public | getV2PageReactUsers | **GET** /page-reacts/v2/{tenantId}/list |
api_public | getV2PageReacts | **GET** /page-reacts/v2/{tenantId} |
api_public | lockComment | **POST** /comments/{tenantId}/{commentId}/lock |
api_public | logoutPublic | **PUT** /auth/logout |
api_public | pinComment | **POST** /comments/{tenantId}/{commentId}/pin |
api_public | reactFeedPostPublic | **POST** /feed-posts/{tenantId}/react/{postId} |
api_public | resetUserNotificationCount | **POST** /user-notifications/reset-count |
Expand Down
Loading
Loading