mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 04:11:11 +00:00
Merge branch 'makotech222-custom-emojis'
This commit is contained in:
commit
07b05025b0
8 changed files with 142 additions and 1 deletions
32
src/http.ts
32
src/http.ts
|
@ -36,6 +36,11 @@ import {
|
|||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
CreateCustomEmoji,
|
||||
DeleteCustomEmoji,
|
||||
EditCustomEmoji,
|
||||
} from "./interfaces/api/custom_emoji";
|
||||
import {
|
||||
AddAdmin,
|
||||
AddAdminResponse,
|
||||
|
@ -1158,6 +1163,33 @@ export class LemmyHttp {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new custom emoji
|
||||
*
|
||||
* `HTTP.POST /custom_emoji`
|
||||
*/
|
||||
async createCustomEmoji(form: CreateCustomEmoji) {
|
||||
return this.wrapper(HttpType.Post, "/custom_emoji", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing custom emoji
|
||||
*
|
||||
* `HTTP.PUT /custom_emoji`
|
||||
*/
|
||||
async editCustomEmoji(form: EditCustomEmoji) {
|
||||
return this.wrapper(HttpType.Put, "/custom_emoji", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom emoji
|
||||
*
|
||||
* `HTTP.Post /custom_emoji/delete`
|
||||
*/
|
||||
async deleteCustomEmoji(form: DeleteCustomEmoji) {
|
||||
return this.wrapper(HttpType.Post, "/custom_emoji/delete", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload an image to the server.
|
||||
*/
|
||||
|
|
53
src/interfaces/api/custom_emoji.ts
Normal file
53
src/interfaces/api/custom_emoji.ts
Normal file
|
@ -0,0 +1,53 @@
|
|||
import { CustomEmojiView } from "../views";
|
||||
|
||||
export class CreateCustomEmoji {
|
||||
category: string;
|
||||
shortcode: string;
|
||||
image_url: string;
|
||||
alt_text: string;
|
||||
keywords: string[];
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreateCustomEmoji) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class EditCustomEmoji {
|
||||
id: number;
|
||||
category: string;
|
||||
image_url: string;
|
||||
alt_text: string;
|
||||
keywords: string[];
|
||||
auth: string;
|
||||
|
||||
constructor(init: EditCustomEmoji) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class DeleteCustomEmoji {
|
||||
id: number;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeleteCustomEmoji) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class DeleteCustomEmojiResponse {
|
||||
id: number;
|
||||
success: boolean;
|
||||
|
||||
constructor(init: DeleteCustomEmojiResponse) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export class CustomEmojiResponse {
|
||||
custom_emoji: CustomEmojiView;
|
||||
|
||||
constructor(init: CustomEmojiResponse) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
export * from "./comment";
|
||||
export * from "./community";
|
||||
export * from "./custom_emoji";
|
||||
export * from "./person";
|
||||
export * from "./post";
|
||||
export * from "./site";
|
||||
|
|
|
@ -10,6 +10,7 @@ import {
|
|||
CommunityFollowerView,
|
||||
CommunityModeratorView,
|
||||
CommunityView,
|
||||
CustomEmojiView,
|
||||
LocalUserSettingsView,
|
||||
ModAddCommunityView,
|
||||
ModAddView,
|
||||
|
@ -195,7 +196,8 @@ export interface GetSiteResponse {
|
|||
federated_instances?: FederatedInstances;
|
||||
all_languages: Language[];
|
||||
discussion_languages: number[];
|
||||
taglines?: Tagline[];
|
||||
taglines: Tagline[];
|
||||
custom_emojis: CustomEmojiView[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,6 +86,9 @@ export enum UserOperation {
|
|||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
VerifyEmail,
|
||||
CreateCustomEmoji,
|
||||
EditCustomEmoji,
|
||||
DeleteCustomEmoji,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -391,3 +391,20 @@ export interface Tagline {
|
|||
published: string;
|
||||
updated?: string;
|
||||
}
|
||||
|
||||
export class CustomEmoji {
|
||||
id: number;
|
||||
local_site_id: number;
|
||||
shortcode: string;
|
||||
image_url: string;
|
||||
alt_text: string;
|
||||
category: string;
|
||||
published: string;
|
||||
updated: string;
|
||||
}
|
||||
|
||||
export class CustomEmojiKeyword {
|
||||
id: number;
|
||||
custom_emoji_id: number;
|
||||
keyword: string;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import {
|
|||
CommentReply,
|
||||
CommentReport,
|
||||
CommunitySafe,
|
||||
CustomEmoji,
|
||||
CustomEmojiKeyword,
|
||||
LocalSite,
|
||||
LocalSiteRateLimit,
|
||||
LocalUserSettings,
|
||||
|
@ -289,3 +291,8 @@ export interface PrivateMessageReportView {
|
|||
creator: PersonSafe;
|
||||
resolver?: PersonSafe;
|
||||
}
|
||||
|
||||
export class CustomEmojiView {
|
||||
custom_emoji: CustomEmoji;
|
||||
keywords: CustomEmojiKeyword[];
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@ import {
|
|||
RemoveCommunity,
|
||||
TransferCommunity,
|
||||
} from "./interfaces/api/community";
|
||||
import {
|
||||
CreateCustomEmoji,
|
||||
DeleteCustomEmoji,
|
||||
EditCustomEmoji,
|
||||
} from "./interfaces/api/custom_emoji";
|
||||
import {
|
||||
AddAdmin,
|
||||
BanPerson,
|
||||
|
@ -682,6 +687,27 @@ export class LemmyWebsocket {
|
|||
purgeComment(form: PurgeComment) {
|
||||
return wrapper(UserOperation.PurgeComment, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a custom emoji
|
||||
*/
|
||||
createCustomEmoji(form: CreateCustomEmoji) {
|
||||
return wrapper(UserOperation.CreateCustomEmoji, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a custom emoji
|
||||
*/
|
||||
editCustomEmoji(form: EditCustomEmoji) {
|
||||
return wrapper(UserOperation.EditCustomEmoji, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom emoji
|
||||
*/
|
||||
deleteCustomEmoji(form: DeleteCustomEmoji) {
|
||||
return wrapper(UserOperation.DeleteCustomEmoji, form);
|
||||
}
|
||||
}
|
||||
|
||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||
|
|
Loading…
Reference in a new issue