Private community (#371)

* Private community

* 0.20.0-private-community.1

* add missing files

* 0.20.0-private-community.2

* update

* 0.20.0-private-community.3

* rename

* 0.20.0-private-community.4

* change

* 0.20.0-private-community.5

* add file

* 0.20.0-private-community.6

* update

* 0.20.0-private-community.7

* 0.20.0-private-community.8

* lint

* 0.20.0-private-community.9

* fix null

* Updating types from main.

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
This commit is contained in:
Nutomic 2024-11-07 18:19:30 +01:00 committed by GitHub
parent c1545659b2
commit 22fbe7eaeb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 105 additions and 6 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "lemmy-js-client", "name": "lemmy-js-client",
"description": "A javascript / typescript client for Lemmy", "description": "A javascript / typescript client for Lemmy",
"version": "0.20.0-alpha.17", "version": "0.20.0-private-community.9",
"author": "Dessalines <tyhou13@gmx.com>", "author": "Dessalines <tyhou13@gmx.com>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "./dist/index.js", "main": "./dist/index.js",

View file

@ -154,6 +154,12 @@ import { ListTaglinesResponse } from "./types/ListTaglinesResponse";
import { ListCustomEmojis } from "./types/ListCustomEmojis"; import { ListCustomEmojis } from "./types/ListCustomEmojis";
import { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; import { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse";
import { GetRandomCommunity } from "./types/GetRandomCommunity"; 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 { enum HttpType {
Get = "GET", 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<ApproveCommunityPendingFollower, SuccessResponse>(
HttpType.Post,
"/community/pending_follows/approve",
form,
options,
);
}
/** /**
* Block a community. * Block a community.
* *

View file

@ -18,6 +18,7 @@ export { AdminPurgePerson } from "./types/AdminPurgePerson";
export { AdminPurgePersonView } from "./types/AdminPurgePersonView"; export { AdminPurgePersonView } from "./types/AdminPurgePersonView";
export { AdminPurgePost } from "./types/AdminPurgePost"; export { AdminPurgePost } from "./types/AdminPurgePost";
export { AdminPurgePostView } from "./types/AdminPurgePostView"; export { AdminPurgePostView } from "./types/AdminPurgePostView";
export { ApproveCommunityPendingFollower } from "./types/ApproveCommunityPendingFollower";
export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication"; export { ApproveRegistrationApplication } from "./types/ApproveRegistrationApplication";
export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth"; export { AuthenticateWithOauth } from "./types/AuthenticateWithOauth";
export { BanFromCommunity } from "./types/BanFromCommunity"; export { BanFromCommunity } from "./types/BanFromCommunity";
@ -49,6 +50,7 @@ export { CommentSortType } from "./types/CommentSortType";
export { CommentView } from "./types/CommentView"; export { CommentView } from "./types/CommentView";
export { Community } from "./types/Community"; export { Community } from "./types/Community";
export { CommunityAggregates } from "./types/CommunityAggregates"; export { CommunityAggregates } from "./types/CommunityAggregates";
export { CommunityFollowerState } from "./types/CommunityFollowerState";
export { CommunityFollowerView } from "./types/CommunityFollowerView"; export { CommunityFollowerView } from "./types/CommunityFollowerView";
export { CommunityId } from "./types/CommunityId"; export { CommunityId } from "./types/CommunityId";
export { CommunityModeratorView } from "./types/CommunityModeratorView"; export { CommunityModeratorView } from "./types/CommunityModeratorView";
@ -102,6 +104,8 @@ export { GetComment } from "./types/GetComment";
export { GetComments } from "./types/GetComments"; export { GetComments } from "./types/GetComments";
export { GetCommentsResponse } from "./types/GetCommentsResponse"; export { GetCommentsResponse } from "./types/GetCommentsResponse";
export { GetCommunity } from "./types/GetCommunity"; export { GetCommunity } from "./types/GetCommunity";
export { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount";
export { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse";
export { GetCommunityResponse } from "./types/GetCommunityResponse"; export { GetCommunityResponse } from "./types/GetCommunityResponse";
export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse"; export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
export { GetModlog } from "./types/GetModlog"; export { GetModlog } from "./types/GetModlog";
@ -142,6 +146,8 @@ export { ListCommentReports } from "./types/ListCommentReports";
export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
export { ListCommunities } from "./types/ListCommunities"; export { ListCommunities } from "./types/ListCommunities";
export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse"; export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse";
export { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows";
export { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse";
export { ListCustomEmojis } from "./types/ListCustomEmojis"; export { ListCustomEmojis } from "./types/ListCustomEmojis";
export { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; export { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse";
export { ListLoginsResponse } from "./types/ListLoginsResponse"; export { ListLoginsResponse } from "./types/ListLoginsResponse";
@ -208,6 +214,7 @@ export { OpenGraphData } from "./types/OpenGraphData";
export { PaginationCursor } from "./types/PaginationCursor"; export { PaginationCursor } from "./types/PaginationCursor";
export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset"; export { PasswordChangeAfterReset } from "./types/PasswordChangeAfterReset";
export { PasswordReset } from "./types/PasswordReset"; export { PasswordReset } from "./types/PasswordReset";
export { PendingFollow } from "./types/PendingFollow";
export { Person } from "./types/Person"; export { Person } from "./types/Person";
export { PersonAggregates } from "./types/PersonAggregates"; export { PersonAggregates } from "./types/PersonAggregates";
export { PersonId } from "./types/PersonId"; export { PersonId } from "./types/PersonId";

View file

@ -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;
};

View file

@ -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";

View file

@ -2,7 +2,5 @@
/** /**
* Defines who can browse and interact with content in a community. * 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";

View file

@ -24,4 +24,5 @@ export type FederationError =
| "UrlWithoutDomain" | "UrlWithoutDomain"
| "InboxTimeout" | "InboxTimeout"
| "CantDeleteSite" | "CantDeleteSite"
| "ObjectIsNotPublic"; | "ObjectIsNotPublic"
| "ObjectIsNotPrivate";

View file

@ -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 };

View file

@ -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 };

View file

@ -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;
};

View file

@ -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<PendingFollow>;
};

View file

@ -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;
};

View file

@ -3,4 +3,8 @@
/** /**
* A type / status for a community subscribe. * A type / status for a community subscribe.
*/ */
export type SubscribedType = "Subscribed" | "NotSubscribed" | "Pending"; export type SubscribedType =
| "Subscribed"
| "NotSubscribed"
| "Pending"
| "ApprovalRequired";