Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add post tags functions #483

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion copy_generated_types_from_lemmy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ find src/types -type f -name '*.ts' -exec sed -i 's/bigint/number/g' {} +

node putTypesInIndex.js

prettier -w src
pnpm prettier -w src

98 changes: 98 additions & 0 deletions src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { CreateComment } from "./types/CreateComment";
import { CreateCommentLike } from "./types/CreateCommentLike";
import { CreateCommentReport } from "./types/CreateCommentReport";
import { CreateCommunity } from "./types/CreateCommunity";
import { CreateCommunityTag } from "./types/CreateCommunityTag";
import { CreateCustomEmoji } from "./types/CreateCustomEmoji";
import { CreateOAuthProvider } from "./types/CreateOAuthProvider";
import { CreatePost } from "./types/CreatePost";
Expand All @@ -33,6 +34,7 @@ import { CustomEmojiResponse } from "./types/CustomEmojiResponse";
import { DeleteAccount } from "./types/DeleteAccount";
import { DeleteComment } from "./types/DeleteComment";
import { DeleteCommunity } from "./types/DeleteCommunity";
import { DeleteCommunityTag } from "./types/DeleteCommunityTag";
import { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
import { DeleteOAuthProvider } from "./types/DeleteOAuthProvider";
import { DeletePost } from "./types/DeletePost";
Expand Down Expand Up @@ -72,6 +74,8 @@ import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
import { ListCommunities } from "./types/ListCommunities";
import { ListCommunitiesResponse } from "./types/ListCommunitiesResponse";
import { ListCommunityTags } from "./types/ListCommunityTags";
import { ListCommunityTagsResponse } from "./types/ListCommunityTagsResponse";
import { ListRegistrationApplications } from "./types/ListRegistrationApplications";
import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationApplicationsResponse";
import { LockPost } from "./types/LockPost";
Expand Down Expand Up @@ -107,6 +111,8 @@ import { Search } from "./types/Search";
import { SearchResponse } from "./types/SearchResponse";
import { SiteResponse } from "./types/SiteResponse";
import { TransferCommunity } from "./types/TransferCommunity";
import { UpdateCommunityTag } from "./types/UpdateCommunityTag";
import { UpdatePostTags } from "./types/UpdatePostTags";
import { VerifyEmail } from "./types/VerifyEmail";
import {
DeleteImageParamsI,
Expand Down Expand Up @@ -199,6 +205,7 @@ import {
Security,
Tags,
} from "tsoa";
import { CommunityTagResponse } from "./types/CommunityTagResponse";

enum HttpType {
Get = "GET",
Expand Down Expand Up @@ -2068,6 +2075,97 @@ export class LemmyHttp extends Controller {
);
}

/**
* @summary Create a community tag.
*/
@Security("bearerAuth")
@Post("/community/post_tag")
@Tags("Community")
createCommunityTag(
@Body() form: CreateCommunityTag,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<CreateCommunityTag, CommunityTagResponse>(
HttpType.Post,
"/community/post_tag",
form,
options,
);
}

/**
* @summary Update a community tag.
*/
@Security("bearerAuth")
@Put("/community/post_tag")
@Tags("Community")
updateCommunityTag(
@Body() form: UpdateCommunityTag,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<UpdateCommunityTag, CommunityTagResponse>(
HttpType.Put,
"/community/post_tag",
form,
options,
);
}

/**
* @summary List community tags.
*/
@Security("bearerAuth")
@Security({})
@Get("/community/post_tag/list")
@Tags("Community")
listCommunityTags(
@Queries() form: ListCommunityTags,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<ListCommunityTags, ListCommunityTagsResponse>(
HttpType.Get,
"/community/post_tag/list",
form,
options,
);
}

/**
* @summary Delete a community tag.
*/
@Security("bearerAuth")
@Post("/community/post_tag")
@Tags("Community")
deleteCommunityTag(
@Body() form: DeleteCommunityTag,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<DeleteCommunityTag, CommunityTagResponse>(
HttpType.Delete,
"/community/post_tag",
form,
options,
);
}

/**
* @summary Update post tags.
*/
@Security("bearerAuth")
@Put("/post/tags")
@Tags("Post")
updatePostTags(
@Body() form: UpdatePostTags,
@Inject() options?: RequestOptions,
) {
return this.#wrapper<UpdatePostTags, PostResponse>(
HttpType.Put,
"/post/tags",
form,
options,
);
}

/**
* @summary Create a new oauth provider method
*/
Expand Down
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ export { CommunityReportId } from "./types/CommunityReportId";
export { CommunityReportView } from "./types/CommunityReportView";
export { CommunityResponse } from "./types/CommunityResponse";
export { CommunitySortType } from "./types/CommunitySortType";
export { CommunityTagResponse } from "./types/CommunityTagResponse";
export { CommunityView } from "./types/CommunityView";
export { CommunityVisibility } from "./types/CommunityVisibility";
export { CreateComment } from "./types/CreateComment";
export { CreateCommentLike } from "./types/CreateCommentLike";
export { CreateCommentReport } from "./types/CreateCommentReport";
export { CreateCommunity } from "./types/CreateCommunity";
export { CreateCommunityTag } from "./types/CreateCommunityTag";
export { CreateCustomEmoji } from "./types/CreateCustomEmoji";
export { CreateOAuthProvider } from "./types/CreateOAuthProvider";
export { CreatePost } from "./types/CreatePost";
Expand All @@ -88,6 +90,7 @@ export { DbUrl } from "./types/DbUrl";
export { DeleteAccount } from "./types/DeleteAccount";
export { DeleteComment } from "./types/DeleteComment";
export { DeleteCommunity } from "./types/DeleteCommunity";
export { DeleteCommunityTag } from "./types/DeleteCommunityTag";
export { DeleteCustomEmoji } from "./types/DeleteCustomEmoji";
export { DeleteImageParams } from "./types/DeleteImageParams";
export { DeleteOAuthProvider } from "./types/DeleteOAuthProvider";
Expand Down Expand Up @@ -157,6 +160,8 @@ export { ListCommunities } from "./types/ListCommunities";
export { ListCommunitiesResponse } from "./types/ListCommunitiesResponse";
export { ListCommunityPendingFollows } from "./types/ListCommunityPendingFollows";
export { ListCommunityPendingFollowsResponse } from "./types/ListCommunityPendingFollowsResponse";
export { ListCommunityTags } from "./types/ListCommunityTags";
export { ListCommunityTagsResponse } from "./types/ListCommunityTagsResponse";
export { ListCustomEmojis } from "./types/ListCustomEmojis";
export { ListCustomEmojisResponse } from "./types/ListCustomEmojisResponse";
export { ListInbox } from "./types/ListInbox";
Expand Down Expand Up @@ -323,6 +328,8 @@ export { Tagline } from "./types/Tagline";
export { TaglineId } from "./types/TaglineId";
export { TaglineResponse } from "./types/TaglineResponse";
export { TransferCommunity } from "./types/TransferCommunity";
export { UpdateCommunityTag } from "./types/UpdateCommunityTag";
export { UpdatePostTags } from "./types/UpdatePostTags";
export { UpdateTagline } from "./types/UpdateTagline";
export { UpdateTotp } from "./types/UpdateTotp";
export { UpdateTotpResponse } from "./types/UpdateTotpResponse";
Expand Down
9 changes: 9 additions & 0 deletions src/types/CommunityTagResponse.ts
Original file line number Diff line number Diff line change
@@ -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 { TagId } from "./TagId";

export type CommunityTagResponse = {
id: TagId;
name: string;
community_id: CommunityId;
};
11 changes: 11 additions & 0 deletions src/types/CreateCommunityTag.ts
Original file line number Diff line number Diff line change
@@ -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 { CommunityId } from "./CommunityId";

/**
* Create a tag for a community.
*/
export type CreateCommunityTag = {
community_id: CommunityId;
id_slug: string;
name: string;
};
7 changes: 7 additions & 0 deletions src/types/DeleteCommunityTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { TagId } from "./TagId";

/**
* Delete a community tag.
*/
export type DeleteCommunityTag = { tag_id: TagId };
2 changes: 0 additions & 2 deletions src/types/EditPost.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { LanguageId } from "./LanguageId";
import type { PostId } from "./PostId";
import type { TagId } from "./TagId";

/**
* Edit a post.
Expand All @@ -24,7 +23,6 @@ export type EditPost = {
* Instead of fetching a thumbnail, use a custom one.
*/
custom_thumbnail?: string;
tags?: Array<TagId>;
/**
* Time when this post should be scheduled. Null means publish immediately.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/types/ListCommunityTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// 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";

/**
* List tags for a community.
*/
export type ListCommunityTags = { community_id: CommunityId };
4 changes: 4 additions & 0 deletions src/types/ListCommunityTagsResponse.ts
Original file line number Diff line number Diff line change
@@ -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 { CommunityTagResponse } from "./CommunityTagResponse";

export type ListCommunityTagsResponse = { tags: Array<CommunityTagResponse> };
2 changes: 1 addition & 1 deletion src/types/PostTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import type { Tag } from "./Tag";
/**
* we wrap this in a struct so we can implement FromSqlRow<Json> for it
*/
export type PostTags = { tags: Array<Tag> };
export type PostTags = Array<Tag>;
7 changes: 7 additions & 0 deletions src/types/UpdateCommunityTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { TagId } from "./TagId";

/**
* Update a community tag.
*/
export type UpdateCommunityTag = { tag_id: TagId; name: string };
8 changes: 8 additions & 0 deletions src/types/UpdatePostTags.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { PostId } from "./PostId";
import type { TagId } from "./TagId";

/**
* Update tags for a post.
*/
export type UpdatePostTags = { post_id: PostId; tags: Array<TagId> };
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"noImplicitAny": true,
"lib": ["es2017", "es7", "es6", "dom"],
"outDir": "./dist",
"target": "ES2015",
"target": "ES2020",
"experimentalDecorators": true,
"strictNullChecks": true,
"moduleResolution": "Node",
Expand Down