mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 12:21:12 +00:00
Add custom emojis
This commit is contained in:
parent
2477b17a45
commit
50285bd049
8 changed files with 164 additions and 0 deletions
49
src/http.ts
49
src/http.ts
|
@ -34,6 +34,13 @@ import {
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
} from "./interfaces/api/community";
|
} from "./interfaces/api/community";
|
||||||
|
import {
|
||||||
|
CreateCustomEmoji,
|
||||||
|
CustomEmojiResponse,
|
||||||
|
DeleteCustomEmoji,
|
||||||
|
DeleteCustomEmojiResponse,
|
||||||
|
EditCustomEmoji,
|
||||||
|
} from "./interfaces/api/custom_emoji";
|
||||||
import {
|
import {
|
||||||
AddAdmin,
|
AddAdmin,
|
||||||
AddAdminResponse,
|
AddAdminResponse,
|
||||||
|
@ -1154,6 +1161,48 @@ export class LemmyHttp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new custom emoji
|
||||||
|
*
|
||||||
|
* `HTTP.POST /custom_emoji`
|
||||||
|
*/
|
||||||
|
async createCustomEmoji(form: CreateCustomEmoji) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/custom_emoji",
|
||||||
|
form,
|
||||||
|
CustomEmojiResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit an existing custom emoji
|
||||||
|
*
|
||||||
|
* `HTTP.PUT /custom_emoji`
|
||||||
|
*/
|
||||||
|
async editCustomEmoji(form: EditCustomEmoji) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Put,
|
||||||
|
"/custom_emoji",
|
||||||
|
form,
|
||||||
|
CustomEmojiResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a custom emoji
|
||||||
|
*
|
||||||
|
* `HTTP.Post /custom_emoji/delete`
|
||||||
|
*/
|
||||||
|
async deleteCustomEmoji(form: DeleteCustomEmoji) {
|
||||||
|
return this.wrapper(
|
||||||
|
HttpType.Post,
|
||||||
|
"/custom_emoji/delete",
|
||||||
|
form,
|
||||||
|
DeleteCustomEmojiResponse
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private buildFullUrl(endpoint: string): string {
|
private buildFullUrl(endpoint: string): string {
|
||||||
return `${this.apiUrl}${endpoint}`;
|
return `${this.apiUrl}${endpoint}`;
|
||||||
}
|
}
|
||||||
|
|
54
src/interfaces/api/custom_emoji.ts
Normal file
54
src/interfaces/api/custom_emoji.ts
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
import "reflect-metadata";
|
||||||
|
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 "./comment";
|
||||||
export * from "./community";
|
export * from "./community";
|
||||||
|
export * from "./custom_emoji";
|
||||||
export * from "./person";
|
export * from "./person";
|
||||||
export * from "./post";
|
export * from "./post";
|
||||||
export * from "./site";
|
export * from "./site";
|
||||||
|
|
|
@ -10,6 +10,7 @@ import {
|
||||||
CommunityFollowerView,
|
CommunityFollowerView,
|
||||||
CommunityModeratorView,
|
CommunityModeratorView,
|
||||||
CommunityView,
|
CommunityView,
|
||||||
|
CustomEmojiView,
|
||||||
LocalUserSettingsView,
|
LocalUserSettingsView,
|
||||||
ModAddCommunityView,
|
ModAddCommunityView,
|
||||||
ModAddView,
|
ModAddView,
|
||||||
|
@ -194,6 +195,7 @@ export interface GetSiteResponse {
|
||||||
all_languages: Language[];
|
all_languages: Language[];
|
||||||
discussion_languages: number[];
|
discussion_languages: number[];
|
||||||
taglines?: Tagline[];
|
taglines?: Tagline[];
|
||||||
|
custom_emojis: CustomEmojiView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -86,6 +86,9 @@ export enum UserOperation {
|
||||||
GetReportCount,
|
GetReportCount,
|
||||||
GetUnreadCount,
|
GetUnreadCount,
|
||||||
VerifyEmail,
|
VerifyEmail,
|
||||||
|
CreateCustomEmoji,
|
||||||
|
EditCustomEmoji,
|
||||||
|
DeleteCustomEmoji,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -386,3 +386,23 @@ export interface Tagline {
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
updated?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class CustomEmoji {
|
||||||
|
id: number;
|
||||||
|
local_site_id: number;
|
||||||
|
shortcode: string;
|
||||||
|
image_url: string;
|
||||||
|
alt_text: string;
|
||||||
|
category: string;
|
||||||
|
published: string;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CustomEmojiKeyword {
|
||||||
|
id: number;
|
||||||
|
custom_emoji_id: number;
|
||||||
|
keyword: string;
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import {
|
||||||
CommentReply,
|
CommentReply,
|
||||||
CommentReport,
|
CommentReport,
|
||||||
CommunitySafe,
|
CommunitySafe,
|
||||||
|
CustomEmoji,
|
||||||
|
CustomEmojiKeyword,
|
||||||
LocalSite,
|
LocalSite,
|
||||||
LocalSiteRateLimit,
|
LocalSiteRateLimit,
|
||||||
LocalUserSettings,
|
LocalUserSettings,
|
||||||
|
@ -289,3 +291,10 @@ export interface PrivateMessageReportView {
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
resolver?: PersonSafe;
|
resolver?: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class CustomEmojiView {
|
||||||
|
@Type(() => CustomEmoji)
|
||||||
|
custom_emoji: CustomEmoji;
|
||||||
|
@Type(() => CustomEmojiKeyword)
|
||||||
|
keywords: CustomEmojiKeyword[];
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,11 @@ import {
|
||||||
RemoveCommunity,
|
RemoveCommunity,
|
||||||
TransferCommunity,
|
TransferCommunity,
|
||||||
} from "./interfaces/api/community";
|
} from "./interfaces/api/community";
|
||||||
|
import {
|
||||||
|
CreateCustomEmoji,
|
||||||
|
DeleteCustomEmoji,
|
||||||
|
EditCustomEmoji,
|
||||||
|
} from "./interfaces/api/custom_emoji";
|
||||||
import {
|
import {
|
||||||
AddAdmin,
|
AddAdmin,
|
||||||
BanPerson,
|
BanPerson,
|
||||||
|
@ -682,6 +687,27 @@ export class LemmyWebsocket {
|
||||||
purgeComment(form: PurgeComment) {
|
purgeComment(form: PurgeComment) {
|
||||||
return wrapper(UserOperation.PurgeComment, form);
|
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) {
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||||
|
|
Loading…
Reference in a new issue