diff --git a/package.json b/package.json index cf6882f..c75867b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.20.0-alpha.17", + "version": "0.20.0-private-community.9", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/http.ts b/src/http.ts index 16d7974..2d69587 100644 --- a/src/http.ts +++ b/src/http.ts @@ -154,6 +154,12 @@ import { ListTaglinesResponse } from "./types/ListTaglinesResponse"; import { ListCustomEmojis } from "./types/ListCustomEmojis"; import { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; import { GetRandomCommunity } from "./types/GetRandomCommunity"; +import { ApproveCommunityPendingFollower } from "./types/ApproveCommunityPendingFollower"; +import { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount"; +import { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse"; +import { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse"; +import { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows"; +import { CommunityId } from "./types/CommunityId"; enum HttpType { Get = "GET", @@ -482,6 +488,39 @@ export class LemmyHttp { ); } + getCommunityPendingFollowsCount( + community_id: CommunityId, + options?: RequestOptions, + ) { + const form: GetCommunityPendingFollowsCount = { community_id }; + return this.#wrapper< + GetCommunityPendingFollowsCount, + GetCommunityPendingFollowsCountResponse + >(HttpType.Get, "/community/pending_follows/count", form, options); + } + + listCommunityPendingFollows( + form: ListCommunityPendingFollows, + options?: RequestOptions, + ) { + return this.#wrapper< + ListCommunityPendingFollows, + ListCommunityPendingFollowsResponse + >(HttpType.Get, "/community/pending_follows/list", form, options); + } + + approveCommunityPendingFollow( + form: ApproveCommunityPendingFollower, + options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Post, + "/community/pending_follows/approve", + form, + options, + ); + } + /** * Block a community. * diff --git a/src/index.ts b/src/index.ts index af0b610..6bec7c1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,7 @@ export { AdminPurgePerson } from "./types/AdminPurgePerson"; export { AdminPurgePersonView } from "./types/AdminPurgePersonView"; export { AdminPurgePost } from "./types/AdminPurgePost"; export { AdminPurgePostView } from "./types/AdminPurgePostView"; +export { ApproveCommunityPendingFollower } from "./types/ApproveCommunityPendingFollower"; export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication"; export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; export { BanFromCommunity } from "./types/BanFromCommunity"; @@ -49,6 +50,7 @@ export { CommentSortType } from "./types/CommentSortType"; export { CommentView } from "./types/CommentView"; export { Community } from "./types/Community"; export { CommunityAggregates } from "./types/CommunityAggregates"; +export { CommunityFollowerState } from "./types/CommunityFollowerState"; export { CommunityFollowerView } from "./types/CommunityFollowerView"; export { CommunityId } from "./types/CommunityId"; export { CommunityModeratorView } from "./types/CommunityModeratorView"; @@ -102,6 +104,8 @@ export { GetComment } from "./types/GetComment"; export { GetComments } from "./types/GetComments"; export { GetCommentsResponse } from "./types/GetCommentsResponse"; export { GetCommunity } from "./types/GetCommunity"; +export { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount"; +export { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse"; export { GetCommunityResponse } from "./types/GetCommunityResponse"; export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse"; export { GetModlog } from "./types/GetModlog"; @@ -142,6 +146,8 @@ export { ListCommentReports } from "./types/ListCommentReports"; export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; export { ListCommunities } from "./types/ListCommunities"; export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; +export { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows"; +export { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse"; export { ListCustomEmojis } from "./types/ListCustomEmojis"; export { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; export { ListLoginsResponse } from "./types/ListLoginsResponse"; @@ -208,6 +214,7 @@ export { OpenGraphData } from "./types/OpenGraphData"; export { PaginationCursor } from "./types/PaginationCursor"; export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset"; export { PasswordReset } from "./types/PasswordReset"; +export { PendingFollow } from "./types/PendingFollow"; export { Person } from "./types/Person"; export { PersonAggregates } from "./types/PersonAggregates"; export { PersonId } from "./types/PersonId"; diff --git a/src/types/ApproveCommunityPendingFollower.ts b/src/types/ApproveCommunityPendingFollower.ts new file mode 100644 index 0000000..5cdae33 --- /dev/null +++ b/src/types/ApproveCommunityPendingFollower.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommunityId } from "./CommunityId"; +import type { PersonId } from "./PersonId"; + +export type ApproveCommunityPendingFollower = { + community_id: CommunityId; + follower_id: PersonId; + approve: boolean; +}; diff --git a/src/types/CommunityFollowerState.ts b/src/types/CommunityFollowerState.ts new file mode 100644 index 0000000..8461bf6 --- /dev/null +++ b/src/types/CommunityFollowerState.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type CommunityFollowerState = + | "Accepted" + | "Pending" + | "ApprovalRequired"; diff --git a/src/types/CommunityVisibility.ts b/src/types/CommunityVisibility.ts index b062ab0..0a6e6f5 100644 --- a/src/types/CommunityVisibility.ts +++ b/src/types/CommunityVisibility.ts @@ -2,7 +2,5 @@ /** * Defines who can browse and interact with content in a community. - * - * TODO: Also use this to define private communities */ -export type CommunityVisibility = "Public" | "LocalOnly"; +export type CommunityVisibility = "Public" | "LocalOnly" | "Private"; diff --git a/src/types/FederationError.ts b/src/types/FederationError.ts index c29b2f3..35a371e 100644 --- a/src/types/FederationError.ts +++ b/src/types/FederationError.ts @@ -24,4 +24,5 @@ export type FederationError = | "UrlWithoutDomain" | "InboxTimeout" | "CantDeleteSite" - | "ObjectIsNotPublic"; + | "ObjectIsNotPublic" + | "ObjectIsNotPrivate"; diff --git a/src/types/GetCommunityPendingFollowsCount.ts b/src/types/GetCommunityPendingFollowsCount.ts new file mode 100644 index 0000000..ab937b1 --- /dev/null +++ b/src/types/GetCommunityPendingFollowsCount.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommunityId } from "./CommunityId"; + +export type GetCommunityPendingFollowsCount = { community_id: CommunityId }; diff --git a/src/types/GetCommunityPendingFollowsCountResponse.ts b/src/types/GetCommunityPendingFollowsCountResponse.ts new file mode 100644 index 0000000..11b402d --- /dev/null +++ b/src/types/GetCommunityPendingFollowsCountResponse.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type GetCommunityPendingFollowsCountResponse = { count: number }; diff --git a/src/types/ListCommunityPendingFollows.ts b/src/types/ListCommunityPendingFollows.ts new file mode 100644 index 0000000..6974ddd --- /dev/null +++ b/src/types/ListCommunityPendingFollows.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type ListCommunityPendingFollows = { + /** + * Only shows the unapproved applications + */ + pending_only?: boolean; + all_communities?: boolean; + page?: number; + limit?: number; +}; diff --git a/src/types/ListCommunityPendingFollowsResponse.ts b/src/types/ListCommunityPendingFollowsResponse.ts new file mode 100644 index 0000000..2c6829f --- /dev/null +++ b/src/types/ListCommunityPendingFollowsResponse.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PendingFollow } from "./PendingFollow"; + +export type ListCommunityPendingFollowsResponse = { + items: Array; +}; diff --git a/src/types/PendingFollow.ts b/src/types/PendingFollow.ts new file mode 100644 index 0000000..d7e7149 --- /dev/null +++ b/src/types/PendingFollow.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Community } from "./Community"; +import type { Person } from "./Person"; +import type { SubscribedType } from "./SubscribedType"; + +export type PendingFollow = { + person: Person; + community: Community; + is_new_instance: boolean; + subscribed: SubscribedType; +}; diff --git a/src/types/SubscribedType.ts b/src/types/SubscribedType.ts index aa40dd8..85313b3 100644 --- a/src/types/SubscribedType.ts +++ b/src/types/SubscribedType.ts @@ -3,4 +3,8 @@ /** * A type / status for a community subscribe. */ -export type SubscribedType = "Subscribed" | "NotSubscribed" | "Pending"; +export type SubscribedType = + | "Subscribed" + | "NotSubscribed" + | "Pending" + | "ApprovalRequired";