mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 20:31:12 +00:00
Merge branch 'main' into admin_purge
This commit is contained in:
commit
9c59fc2a31
18 changed files with 1512 additions and 1663 deletions
26
.drone.yml
26
.drone.yml
|
@ -9,23 +9,25 @@ platform:
|
|||
steps:
|
||||
|
||||
- name: yarn
|
||||
image: node:14-alpine
|
||||
image: node:17-alpine
|
||||
commands:
|
||||
- yarn
|
||||
|
||||
- name: yarn lint
|
||||
image: node:14-alpine
|
||||
image: node:17-alpine
|
||||
commands:
|
||||
- yarn lint
|
||||
|
||||
- name: npm
|
||||
image: plugins/npm
|
||||
settings:
|
||||
username:
|
||||
from_secret: npm_username
|
||||
password:
|
||||
from_secret: npm_password
|
||||
email: tyhou13@gmx.com
|
||||
- name: npm publish
|
||||
image: node:17-alpine
|
||||
commands:
|
||||
- echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" >> .npmrc
|
||||
- echo "email = $NPM_EMAIL" >> ~/.npmrc
|
||||
- npm publish
|
||||
environment:
|
||||
NPM_AUTH_TOKEN:
|
||||
from_secret: npm_token
|
||||
NPM_EMAIL: tyhou13@gmx.com
|
||||
when:
|
||||
ref:
|
||||
- refs/tags/*
|
||||
|
@ -41,11 +43,11 @@ platform:
|
|||
steps:
|
||||
|
||||
- name: yarn
|
||||
image: node:14-alpine
|
||||
image: node:17-alpine
|
||||
commands:
|
||||
- yarn
|
||||
|
||||
- name: yarn lint
|
||||
image: node:14-alpine
|
||||
image: node:17-alpine
|
||||
commands:
|
||||
- yarn lint
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
"browser": true
|
||||
},
|
||||
"plugins": [
|
||||
"jane"
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"extends": [
|
||||
"plugin:jane/recommended",
|
||||
"plugin:jane/typescript"
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
|
@ -16,14 +16,11 @@
|
|||
"warnOnUnsupportedTypeScriptVersion": false
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/camelcase": 0,
|
||||
"@typescript-eslint/member-delimiter-style": 0,
|
||||
"@typescript-eslint/no-empty-interface": 0,
|
||||
"@typescript-eslint/no-empty-function": 0,
|
||||
"@typescript-eslint/ban-ts-comment": 0,
|
||||
"@typescript-eslint/no-explicit-any": 0,
|
||||
"@typescript-eslint/no-this-alias": 0,
|
||||
"@typescript-eslint/no-unused-vars": 0,
|
||||
"@typescript-eslint/no-use-before-define": 0,
|
||||
"@typescript-eslint/no-useless-constructor": 0,
|
||||
"@typescript-eslint/explicit-module-boundary-types": 0,
|
||||
"arrow-body-style": 0,
|
||||
"curly": 0,
|
||||
"eol-last": 0,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = Object.assign(require('eslint-plugin-jane/prettier-ts'), {
|
||||
arrowParens: 'avoid',
|
||||
module.exports = Object.assign(require("eslint-plugin-prettier"), {
|
||||
arrowParens: "avoid",
|
||||
semi: true,
|
||||
});
|
||||
|
|
29
package.json
29
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "lemmy-js-client",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"version": "0.13.4-rc.2",
|
||||
"version": "0.16.4-rc.3",
|
||||
"author": "Dessalines <tyhou13@gmx.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/index.js",
|
||||
|
@ -16,18 +16,23 @@
|
|||
},
|
||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||
"devDependencies": {
|
||||
"@types/node": "^16.10.2",
|
||||
"@types/node": "^17.0.33",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-jane": "^9.0.6",
|
||||
"husky": "^7.0.2",
|
||||
"lint-staged": "^11.1.2",
|
||||
"node-fetch": "^3.0.0",
|
||||
"prettier": "^2.4.1",
|
||||
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
||||
"@typescript-eslint/parser": "^5.23.0",
|
||||
"eslint": "^8.15.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^12.4.1",
|
||||
"node-fetch": "^3.2.4",
|
||||
"prettier": "^2.6.2",
|
||||
"prettier-plugin-import-sort": "^0.0.7",
|
||||
"prettier-plugin-organize-imports": "^2.3.4",
|
||||
"prettier-plugin-packagejson": "^2.2.18",
|
||||
"sortpack": "^2.2.0",
|
||||
"typedoc": "^0.21.6",
|
||||
"typedoc-plugin-sourcefile-url": "^1.0.6",
|
||||
"typescript": "^4.4.3"
|
||||
"typescript": "^4.6.4"
|
||||
},
|
||||
"types": "./dist/index.d.ts",
|
||||
"lint-staged": {
|
||||
|
@ -38,5 +43,11 @@
|
|||
"package.json": [
|
||||
"sortpack"
|
||||
]
|
||||
},
|
||||
"importSort": {
|
||||
".js, .jsx, .ts, .tsx": {
|
||||
"style": "module",
|
||||
"parser": "typescript"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
418
src/http.ts
418
src/http.ts
|
@ -1,4 +1,4 @@
|
|||
import fetch from 'node-fetch';
|
||||
import fetch from "node-fetch";
|
||||
import {
|
||||
CommentReportResponse,
|
||||
CommentResponse,
|
||||
|
@ -15,7 +15,7 @@ import {
|
|||
RemoveComment,
|
||||
ResolveCommentReport,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
} from "./interfaces/api/comment";
|
||||
import {
|
||||
AddModToCommunity,
|
||||
AddModToCommunityResponse,
|
||||
|
@ -34,10 +34,54 @@ import {
|
|||
ListCommunitiesResponse,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
AddAdmin,
|
||||
AddAdminResponse,
|
||||
BannedPersonsResponse,
|
||||
BanPerson,
|
||||
BanPersonResponse,
|
||||
BlockPerson,
|
||||
BlockPersonResponse,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeleteAccountResponse,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetBannedPersons,
|
||||
GetCaptchaResponse,
|
||||
GetPersonDetails,
|
||||
GetPersonDetailsResponse,
|
||||
GetPersonMentions,
|
||||
GetPersonMentionsResponse,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetRepliesResponse,
|
||||
GetReportCount,
|
||||
GetReportCountResponse,
|
||||
GetUnreadCount,
|
||||
GetUnreadCountResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
MarkAllAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
PasswordResetResponse,
|
||||
PersonMentionResponse,
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
VerifyEmailResponse,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
CreatePostReport,
|
||||
DeletePost,
|
||||
EditPost,
|
||||
GetPost,
|
||||
|
@ -46,18 +90,19 @@ import {
|
|||
GetPostsResponse,
|
||||
GetSiteMetadata,
|
||||
GetSiteMetadataResponse,
|
||||
ListPostReports,
|
||||
ListPostReportsResponse,
|
||||
LockPost,
|
||||
CreatePostReport,
|
||||
MarkPostAsRead,
|
||||
PostReportResponse,
|
||||
PostResponse,
|
||||
RemovePost,
|
||||
ResolvePostReport,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
ResolvePostReport,
|
||||
ListPostReports,
|
||||
ListPostReportsResponse,
|
||||
} from './interfaces/api/post';
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
|
@ -66,62 +111,30 @@ import {
|
|||
GetSiteConfig,
|
||||
GetSiteConfigResponse,
|
||||
GetSiteResponse,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
GetUnreadRegistrationApplicationCountResponse,
|
||||
LeaveAdmin,
|
||||
ListRegistrationApplications,
|
||||
ListRegistrationApplicationsResponse,
|
||||
PurgeComment,
|
||||
PurgeCommunity,
|
||||
PurgeItemResponse,
|
||||
PurgePerson,
|
||||
PurgePost,
|
||||
RegistrationApplicationResponse,
|
||||
ResolveObject,
|
||||
ResolveObjectResponse,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
SearchResponse,
|
||||
SiteResponse,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
import {
|
||||
AddAdmin,
|
||||
AddAdminResponse,
|
||||
BanPerson,
|
||||
BanPersonResponse,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetCaptchaResponse,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetRepliesResponse,
|
||||
GetPersonDetails,
|
||||
GetPersonDetailsResponse,
|
||||
GetPersonMentions,
|
||||
GetPersonMentionsResponse,
|
||||
Login,
|
||||
LoginResponse,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
PasswordResetResponse,
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
PersonMentionResponse,
|
||||
BlockPerson,
|
||||
BlockPersonResponse,
|
||||
GetReportCount,
|
||||
GetReportCountResponse,
|
||||
} from './interfaces/api/person';
|
||||
|
||||
import { VERSION } from './interfaces/others';
|
||||
} from "./interfaces/api/site";
|
||||
import { VERSION } from "./interfaces/others";
|
||||
|
||||
enum HttpType {
|
||||
Get = 'GET',
|
||||
Post = 'POST',
|
||||
Put = 'PUT',
|
||||
Get = "GET",
|
||||
Post = "POST",
|
||||
Put = "PUT",
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,535 +159,682 @@ export class LemmyHttp {
|
|||
|
||||
/**
|
||||
* Gets the site, and your user data.
|
||||
* `HTTP.GET /site`
|
||||
*/
|
||||
async getSite(form: GetSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Get, '/site', form);
|
||||
return this.wrapper(HttpType.Get, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create your site.
|
||||
* `HTTP.POST /site`
|
||||
*/
|
||||
async createSite(form: CreateSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site', form);
|
||||
return this.wrapper(HttpType.Post, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit your site.
|
||||
* `HTTP.PUT /site`
|
||||
*/
|
||||
async editSite(form: EditSite): Promise<SiteResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site', form);
|
||||
return this.wrapper(HttpType.Put, "/site", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer your site to another user.
|
||||
* Leave the Site admins.
|
||||
* `HTTP.POST /user/leave_admin`
|
||||
*/
|
||||
async transferSite(form: TransferSite): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Post, '/site/transfer', form);
|
||||
async leaveAdmin(form: LeaveAdmin): Promise<GetSiteResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/leave_admin", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your site configuration.
|
||||
* `HTTP.GET /site/config`
|
||||
*/
|
||||
async getSiteConfig(form: GetSiteConfig): Promise<GetSiteConfigResponse> {
|
||||
return this.wrapper(HttpType.Get, '/site/config', form);
|
||||
return this.wrapper(HttpType.Get, "/site/config", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save your site config.
|
||||
* `HTTP.PUT /site/config`
|
||||
*/
|
||||
async saveSiteConfig(form: SaveSiteConfig): Promise<GetSiteConfigResponse> {
|
||||
return this.wrapper(HttpType.Put, '/site/config', form);
|
||||
return this.wrapper(HttpType.Put, "/site/config", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the modlog.
|
||||
* `HTTP.GET /modlog`
|
||||
*/
|
||||
async getModlog(form: GetModlog): Promise<GetModlogResponse> {
|
||||
return this.wrapper(HttpType.Get, '/modlog', form);
|
||||
return this.wrapper(HttpType.Get, "/modlog", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search lemmy.
|
||||
* `HTTP.GET /search`
|
||||
*/
|
||||
async search(form: Search): Promise<SearchResponse> {
|
||||
return this.wrapper(HttpType.Get, '/search', form);
|
||||
return this.wrapper(HttpType.Get, "/search", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a non-local / federated object.
|
||||
* `HTTP.GET /resolve_object`
|
||||
*/
|
||||
async resolveObject(form: ResolveObject): Promise<ResolveObjectResponse> {
|
||||
return this.wrapper(HttpType.Get, '/resolve_object', form);
|
||||
return this.wrapper(HttpType.Get, "/resolve_object", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new community.
|
||||
* `HTTP.POST /community`
|
||||
*/
|
||||
async createCommunity(form: CreateCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community', form);
|
||||
return this.wrapper(HttpType.Post, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch a community.
|
||||
* `HTTP.GET /community`
|
||||
*/
|
||||
async getCommunity(form: GetCommunity): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community', form);
|
||||
return this.wrapper(HttpType.Get, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a community.
|
||||
* `HTTP.PUT /community`
|
||||
*/
|
||||
async editCommunity(form: EditCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Put, '/community', form);
|
||||
return this.wrapper(HttpType.Put, "/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List communities, with various filters.
|
||||
* `HTTP.GET /community/list`
|
||||
*/
|
||||
async listCommunities(
|
||||
form: ListCommunities
|
||||
): Promise<ListCommunitiesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/community/list', form);
|
||||
return this.wrapper(HttpType.Get, "/community/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow / subscribe to a community.
|
||||
* `HTTP.POST /community/follow`
|
||||
*/
|
||||
async followCommunity(form: FollowCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/follow', form);
|
||||
return this.wrapper(HttpType.Post, "/community/follow", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a community.
|
||||
* `HTTP.POST /community/block`
|
||||
*/
|
||||
async blockCommunity(form: BlockCommunity): Promise<BlockCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/block', form);
|
||||
return this.wrapper(HttpType.Post, "/community/block", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a community.
|
||||
* `HTTP.POST /community/delete`
|
||||
*/
|
||||
async deleteCommunity(form: DeleteCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/community/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a community.
|
||||
* `HTTP.POST /community/remove`
|
||||
*/
|
||||
async removeCommunity(form: RemoveCommunity): Promise<CommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/community/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer your community to an existing moderator.
|
||||
* `HTTP.POST /community/transfer`
|
||||
*/
|
||||
async transferCommunity(
|
||||
form: TransferCommunity
|
||||
): Promise<GetCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/transfer', form);
|
||||
return this.wrapper(HttpType.Post, "/community/transfer", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a user from a community.
|
||||
* `HTTP.POST /community/ban_user`
|
||||
*/
|
||||
async banFromCommunity(
|
||||
form: BanFromCommunity
|
||||
): Promise<BanFromCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/ban_user', form);
|
||||
return this.wrapper(HttpType.Post, "/community/ban_user", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a moderator to your community.
|
||||
* `HTTP.POST /community/mod`
|
||||
*/
|
||||
async addModToCommunity(
|
||||
form: AddModToCommunity
|
||||
): Promise<AddModToCommunityResponse> {
|
||||
return this.wrapper(HttpType.Post, '/community/mod', form);
|
||||
return this.wrapper(HttpType.Post, "/community/mod", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a post.
|
||||
* `HTTP.POST /post`
|
||||
*/
|
||||
async createPost(form: CreatePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post', form);
|
||||
return this.wrapper(HttpType.Post, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch a post.
|
||||
* `HTTP.GET /post`
|
||||
*/
|
||||
async getPost(form: GetPost): Promise<GetPostResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post', form);
|
||||
return this.wrapper(HttpType.Get, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a post.
|
||||
* `HTTP.PUT /post`
|
||||
*/
|
||||
async editPost(form: EditPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post', form);
|
||||
return this.wrapper(HttpType.Put, "/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a post.
|
||||
* `HTTP.POST /post/delete`
|
||||
*/
|
||||
async deletePost(form: DeletePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/post/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a post.
|
||||
* `HTTP.POST /post/remove`
|
||||
*/
|
||||
async removePost(form: RemovePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/post/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a post as read.
|
||||
* `HTTP.POST /post/mark_as_read`
|
||||
*/
|
||||
async markPostAsRead(form: MarkPostAsRead): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, "/post/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator can lock a post ( IE disable new comments ).
|
||||
* `HTTP.POST /post/lock`
|
||||
*/
|
||||
async lockPost(form: LockPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/lock', form);
|
||||
return this.wrapper(HttpType.Post, "/post/lock", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator can sticky a post ( IE stick it to the top of a community ).
|
||||
* `HTTP.POST /post/sticky`
|
||||
*/
|
||||
async stickyPost(form: StickyPost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/sticky', form);
|
||||
return this.wrapper(HttpType.Post, "/post/sticky", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch posts, with various filters.
|
||||
* `HTTP.GET /post/list`
|
||||
*/
|
||||
async getPosts(form: GetPosts): Promise<GetPostsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/list', form);
|
||||
return this.wrapper(HttpType.Get, "/post/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like / vote on a post.
|
||||
* `HTTP.POST /post/like`
|
||||
*/
|
||||
async likePost(form: CreatePostLike): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/like', form);
|
||||
return this.wrapper(HttpType.Post, "/post/like", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a post.
|
||||
* `HTTP.PUT /post/save`
|
||||
*/
|
||||
async savePost(form: SavePost): Promise<PostResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post/save', form);
|
||||
return this.wrapper(HttpType.Put, "/post/save", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a post.
|
||||
* `HTTP.POST /post/report`
|
||||
*/
|
||||
async createPostReport(form: CreatePostReport): Promise<PostReportResponse> {
|
||||
return this.wrapper(HttpType.Post, '/post/report', form);
|
||||
return this.wrapper(HttpType.Post, "/post/report", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a post report. Only a mod can do this.
|
||||
* `HTTP.PUT /post/report/resolve`
|
||||
*/
|
||||
async resolvePostReport(
|
||||
form: ResolvePostReport
|
||||
): Promise<PostReportResponse> {
|
||||
return this.wrapper(HttpType.Put, '/post/report/resolve', form);
|
||||
return this.wrapper(HttpType.Put, "/post/report/resolve", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List post reports.
|
||||
* `HTTP.GET /post/report/list`
|
||||
*/
|
||||
async listPostReports(
|
||||
form: ListPostReports
|
||||
): Promise<ListPostReportsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/report/list', form);
|
||||
return this.wrapper(HttpType.Get, "/post/report/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch metadata for any given site.
|
||||
* `HTTP.GET /post/site_metadata`
|
||||
*/
|
||||
async getSiteMetadata(
|
||||
form: GetSiteMetadata
|
||||
): Promise<GetSiteMetadataResponse> {
|
||||
return this.wrapper(HttpType.Get, '/post/site_metadata', form);
|
||||
return this.wrapper(HttpType.Get, "/post/site_metadata", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a comment.
|
||||
* `HTTP.POST /comment`
|
||||
*/
|
||||
async createComment(form: CreateComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment', form);
|
||||
return this.wrapper(HttpType.Post, "/comment", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a comment.
|
||||
* `HTTP.PUT /comment`
|
||||
*/
|
||||
async editComment(form: EditComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment', form);
|
||||
return this.wrapper(HttpType.Put, "/comment", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a comment.
|
||||
* `HTTP.POST /comment/delete`
|
||||
*/
|
||||
async deleteComment(form: DeleteComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* A moderator remove for a comment.
|
||||
* `HTTP.POST /comment/remove`
|
||||
*/
|
||||
async removeComment(form: RemoveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/remove', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/remove", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a comment as read.
|
||||
* `HTTP.POST /comment/mark_as_read`
|
||||
*/
|
||||
async markCommentAsRead(form: MarkCommentAsRead): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like / vote on a comment.
|
||||
* `HTTP.POST /comment/like`
|
||||
*/
|
||||
async likeComment(form: CreateCommentLike): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/like', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/like", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a comment.
|
||||
* `HTTP.PUT /comment/save`
|
||||
*/
|
||||
async saveComment(form: SaveComment): Promise<CommentResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment/save', form);
|
||||
return this.wrapper(HttpType.Put, "/comment/save", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch comments.
|
||||
* `HTTP.GET /comment/list`
|
||||
*/
|
||||
async getComments(form: GetComments): Promise<GetCommentsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/comment/list', form);
|
||||
return this.wrapper(HttpType.Get, "/comment/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Report a comment.
|
||||
* `HTTP.POST /comment/report`
|
||||
*/
|
||||
async createCommentReport(
|
||||
form: CreateCommentReport
|
||||
): Promise<CommentReportResponse> {
|
||||
return this.wrapper(HttpType.Post, '/comment/report', form);
|
||||
return this.wrapper(HttpType.Post, "/comment/report", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a comment report. Only a mod can do this.
|
||||
* `HTTP.PUT /comment/report/resolve`
|
||||
*/
|
||||
async resolveCommentReport(
|
||||
form: ResolveCommentReport
|
||||
): Promise<CommentReportResponse> {
|
||||
return this.wrapper(HttpType.Put, '/comment/report/resolve', form);
|
||||
return this.wrapper(HttpType.Put, "/comment/report/resolve", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List comment reports.
|
||||
* `HTTP.GET /comment/report/list`
|
||||
*/
|
||||
async listCommentReports(
|
||||
form: ListCommentReports
|
||||
): Promise<ListCommentReportsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/comment/report/list', form);
|
||||
return this.wrapper(HttpType.Get, "/comment/report/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get / fetch private messages.
|
||||
* `HTTP.GET /private_message/list`
|
||||
*/
|
||||
async getPrivateMessages(
|
||||
form: GetPrivateMessages
|
||||
): Promise<PrivateMessagesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/private_message/list', form);
|
||||
return this.wrapper(HttpType.Get, "/private_message/list", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a private message.
|
||||
* `HTTP.POST /private_message`
|
||||
*/
|
||||
async createPrivateMessage(
|
||||
form: CreatePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a private message.
|
||||
* `HTTP.PUT /private_message`
|
||||
*/
|
||||
async editPrivateMessage(
|
||||
form: EditPrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Put, '/private_message', form);
|
||||
return this.wrapper(HttpType.Put, "/private_message", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a private message.
|
||||
* `HTTP.POST /private_message/delete`
|
||||
*/
|
||||
async deletePrivateMessage(
|
||||
form: DeletePrivateMessage
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/delete', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a private message as read.
|
||||
* `HTTP.POST /private_message/mark_as_read`
|
||||
*/
|
||||
async markPrivateMessageAsRead(
|
||||
form: MarkPrivateMessageAsRead
|
||||
): Promise<PrivateMessageResponse> {
|
||||
return this.wrapper(HttpType.Post, '/private_message/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/private_message/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
* `HTTP.POST /user/register`
|
||||
*/
|
||||
async register(form: Register): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/register', form);
|
||||
return this.wrapper(HttpType.Post, "/user/register", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log into lemmy.
|
||||
* `HTTP.POST /user/login`
|
||||
*/
|
||||
async login(form: Login): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/login', form);
|
||||
return this.wrapper(HttpType.Post, "/user/login", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details for a person.
|
||||
* `HTTP.GET /user`
|
||||
*/
|
||||
async getPersonDetails(
|
||||
form: GetPersonDetails
|
||||
): Promise<GetPersonDetailsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user', form);
|
||||
return this.wrapper(HttpType.Get, "/user", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mentions for your user.
|
||||
* `HTTP.GET /user/mention`
|
||||
*/
|
||||
async getPersonMentions(
|
||||
form: GetPersonMentions
|
||||
): Promise<GetPersonMentionsResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/mention', form);
|
||||
return this.wrapper(HttpType.Get, "/user/mention", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a person mention as read.
|
||||
* `HTTP.POST /user/mention/mark_as_read`
|
||||
*/
|
||||
async markPersonMentionAsRead(
|
||||
form: MarkPersonMentionAsRead
|
||||
): Promise<PersonMentionResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mention/mark_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/user/mention/mark_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment replies.
|
||||
* `HTTP.GET /user/replies`
|
||||
*/
|
||||
async getReplies(form: GetReplies): Promise<GetRepliesResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/replies', form);
|
||||
return this.wrapper(HttpType.Get, "/user/replies", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ban a person from your site.
|
||||
* `HTTP.POST /user/ban`
|
||||
*/
|
||||
async banPerson(form: BanPerson): Promise<BanPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/ban', form);
|
||||
return this.wrapper(HttpType.Post, "/user/ban", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of banned users
|
||||
* `HTTP.GET /user/banned`
|
||||
*/
|
||||
async getBannedPersons(
|
||||
form: GetBannedPersons
|
||||
): Promise<BannedPersonsResponse> {
|
||||
return this.wrapper(HttpType.Get, "/user/banned", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block a person.
|
||||
* `HTTP.POST /user/block`
|
||||
*/
|
||||
async blockPerson(form: BlockPerson): Promise<BlockPersonResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/block', form);
|
||||
return this.wrapper(HttpType.Post, "/user/block", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a Captcha.
|
||||
* `HTTP.GET /user/get_captcha`
|
||||
*/
|
||||
async getCaptcha(): Promise<GetCaptchaResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/get_captcha', {});
|
||||
return this.wrapper(HttpType.Get, "/user/get_captcha", {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete your account.
|
||||
* `HTTP.POST /user/delete_account`
|
||||
*/
|
||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/delete_account', form);
|
||||
async deleteAccount(form: DeleteAccount): Promise<DeleteAccountResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset your password.
|
||||
* `HTTP.POST /user/password_reset`
|
||||
*/
|
||||
async passwordReset(form: PasswordReset): Promise<PasswordResetResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_reset', form);
|
||||
return this.wrapper(HttpType.Post, "/user/password_reset", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your password from an email / token based reset.
|
||||
* `HTTP.POST /user/password_change`
|
||||
*/
|
||||
async passwordChange(form: PasswordChange): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/password_change', form);
|
||||
return this.wrapper(HttpType.Post, "/user/password_change", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark all replies as read.
|
||||
* `HTTP.POST /user/mark_all_as_read`
|
||||
*/
|
||||
async markAllAsRead(form: MarkAllAsRead): Promise<GetRepliesResponse> {
|
||||
return this.wrapper(HttpType.Post, '/user/mark_all_as_read', form);
|
||||
return this.wrapper(HttpType.Post, "/user/mark_all_as_read", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save your user settings.
|
||||
* `HTTP.PUT /user/save_user_settings`
|
||||
*/
|
||||
async saveUserSettings(form: SaveUserSettings): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Put, '/user/save_user_settings', form);
|
||||
return this.wrapper(HttpType.Put, "/user/save_user_settings", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change your user password.
|
||||
* `HTTP.PUT /user/change_password`
|
||||
*/
|
||||
async changePassword(form: ChangePassword): Promise<LoginResponse> {
|
||||
return this.wrapper(HttpType.Put, '/user/change_password', form);
|
||||
return this.wrapper(HttpType.Put, "/user/change_password", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get counts for your reports
|
||||
* `HTTP.GET /user/report_count`
|
||||
*/
|
||||
async getReportCount(form: GetReportCount): Promise<GetReportCountResponse> {
|
||||
return this.wrapper(HttpType.Get, '/user/report_count', form);
|
||||
return this.wrapper(HttpType.Get, "/user/report_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your unread counts
|
||||
* `HTTP.GET /user/unread_count`
|
||||
*/
|
||||
async getUnreadCount(form: GetUnreadCount): Promise<GetUnreadCountResponse> {
|
||||
return this.wrapper(HttpType.Get, "/user/unread_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
* `HTTP.POST /user/verify_email`
|
||||
*/
|
||||
async verifyEmail(form: VerifyEmail): Promise<VerifyEmailResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/verify_email", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an admin to your site.
|
||||
* `HTTP.POST /admin/add`
|
||||
*/
|
||||
async addAdmin(form: AddAdmin): Promise<AddAdminResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/add', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/add", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
* `HTTP.GET /admin/registration_application/count`
|
||||
*/
|
||||
async getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
): Promise<GetUnreadRegistrationApplicationCountResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
"/admin/registration_application/count",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the registration applications.
|
||||
* `HTTP.GET /admin/registration_application/list`
|
||||
*/
|
||||
async listRegistrationApplications(
|
||||
form: ListRegistrationApplications
|
||||
): Promise<ListRegistrationApplicationsResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
"/admin/registration_application/list",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
* `HTTP.PUT /admin/registration_application/approve`
|
||||
*/
|
||||
async approveRegistrationApplication(
|
||||
form: ApproveRegistrationApplication
|
||||
): Promise<RegistrationApplicationResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Put,
|
||||
"/admin/registration_application/approve",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a person from the database.
|
||||
* `HTTP.POST /admin/purge/person`
|
||||
*/
|
||||
async purgePerson(form: PurgePerson): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/person', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/purge/person", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a community from the database.
|
||||
* `HTTP.POST /admin/purge/community`
|
||||
*/
|
||||
async purgeCommunity(form: PurgeCommunity): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/community', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/purge/community", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a post from the database.
|
||||
* `HTTP.POST /admin/purge/post`
|
||||
*/
|
||||
async purgePost(form: PurgePost): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/post', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/purge/post", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge / Delete a comment from the database.
|
||||
* `HTTP.POST /admin/purge/comment`
|
||||
*/
|
||||
async purgeComment(form: PurgeComment): Promise<PurgeItemResponse> {
|
||||
return this.wrapper(HttpType.Post, '/admin/purge/comment', form);
|
||||
return this.wrapper(HttpType.Post, "/admin/purge/comment", form);
|
||||
}
|
||||
|
||||
private buildFullUrl(endpoint: string): string {
|
||||
|
@ -689,14 +849,14 @@ export class LemmyHttp {
|
|||
if (type_ == HttpType.Get) {
|
||||
let getUrl = `${this.buildFullUrl(endpoint)}?${encodeGetParams(form)}`;
|
||||
return fetch(getUrl, {
|
||||
method: 'GET',
|
||||
method: "GET",
|
||||
headers: this.headers,
|
||||
}).then(d => d.json() as Promise<ResponseType>);
|
||||
} else {
|
||||
return fetch(this.buildFullUrl(endpoint), {
|
||||
method: type_,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
...this.headers,
|
||||
},
|
||||
body: JSON.stringify(form),
|
||||
|
@ -707,6 +867,6 @@ export class LemmyHttp {
|
|||
|
||||
function encodeGetParams(p: any): string {
|
||||
return Object.entries(p)
|
||||
.map(kv => kv.map(encodeURIComponent).join('='))
|
||||
.join('&');
|
||||
.map(kv => kv.map(encodeURIComponent).join("="))
|
||||
.join("&");
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export * from './interfaces';
|
||||
export * from './http';
|
||||
export * from './websocket';
|
||||
export * from "./http";
|
||||
export * from "./interfaces";
|
||||
export * from "./websocket";
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { CommentReportView, CommentView } from '../views';
|
||||
import { ListingType, SortType } from "../others";
|
||||
import { CommentReportView, CommentView } from "../views";
|
||||
|
||||
export interface CreateComment {
|
||||
content: string;
|
||||
|
@ -77,14 +78,8 @@ export interface CreateCommentLike {
|
|||
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
export interface GetComments {
|
||||
/**
|
||||
* The [[ListingType]].
|
||||
*/
|
||||
type_?: string;
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import { ListingType, SortType } from "../others";
|
||||
import { Site } from "../source";
|
||||
import {
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
} from "../views";
|
||||
|
||||
/**
|
||||
* You can use either `id` or `name` as an id.
|
||||
|
@ -17,6 +19,7 @@ export interface GetCommunity {
|
|||
|
||||
export interface GetCommunityResponse {
|
||||
community_view: CommunityView;
|
||||
site?: Site;
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
@ -28,6 +31,7 @@ export interface CreateCommunity {
|
|||
icon?: string;
|
||||
banner?: string;
|
||||
nsfw?: boolean;
|
||||
posting_restricted_to_mods?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -36,15 +40,8 @@ export interface CommunityResponse {
|
|||
}
|
||||
|
||||
export interface ListCommunities {
|
||||
/**
|
||||
* The [[ListingType]].
|
||||
*/
|
||||
type_?: string;
|
||||
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
|
@ -64,6 +61,9 @@ export interface BanFromCommunity {
|
|||
*/
|
||||
remove_data?: boolean;
|
||||
reason?: string;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ export interface EditCommunity {
|
|||
icon?: string;
|
||||
banner?: string;
|
||||
nsfw?: boolean;
|
||||
posting_restricted_to_mods?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -110,6 +111,9 @@ export interface RemoveCommunity {
|
|||
community_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
export * from './comment';
|
||||
export * from './community';
|
||||
export * from './post';
|
||||
export * from './site';
|
||||
export * from './person';
|
||||
export * from './websocket';
|
||||
export * from "./comment";
|
||||
export * from "./community";
|
||||
export * from "./person";
|
||||
export * from "./post";
|
||||
export * from "./site";
|
||||
export * from "./websocket";
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { SortType } from "../others";
|
||||
import {
|
||||
CommentView,
|
||||
CommunityModeratorView,
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
PersonMentionView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
PostView,
|
||||
PrivateMessageView,
|
||||
} from "../views";
|
||||
|
||||
export interface Login {
|
||||
username_or_email: string;
|
||||
|
@ -19,6 +20,9 @@ export interface Login {
|
|||
*/
|
||||
export interface Register {
|
||||
username: string;
|
||||
/**
|
||||
* Email is mandatory if email verification is enabled on the server
|
||||
*/
|
||||
email?: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
|
@ -29,6 +33,10 @@ export interface Register {
|
|||
captcha_uuid?: string;
|
||||
captcha_answer?: string;
|
||||
honeypot?: string;
|
||||
/**
|
||||
* An answer is mandatory if require application is enabled on the server
|
||||
*/
|
||||
answer?: string;
|
||||
}
|
||||
|
||||
export interface GetCaptcha {}
|
||||
|
@ -106,7 +114,12 @@ export interface ChangePassword {
|
|||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
jwt: string;
|
||||
/**
|
||||
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
||||
*/
|
||||
jwt?: string;
|
||||
verify_email_sent: boolean;
|
||||
registration_created: boolean;
|
||||
}
|
||||
|
||||
export interface GetPersonDetails {
|
||||
|
@ -115,7 +128,7 @@ export interface GetPersonDetails {
|
|||
* To get details for a federated user, use `person@instance.tld`.
|
||||
*/
|
||||
username?: string;
|
||||
sort?: string;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
|
@ -161,6 +174,9 @@ export interface BanPerson {
|
|||
*/
|
||||
remove_data?: boolean;
|
||||
reason?: string;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
expires?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
@ -171,10 +187,7 @@ export interface BanPersonResponse {
|
|||
}
|
||||
|
||||
export interface GetReplies {
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only?: boolean;
|
||||
|
@ -182,10 +195,7 @@ export interface GetReplies {
|
|||
}
|
||||
|
||||
export interface GetPersonMentions {
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only?: boolean;
|
||||
|
@ -210,6 +220,8 @@ export interface DeleteAccount {
|
|||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeleteAccountResponse {}
|
||||
|
||||
export interface PasswordReset {
|
||||
email: string;
|
||||
}
|
||||
|
@ -275,6 +287,22 @@ export interface GetReportCountResponse {
|
|||
post_reports: number;
|
||||
}
|
||||
|
||||
export interface GetUnreadCount {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetUnreadCountResponse {
|
||||
replies: number;
|
||||
mentions: number;
|
||||
private_messages: number;
|
||||
}
|
||||
|
||||
export interface VerifyEmail {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface VerifyEmailResponse {}
|
||||
|
||||
export interface BlockPerson {
|
||||
person_id: number;
|
||||
block: boolean;
|
||||
|
@ -285,3 +313,11 @@ export interface BlockPersonResponse {
|
|||
person_view: PersonViewSafe;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
||||
export interface GetBannedPersons {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface BannedPersonsResponse {
|
||||
banned: PersonViewSafe[];
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { SiteMetadata } from '..';
|
||||
import { ListingType, SiteMetadata, SortType } from "../others";
|
||||
import {
|
||||
CommunityView,
|
||||
CommentView,
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
PostReportView,
|
||||
PostView,
|
||||
} from '../views';
|
||||
} from "../views";
|
||||
|
||||
export interface CreatePost {
|
||||
name: string;
|
||||
|
@ -35,16 +35,8 @@ export interface GetPostResponse {
|
|||
}
|
||||
|
||||
export interface GetPosts {
|
||||
/**
|
||||
* The [[ListingType]].
|
||||
*
|
||||
* Post listing types are `All, Subscribed, Community`
|
||||
*/
|
||||
type_?: string;
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
|
@ -95,6 +87,15 @@ export interface RemovePost {
|
|||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a post as read.
|
||||
*/
|
||||
export interface MarkPostAsRead {
|
||||
post_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can lock a post.
|
||||
*/
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
import { ListingType, SearchType, SortType } from "../others";
|
||||
import {
|
||||
AdminPurgeCommentView,
|
||||
AdminPurgeCommunityView,
|
||||
AdminPurgePersonView,
|
||||
AdminPurgePostView,
|
||||
CommentView,
|
||||
CommunityBlockView,
|
||||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
LocalUserSettingsView,
|
||||
PersonBlockView,
|
||||
} from '../views';
|
||||
import {
|
||||
CommentView,
|
||||
CommunityView,
|
||||
LocalUserSettingsView,
|
||||
ModAddCommunityView,
|
||||
ModTransferCommunityView,
|
||||
ModAddView,
|
||||
ModBanFromCommunityView,
|
||||
ModBanView,
|
||||
|
@ -22,10 +19,13 @@ import {
|
|||
ModRemoveCommunityView,
|
||||
ModRemovePostView,
|
||||
ModStickyPostView,
|
||||
PostView,
|
||||
SiteView,
|
||||
ModTransferCommunityView,
|
||||
PersonBlockView,
|
||||
PersonViewSafe,
|
||||
} from '../views';
|
||||
PostView,
|
||||
RegistrationApplicationView,
|
||||
SiteView,
|
||||
} from "../views";
|
||||
|
||||
/**
|
||||
* Search lemmy for different types of data.
|
||||
|
@ -35,22 +35,12 @@ export interface Search {
|
|||
* The search query string.
|
||||
*/
|
||||
q: string;
|
||||
|
||||
/**
|
||||
* The [[SearchType]].
|
||||
*/
|
||||
type_?: string;
|
||||
type_?: SearchType;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
creator_id?: number;
|
||||
/**
|
||||
* The [[SortType]].
|
||||
*/
|
||||
sort?: string;
|
||||
/**
|
||||
* The [[ListingType]].
|
||||
*/
|
||||
listing_type?: string;
|
||||
sort?: SortType;
|
||||
listing_type?: ListingType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
|
@ -72,6 +62,7 @@ export interface GetModlog {
|
|||
community_id?: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetModlogResponse {
|
||||
|
@ -101,6 +92,12 @@ export interface CreateSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
default_theme?: string;
|
||||
default_post_listing_type?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -114,6 +111,13 @@ export interface EditSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
default_theme?: string;
|
||||
legal_information?: string;
|
||||
default_post_listing_type?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -131,7 +135,6 @@ export interface GetSiteResponse {
|
|||
*/
|
||||
site_view?: SiteView;
|
||||
admins: PersonViewSafe[];
|
||||
banned: PersonViewSafe[];
|
||||
online: number;
|
||||
version: string;
|
||||
/**
|
||||
|
@ -152,8 +155,7 @@ export interface MyUserInfo {
|
|||
person_blocks: PersonBlockView[];
|
||||
}
|
||||
|
||||
export interface TransferSite {
|
||||
person_id: number;
|
||||
export interface LeaveAdmin {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -190,14 +192,12 @@ export interface ResolveObjectResponse {
|
|||
|
||||
export interface PurgePerson {
|
||||
person_id: number;
|
||||
remove_images: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface PurgeCommunity {
|
||||
community_id: number;
|
||||
remove_images: boolean;
|
||||
reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
@ -217,3 +217,36 @@ export interface PurgeComment {
|
|||
export interface PurgeItemResponse {
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplications {
|
||||
/**
|
||||
* Only shows the unread applications (IE those without an admin actor)
|
||||
*/
|
||||
unread_only?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplicationsResponse {
|
||||
registration_applications: RegistrationApplicationView[];
|
||||
}
|
||||
|
||||
export interface ApproveRegistrationApplication {
|
||||
id: number;
|
||||
approve: boolean;
|
||||
deny_reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationResponse {
|
||||
registration_application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCount {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||
registration_applications: number;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
export * from './api';
|
||||
export * from './aggregates';
|
||||
export * from './others';
|
||||
export * from './source';
|
||||
export * from './views';
|
||||
export * from "./aggregates";
|
||||
export * from "./api";
|
||||
export * from "./others";
|
||||
export * from "./source";
|
||||
export * from "./views";
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const VERSION = 'v3';
|
||||
export const VERSION = "v3";
|
||||
|
||||
/**
|
||||
* All of the websocket operations available.
|
||||
|
@ -26,6 +26,7 @@ export enum UserOperation {
|
|||
RemovePost,
|
||||
LockPost,
|
||||
StickyPost,
|
||||
MarkPostAsRead,
|
||||
SavePost,
|
||||
EditCommunity,
|
||||
DeleteCommunity,
|
||||
|
@ -42,13 +43,17 @@ export enum UserOperation {
|
|||
EditSite,
|
||||
GetSite,
|
||||
AddAdmin,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
ListRegistrationApplications,
|
||||
ApproveRegistrationApplication,
|
||||
BanPerson,
|
||||
GetBannedPersons,
|
||||
Search,
|
||||
ResolveObject,
|
||||
MarkAllAsRead,
|
||||
SaveUserSettings,
|
||||
TransferCommunity,
|
||||
TransferSite,
|
||||
LeaveAdmin,
|
||||
DeleteAccount,
|
||||
PasswordReset,
|
||||
PasswordChange,
|
||||
|
@ -78,6 +83,8 @@ export enum UserOperation {
|
|||
ResolvePostReport,
|
||||
ListPostReports,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
VerifyEmail,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,62 +94,62 @@ export enum SortType {
|
|||
/**
|
||||
* Posts sorted by the most recent comment.
|
||||
*/
|
||||
Active = 'Active',
|
||||
Active = "Active",
|
||||
/**
|
||||
* Posts sorted by the published time.
|
||||
*/
|
||||
Hot = 'Hot',
|
||||
New = 'New',
|
||||
Hot = "Hot",
|
||||
New = "New",
|
||||
/**
|
||||
* The top posts for this last day.
|
||||
*/
|
||||
TopDay = 'TopDay',
|
||||
TopDay = "TopDay",
|
||||
/**
|
||||
* The top posts for this last week.
|
||||
*/
|
||||
TopWeek = 'TopWeek',
|
||||
TopWeek = "TopWeek",
|
||||
/**
|
||||
* The top posts for this last month.
|
||||
*/
|
||||
TopMonth = 'TopMonth',
|
||||
TopMonth = "TopMonth",
|
||||
/**
|
||||
* The top posts for this last year.
|
||||
*/
|
||||
TopYear = 'TopYear',
|
||||
TopYear = "TopYear",
|
||||
/**
|
||||
* The top posts of all time.
|
||||
*/
|
||||
TopAll = 'TopAll',
|
||||
TopAll = "TopAll",
|
||||
/**
|
||||
* Posts sorted by the most comments.
|
||||
*/
|
||||
MostComments = 'MostComments',
|
||||
MostComments = "MostComments",
|
||||
/**
|
||||
* Posts sorted by the newest comments, with no necrobumping. IE a forum sort.
|
||||
*/
|
||||
NewComments = 'NewComments',
|
||||
NewComments = "NewComments",
|
||||
}
|
||||
|
||||
/**
|
||||
* The different listing types for post and comment fetches.
|
||||
*/
|
||||
export enum ListingType {
|
||||
All = 'All',
|
||||
Local = 'Local',
|
||||
Subscribed = 'Subscribed',
|
||||
Community = 'Community',
|
||||
All = "All",
|
||||
Local = "Local",
|
||||
Subscribed = "Subscribed",
|
||||
Community = "Community",
|
||||
}
|
||||
|
||||
/**
|
||||
* Search types for lemmy's search.
|
||||
*/
|
||||
export enum SearchType {
|
||||
All = 'All',
|
||||
Comments = 'Comments',
|
||||
Posts = 'Posts',
|
||||
Communities = 'Communities',
|
||||
Users = 'Users',
|
||||
Url = 'Url',
|
||||
All = "All",
|
||||
Comments = "Comments",
|
||||
Posts = "Posts",
|
||||
Communities = "Communities",
|
||||
Users = "Users",
|
||||
Url = "Url",
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,8 @@ export interface LocalUserSettings {
|
|||
show_scores: boolean;
|
||||
show_read_posts: boolean;
|
||||
show_new_post_notifs: boolean;
|
||||
email_verified: boolean;
|
||||
accepted_application: boolean;
|
||||
}
|
||||
|
||||
export interface PersonSafe {
|
||||
|
@ -33,22 +35,33 @@ export interface PersonSafe {
|
|||
matrix_user_id?: string;
|
||||
admin: boolean;
|
||||
bot_account: boolean;
|
||||
ban_expires?: string;
|
||||
}
|
||||
|
||||
export interface Site {
|
||||
id: number;
|
||||
name: string;
|
||||
sidebar?: string;
|
||||
description?: string;
|
||||
creator_id: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
community_creation_admin_only: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
description?: string;
|
||||
community_creation_admin_only: boolean;
|
||||
require_email_verification: boolean;
|
||||
require_application: boolean;
|
||||
application_question?: string;
|
||||
private_instance: boolean;
|
||||
default_theme: string;
|
||||
default_post_listing_type: string;
|
||||
actor_id: string;
|
||||
last_refreshed_at: string;
|
||||
inbox_url: string;
|
||||
public_key: string;
|
||||
legal_information?: string;
|
||||
}
|
||||
|
||||
export interface PrivateMessage {
|
||||
|
@ -242,6 +255,7 @@ export interface CommunitySafe {
|
|||
local: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
posting_restricted_to_mods: boolean;
|
||||
}
|
||||
|
||||
export interface CommentReport {
|
||||
|
@ -278,3 +292,12 @@ export interface PersonMention {
|
|||
read: boolean;
|
||||
published: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplication {
|
||||
id: number;
|
||||
local_user_id: number;
|
||||
answer: string;
|
||||
admin_id?: number;
|
||||
deny_reason?: string;
|
||||
published: string;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
import {
|
||||
CommentAggregates,
|
||||
CommunityAggregates,
|
||||
PersonAggregates,
|
||||
PostAggregates,
|
||||
SiteAggregates,
|
||||
PersonAggregates,
|
||||
} from './aggregates';
|
||||
} from "./aggregates";
|
||||
import {
|
||||
AdminPurgeComment,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
Comment,
|
||||
CommentReport,
|
||||
CommunitySafe,
|
||||
LocalUserSettings,
|
||||
ModAdd,
|
||||
ModAddCommunity,
|
||||
ModTransferCommunity,
|
||||
ModBan,
|
||||
ModBanFromCommunity,
|
||||
ModLockPost,
|
||||
|
@ -19,18 +23,15 @@ import {
|
|||
ModRemoveCommunity,
|
||||
ModRemovePost,
|
||||
ModStickyPost,
|
||||
ModTransferCommunity,
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
RegistrationApplication,
|
||||
Site,
|
||||
PersonMention,
|
||||
PersonSafe,
|
||||
LocalUserSettings,
|
||||
AdminPurgeCommunity,
|
||||
AdminPurgePerson,
|
||||
AdminPurgePost,
|
||||
AdminPurgeComment,
|
||||
} from './source';
|
||||
} from "./source";
|
||||
|
||||
export interface PersonViewSafe {
|
||||
person: PersonSafe;
|
||||
|
@ -60,7 +61,6 @@ export interface LocalUserSettingsView {
|
|||
|
||||
export interface SiteView {
|
||||
site: Site;
|
||||
creator: PersonSafe;
|
||||
counts: SiteAggregates;
|
||||
}
|
||||
|
||||
|
@ -244,3 +244,10 @@ export interface CommunityView {
|
|||
blocked: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationView {
|
||||
registration_application: RegistrationApplication;
|
||||
creator_local_user: LocalUserSettings;
|
||||
creator: PersonSafe;
|
||||
admin?: PersonSafe;
|
||||
}
|
||||
|
|
124
src/websocket.ts
124
src/websocket.ts
|
@ -10,7 +10,7 @@ import {
|
|||
RemoveComment,
|
||||
ResolveCommentReport,
|
||||
SaveComment,
|
||||
} from './interfaces/api/comment';
|
||||
} from "./interfaces/api/comment";
|
||||
import {
|
||||
AddModToCommunity,
|
||||
BanFromCommunity,
|
||||
|
@ -23,7 +23,33 @@ import {
|
|||
ListCommunities,
|
||||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from './interfaces/api/community';
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
BlockPerson,
|
||||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetBannedPersons,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
CreatePostLike,
|
||||
|
@ -35,17 +61,22 @@ import {
|
|||
GetSiteMetadata,
|
||||
ListPostReports,
|
||||
LockPost,
|
||||
MarkPostAsRead,
|
||||
RemovePost,
|
||||
ResolvePostReport,
|
||||
SavePost,
|
||||
StickyPost,
|
||||
} from './interfaces/api/post';
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
LeaveAdmin,
|
||||
ListRegistrationApplications,
|
||||
PurgeComment,
|
||||
PurgeCommunity,
|
||||
PurgePerson,
|
||||
|
@ -53,33 +84,9 @@ import {
|
|||
ResolveObject,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
TransferSite,
|
||||
} from './interfaces/api/site';
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetPrivateMessages,
|
||||
GetReplies,
|
||||
GetPersonDetails,
|
||||
GetPersonMentions,
|
||||
Login,
|
||||
MarkAllAsRead,
|
||||
MarkPrivateMessageAsRead,
|
||||
MarkPersonMentionAsRead,
|
||||
PasswordChange,
|
||||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
ChangePassword,
|
||||
BlockPerson,
|
||||
GetReportCount,
|
||||
} from './interfaces/api/person';
|
||||
import { UserJoin, PostJoin, CommunityJoin } from './interfaces/api/websocket';
|
||||
import { UserOperation } from './interfaces/others';
|
||||
} from "./interfaces/api/site";
|
||||
import { CommunityJoin, PostJoin, UserJoin } from "./interfaces/api/websocket";
|
||||
import { UserOperation } from "./interfaces/others";
|
||||
|
||||
/**
|
||||
* Helps build lemmy websocket message requests, that you can use in your Websocket sends.
|
||||
|
@ -330,6 +337,13 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.StickyPost, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a post as read.
|
||||
*/
|
||||
markPostAsRead(form: MarkPostAsRead) {
|
||||
return wrapper(UserOperation.MarkPostAsRead, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a post.
|
||||
*/
|
||||
|
@ -387,10 +401,10 @@ export class LemmyWebsocket {
|
|||
}
|
||||
|
||||
/**
|
||||
* Transfer your site to another user.
|
||||
* Leave the Site admins.
|
||||
*/
|
||||
transferSite(form: TransferSite) {
|
||||
return wrapper(UserOperation.TransferSite, form);
|
||||
leaveAdmin(form: LeaveAdmin) {
|
||||
return wrapper(UserOperation.LeaveAdmin, form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -400,6 +414,13 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.BanPerson, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of banned users
|
||||
*/
|
||||
getBannedPersons(form: GetBannedPersons) {
|
||||
return wrapper(UserOperation.GetBannedPersons, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an admin to your site.
|
||||
*/
|
||||
|
@ -407,6 +428,29 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.AddAdmin, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
*/
|
||||
getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
) {
|
||||
return wrapper(UserOperation.GetUnreadRegistrationApplicationCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the unread registration applications.
|
||||
*/
|
||||
listRegistrationApplications(form: ListRegistrationApplications) {
|
||||
return wrapper(UserOperation.ListRegistrationApplications, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
*/
|
||||
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
||||
return wrapper(UserOperation.ApproveRegistrationApplication, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details for a person.
|
||||
*/
|
||||
|
@ -512,6 +556,20 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.GetReportCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get your unread counts
|
||||
*/
|
||||
getUnreadCount(form: GetUnreadCount) {
|
||||
return wrapper(UserOperation.GetUnreadCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
*/
|
||||
verifyEmail(form: VerifyEmail) {
|
||||
return wrapper(UserOperation.VerifyEmail, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue