From 482e4c65d06d6a2dd5666322bcd7cb5488652cce Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 2 Oct 2024 12:53:36 -0400 Subject: [PATCH] Adding get random community, updating types from main. (#366) --- src/http.ts | 14 ++++++++++++++ src/index.ts | 2 ++ src/types/CreateSite.ts | 6 +++++- src/types/EditSite.ts | 8 ++++++-- src/types/FederationMode.ts | 3 +++ src/types/GetRandomCommunity.ts | 6 ++++++ src/types/GetSiteResponse.ts | 2 ++ src/types/LemmyErrorType.ts | 2 +- src/types/LocalSite.ts | 6 +++++- src/types/SiteResponse.ts | 1 + 10 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 src/types/FederationMode.ts create mode 100644 src/types/GetRandomCommunity.ts diff --git a/src/http.ts b/src/http.ts index fbc4ef5..d76e2f0 100644 --- a/src/http.ts +++ b/src/http.ts @@ -153,6 +153,7 @@ import { ListTaglines } from "./types/ListTaglines"; import { ListTaglinesResponse } from "./types/ListTaglinesResponse"; import { ListCustomEmojis } from "./types/ListCustomEmojis"; import { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse"; +import { GetRandomCommunity } from "./types/GetRandomCommunity"; enum HttpType { Get = "GET", @@ -538,6 +539,19 @@ export class LemmyHttp { ); } + /** + * Get a random community. + * + * `HTTP.GET /community/random` + */ + getRandomCommunity(form: GetRandomCommunity) { + return this.#wrapper( + HttpType.Get, + "/community/random", + form, + ); + } + /** * Create a post. * diff --git a/src/index.ts b/src/index.ts index f3d0b1b..dc0fbb1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -91,6 +91,7 @@ export { EditPrivateMessage } from "./types/EditPrivateMessage"; export { EditSite } from "./types/EditSite"; export { FeaturePost } from "./types/FeaturePost"; export { FederatedInstances } from "./types/FederatedInstances"; +export { FederationMode } from "./types/FederationMode"; export { FollowCommunity } from "./types/FollowCommunity"; export { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse"; export { GetCaptchaResponse } from "./types/GetCaptchaResponse"; @@ -111,6 +112,7 @@ export { GetPostResponse } from "./types/GetPostResponse"; export { GetPosts } from "./types/GetPosts"; export { GetPostsResponse } from "./types/GetPostsResponse"; export { GetPrivateMessages } from "./types/GetPrivateMessages"; +export { GetRandomCommunity } from "./types/GetRandomCommunity"; export { GetRegistrationApplication } from "./types/GetRegistrationApplication"; export { GetReplies } from "./types/GetReplies"; export { GetRepliesResponse } from "./types/GetRepliesResponse"; diff --git a/src/types/CreateSite.ts b/src/types/CreateSite.ts index d0f376d..8aa6069 100644 --- a/src/types/CreateSite.ts +++ b/src/types/CreateSite.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CommentSortType } from "./CommentSortType"; +import type { FederationMode } from "./FederationMode"; import type { LanguageId } from "./LanguageId"; import type { ListingType } from "./ListingType"; import type { PostListingMode } from "./PostListingMode"; @@ -12,7 +13,6 @@ export interface CreateSite { description?: string; icon?: string; banner?: string; - enable_downvotes?: boolean; enable_nsfw?: boolean; community_creation_admin_only?: boolean; require_email_verification?: boolean; @@ -50,4 +50,8 @@ export interface CreateSite { registration_mode?: RegistrationMode; oauth_registration?: boolean; content_warning?: string; + post_upvotes?: FederationMode; + post_downvotes?: FederationMode; + comment_upvotes?: FederationMode; + comment_downvotes?: FederationMode; } diff --git a/src/types/EditSite.ts b/src/types/EditSite.ts index ee613ef..e66d512 100644 --- a/src/types/EditSite.ts +++ b/src/types/EditSite.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CommentSortType } from "./CommentSortType"; +import type { FederationMode } from "./FederationMode"; import type { LanguageId } from "./LanguageId"; import type { ListingType } from "./ListingType"; import type { PostListingMode } from "./PostListingMode"; @@ -12,7 +13,6 @@ export interface EditSite { description?: string; icon?: string; banner?: string; - enable_downvotes?: boolean; enable_nsfw?: boolean; community_creation_admin_only?: boolean; require_email_verification?: boolean; @@ -49,7 +49,11 @@ export interface EditSite { blocked_instances?: Array; blocked_urls?: Array; registration_mode?: RegistrationMode; - oauth_registration?: boolean; reports_email_admins?: boolean; content_warning?: string; + oauth_registration?: boolean; + post_upvotes?: FederationMode; + post_downvotes?: FederationMode; + comment_upvotes?: FederationMode; + comment_downvotes?: FederationMode; } diff --git a/src/types/FederationMode.ts b/src/types/FederationMode.ts new file mode 100644 index 0000000..2e9376d --- /dev/null +++ b/src/types/FederationMode.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 FederationMode = "All" | "Local" | "Disable"; diff --git a/src/types/GetRandomCommunity.ts b/src/types/GetRandomCommunity.ts new file mode 100644 index 0000000..7c6189e --- /dev/null +++ b/src/types/GetRandomCommunity.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 { ListingType } from "./ListingType"; + +export interface GetRandomCommunity { + type_?: ListingType; +} diff --git a/src/types/GetSiteResponse.ts b/src/types/GetSiteResponse.ts index df68546..7c8b077 100644 --- a/src/types/GetSiteResponse.ts +++ b/src/types/GetSiteResponse.ts @@ -16,6 +16,8 @@ export interface GetSiteResponse { my_user?: MyUserInfo; all_languages: Array; discussion_languages: Array; + taglines: Array; + custom_emojis: Array; tagline?: Tagline; oauth_providers?: Array; admin_oauth_providers?: Array; diff --git a/src/types/LemmyErrorType.ts b/src/types/LemmyErrorType.ts index 6be9272..02c5792 100644 --- a/src/types/LemmyErrorType.ts +++ b/src/types/LemmyErrorType.ts @@ -37,7 +37,7 @@ export type LemmyErrorType = | { error: "person_is_blocked" } | { error: "community_is_blocked" } | { error: "instance_is_blocked" } - | { error: "downvotes_are_disabled" } + | { error: "vote_not_allowed" } | { error: "instance_is_private" } | { error: "invalid_password" } | { error: "site_description_length_overflow" } diff --git a/src/types/LocalSite.ts b/src/types/LocalSite.ts index 1b5bac0..285f411 100644 --- a/src/types/LocalSite.ts +++ b/src/types/LocalSite.ts @@ -1,5 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { CommentSortType } from "./CommentSortType"; +import type { FederationMode } from "./FederationMode"; import type { ListingType } from "./ListingType"; import type { LocalSiteId } from "./LocalSiteId"; import type { PostListingMode } from "./PostListingMode"; @@ -11,7 +12,6 @@ export interface LocalSite { id: LocalSiteId; site_id: SiteId; site_setup: boolean; - enable_downvotes: boolean; community_creation_admin_only: boolean; require_email_verification: boolean; application_question?: string; @@ -35,4 +35,8 @@ export interface LocalSite { default_post_sort_type: PostSortType; default_comment_sort_type: CommentSortType; oauth_registration: boolean; + post_upvotes: FederationMode; + post_downvotes: FederationMode; + comment_upvotes: FederationMode; + comment_downvotes: FederationMode; } diff --git a/src/types/SiteResponse.ts b/src/types/SiteResponse.ts index 91b7bc9..e2320be 100644 --- a/src/types/SiteResponse.ts +++ b/src/types/SiteResponse.ts @@ -3,4 +3,5 @@ import type { SiteView } from "./SiteView"; export interface SiteResponse { site_view: SiteView; + taglines: Array; }