From 8d0b25d8629203bc9731d937d451fd7c829823b2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 17 Aug 2022 19:29:58 -0400 Subject: [PATCH 1/5] Distinguish (#73) * Add distinguish * v0.17.0-rc.41 --- package.json | 2 +- src/interfaces/api/comment.ts | 12 +++++++++++- src/interfaces/source.ts | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 98a852d..2bb2508 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.17.0-rc.39", + "version": "0.17.0-rc.41", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/interfaces/api/comment.ts b/src/interfaces/api/comment.ts index 2c37220..423dd7d 100644 --- a/src/interfaces/api/comment.ts +++ b/src/interfaces/api/comment.ts @@ -27,8 +27,18 @@ export class CreateComment { } export class EditComment { - content: string; comment_id: number; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + content: Option; + /** + * "Distinguishes" a comment, or speak officially. Only doable by community mods or admins. + */ + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + distinguished: Option; /** * An optional front end ID, to tell which is comment is coming back. */ diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 44a5a06..49120bd 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -454,6 +454,7 @@ export class Comment { ap_id: string; local: boolean; path: string; + distinguished: boolean; } export class PersonMention { From c3be80f46cb7e683a9d463329491fd50adf2b2f7 Mon Sep 17 00:00:00 2001 From: Anon Date: Wed, 17 Aug 2022 18:30:14 -0500 Subject: [PATCH 2/5] Add Modlog Filters (#65) * Add types for Modlog Filters * Update for optionals --- src/interfaces/api/site.ts | 20 ++++++++--- src/interfaces/others.ts | 22 ++++++++++++ src/interfaces/source.ts | 4 +++ src/interfaces/views.ts | 70 ++++++++++++++++++++++++++++++-------- 4 files changed, 98 insertions(+), 18 deletions(-) diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index 63423a2..b3f3905 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -2,7 +2,7 @@ import { Option } from "@sniptt/monads"; import { Expose, Transform, Type } from "class-transformer"; import "reflect-metadata"; import { toOption, toUndefined } from "../../utils"; -import { ListingType, SearchType, SortType } from "../others"; +import { ListingType, SearchType, SortType, ModlogActionType } from "../others"; import { AdminPurgeCommentView, AdminPurgeCommunityView, @@ -96,6 +96,7 @@ export class SearchResponse { users: PersonViewSafe[]; } + export class GetModlog { @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @@ -117,7 +118,11 @@ export class GetModlog { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() auth: Option; - + type_: ModlogActionType; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + other_person_id: Option; constructor(init: GetModlog) { Object.assign(this, init); } @@ -212,8 +217,11 @@ export class CreateSite { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() default_post_listing_type: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + hide_modlog_mod_names: Option; auth: string; - constructor(init: CreateSite) { Object.assign(this, init); } @@ -284,8 +292,12 @@ export class EditSite { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() default_post_listing_type: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + hide_modlog_mod_names: Option; auth: string; - + constructor(init: EditSite) { Object.assign(this, init); } diff --git a/src/interfaces/others.ts b/src/interfaces/others.ts index 58d07f9..ee83480 100644 --- a/src/interfaces/others.ts +++ b/src/interfaces/others.ts @@ -182,6 +182,28 @@ export enum SearchType { Url = "Url", } +/** + * Mod log action types + */ +export enum ModlogActionType { + All = "All", + ModRemovePost = "ModRemovePost", + ModLockPost = "ModLockPost", + ModStickyPost = "ModStickyPost", + ModRemoveComment = "ModRemoveComment", + ModRemoveCommunity = "ModRemoveCommunity", + ModBanFromCommunity = "ModBanFromCommunity", + ModAddCommunity = "ModAddCommunity", + ModTransferCommunity = "ModTransferCommunity", + ModAdd = "ModAdd", + ModBan = "ModBan", + ModHideCommunity = "ModHideCommunity", + AdminPurgePerson = "AdminPurgePerson", + AdminPurgeCommunity = "AdminPurgeCommunity", + AdminPurgePost = "AdminPurgePost", + AdminPurgeComment = "AdminPurgeComment", +} + /** * Different Subscribed states */ diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 49120bd..2756fa0 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -111,6 +111,10 @@ export class Site { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() legal_information: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + hide_modlog_mod_names: Option; } export class PrivateMessage { diff --git a/src/interfaces/views.ts b/src/interfaces/views.ts index 159f220..1b03c54 100644 --- a/src/interfaces/views.ts +++ b/src/interfaces/views.ts @@ -208,8 +208,11 @@ export class CommentReportView { export class ModAddCommunityView { @Type(() => ModAddCommunity) mod_add_community: ModAddCommunity; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => CommunitySafe) community: CommunitySafe; @Type(() => PersonSafe) @@ -219,8 +222,11 @@ export class ModAddCommunityView { export class ModTransferCommunityView { @Type(() => ModTransferCommunity) mod_transfer_community: ModTransferCommunity; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => CommunitySafe) community: CommunitySafe; @Type(() => PersonSafe) @@ -230,8 +236,11 @@ export class ModTransferCommunityView { export class ModAddView { @Type(() => ModAdd) mod_add: ModAdd; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => PersonSafe) modded_person: PersonSafe; } @@ -239,8 +248,11 @@ export class ModAddView { export class ModBanFromCommunityView { @Type(() => ModBanFromCommunity) mod_ban_from_community: ModBanFromCommunity; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => CommunitySafe) community: CommunitySafe; @Type(() => PersonSafe) @@ -250,8 +262,11 @@ export class ModBanFromCommunityView { export class ModBanView { @Type(() => ModBan) mod_ban: ModBan; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => PersonSafe) banned_person: PersonSafe; } @@ -259,8 +274,11 @@ export class ModBanView { export class ModLockPostView { @Type(() => ModLockPost) mod_lock_post: ModLockPost; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => Post) post: Post; @Type(() => CommunitySafe) @@ -270,8 +288,11 @@ export class ModLockPostView { export class ModRemoveCommentView { @Type(() => ModRemoveComment) mod_remove_comment: ModRemoveComment; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => Comment) comment: Comment; @Type(() => PersonSafe) @@ -285,8 +306,11 @@ export class ModRemoveCommentView { export class ModRemoveCommunityView { @Type(() => ModRemoveCommunity) mod_remove_community: ModRemoveCommunity; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => CommunitySafe) community: CommunitySafe; } @@ -294,8 +318,11 @@ export class ModRemoveCommunityView { export class ModRemovePostView { @Type(() => ModRemovePost) mod_remove_post: ModRemovePost; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => Post) post: Post; @Type(() => CommunitySafe) @@ -305,8 +332,11 @@ export class ModRemovePostView { export class ModStickyPostView { @Type(() => ModStickyPost) mod_sticky_post: ModStickyPost; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - moderator: PersonSafe; + moderator: Option; @Type(() => Post) post: Post; @Type(() => CommunitySafe) @@ -316,22 +346,31 @@ export class ModStickyPostView { export class AdminPurgeCommunityView { @Type(() => AdminPurgeCommunity) admin_purge_community: AdminPurgeCommunity; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - admin: PersonSafe; + admin: Option; } export class AdminPurgePersonView { @Type(() => AdminPurgePerson) admin_purge_person: AdminPurgePerson; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - admin: PersonSafe; + admin: Option; } export class AdminPurgePostView { @Type(() => AdminPurgePost) admin_purge_post: AdminPurgePost; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - admin: PersonSafe; + admin: Option; @Type(() => CommunitySafe) community: CommunitySafe; } @@ -339,8 +378,11 @@ export class AdminPurgePostView { export class AdminPurgeCommentView { @Type(() => AdminPurgeComment) admin_purge_comment: AdminPurgeComment; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() @Type(() => PersonSafe) - admin: PersonSafe; + admin: Option; @Type(() => Post) post: Post; } From e266c65a7f3f26a3347ec3b034533b6e7e575f8d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 17 Aug 2022 19:30:44 -0400 Subject: [PATCH 3/5] v0.17.0-rc.43 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2bb2508..3a2c4c7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.17.0-rc.41", + "version": "0.17.0-rc.43", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", From ca66e1b8bab086124b2afc8da39804530e2a96d3 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Tue, 13 Sep 2022 21:23:11 +0000 Subject: [PATCH 4/5] Rename post.embed_html field to embed_video_url (#75) https://github.com/LemmyNet/lemmy/pull/2261 --- src/interfaces/source.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 2756fa0..789c853 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -193,7 +193,7 @@ export class Post { @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() - embed_html: Option; + embed_video_url: Option; @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() From c3b76c88b0241edeeb7f64852009c179c5f919ae Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 22 Sep 2022 12:52:44 -0400 Subject: [PATCH 5/5] Add language (#77) * Add language_id for user, post, and comment creation. * v0.17.0-rc.44 --- package.json | 2 +- src/interfaces/api/comment.ts | 8 ++++++++ src/interfaces/api/person.ts | 6 +++++- src/interfaces/api/post.ts | 8 ++++++++ src/interfaces/api/site.ts | 10 +++++++--- src/interfaces/source.ts | 10 +++++++++- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 3a2c4c7..e191eb0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.17.0-rc.43", + "version": "0.17.0-rc.44", "author": "Dessalines ", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/interfaces/api/comment.ts b/src/interfaces/api/comment.ts index 423dd7d..5f2f78c 100644 --- a/src/interfaces/api/comment.ts +++ b/src/interfaces/api/comment.ts @@ -11,6 +11,10 @@ export class CreateComment { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() parent_id: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + language_id: Option; post_id: number; /** * An optional front end ID, to tell which is comment is coming back. @@ -39,6 +43,10 @@ export class EditComment { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() distinguished: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + language_id: Option; /** * An optional front end ID, to tell which is comment is coming back. */ diff --git a/src/interfaces/api/person.ts b/src/interfaces/api/person.ts index 147d62d..7d2b2e4 100644 --- a/src/interfaces/api/person.ts +++ b/src/interfaces/api/person.ts @@ -136,7 +136,7 @@ export class SaveUserSettings { @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() - lang: Option; + interface_language: Option; @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() @@ -189,6 +189,10 @@ export class SaveUserSettings { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() show_new_post_notifs: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + discussion_languages: Option; auth: string; constructor(init: SaveUserSettings) { diff --git a/src/interfaces/api/post.ts b/src/interfaces/api/post.ts index 48abf55..fbbf2bb 100644 --- a/src/interfaces/api/post.ts +++ b/src/interfaces/api/post.ts @@ -24,6 +24,10 @@ export class CreatePost { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() nsfw: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + language_id: Option; community_id: number; @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @@ -149,6 +153,10 @@ export class EditPost { @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Expose() nsfw: Option; + @Transform(({ value }) => toOption(value), { toClassOnly: true }) + @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) + @Expose() + language_id: Option; auth: string; constructor(init: EditPost) { diff --git a/src/interfaces/api/site.ts b/src/interfaces/api/site.ts index b3f3905..0108cc2 100644 --- a/src/interfaces/api/site.ts +++ b/src/interfaces/api/site.ts @@ -2,7 +2,8 @@ import { Option } from "@sniptt/monads"; import { Expose, Transform, Type } from "class-transformer"; import "reflect-metadata"; import { toOption, toUndefined } from "../../utils"; -import { ListingType, SearchType, SortType, ModlogActionType } from "../others"; +import { ListingType, ModlogActionType, SearchType, SortType } from "../others"; +import { Language } from "../source"; import { AdminPurgeCommentView, AdminPurgeCommunityView, @@ -96,7 +97,6 @@ export class SearchResponse { users: PersonViewSafe[]; } - export class GetModlog { @Transform(({ value }) => toOption(value), { toClassOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @@ -297,7 +297,7 @@ export class EditSite { @Expose() hide_modlog_mod_names: Option; auth: string; - + constructor(init: EditSite) { Object.assign(this, init); } @@ -345,6 +345,8 @@ export class GetSiteResponse { @Expose() @Type(() => FederatedInstances) federated_instances: Option; + @Type(() => Language) + all_languages: Language[]; } /** @@ -361,6 +363,8 @@ export class MyUserInfo { community_blocks: CommunityBlockView[]; @Type(() => PersonBlockView) person_blocks: PersonBlockView[]; + @Type(() => Language) + discussion_languages: Language[]; } export class LeaveAdmin { diff --git a/src/interfaces/source.ts b/src/interfaces/source.ts index 789c853..42aaaa6 100644 --- a/src/interfaces/source.ts +++ b/src/interfaces/source.ts @@ -13,7 +13,7 @@ export class LocalUserSettings { theme: string; default_sort_type: number; default_listing_type: number; - lang: string; + interface_language: string; show_avatars: boolean; send_notifications_to_email: boolean; show_bot_accounts: boolean; @@ -200,6 +200,7 @@ export class Post { thumbnail_url: Option; ap_id: string; local: boolean; + language_id: number; } export class PasswordResetRequest { @@ -459,6 +460,7 @@ export class Comment { local: boolean; path: string; distinguished: boolean; + language_id: number; } export class PersonMention { @@ -491,3 +493,9 @@ export class RegistrationApplication { deny_reason: Option; published: string; } + +export class Language { + id: number; + code: string; + name: string; +}