1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-23 18:11:40 +00:00

Create first custom emoji

This commit is contained in:
2020-04-03 16:20:08 +02:00
parent 2465b0c1ac
commit 131735a5f0
6 changed files with 108 additions and 1 deletions

View File

@ -117,6 +117,8 @@ export const Routes : Route[] = [
{path: "/settings/set_account_image_visibility", cb: (h) => SettingsController.SetAccountImageVisibility(h)},
{path: "/settings/upload_custom_emoji", cb: (h) => SettingsController.UploadCustomEmoji(h)},
// Friends controller
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},

View File

@ -13,6 +13,8 @@ import { AccountHelper } from "../helpers/AccountHelper";
import { AccountImageVisibilityLevel } from "../entities/AccountImage";
import { AccountImageHelper } from "../helpers/AccountImageHelper";
import { findKey } from "../utils/ArrayUtils";
import { CustomEmojisHelper } from "../helpers/CustomEmojisHelper";
import { CustomEmoji } from "../entities/CustomEmoji";
/**
* API account image visibility levels
@ -260,4 +262,27 @@ export class SettingsController {
h.success();
}
/**
* Upload a custom emoji to the server
*
* @param h Request handler
*/
public static async UploadCustomEmoji(h: RequestHandler) {
const shorcut = h.postEmojiShorcut("shorcut");
const path = await h.savePostImage("image", "custom_emojies", 72, 72);
// Create the emoji
const emojiID = await CustomEmojisHelper.Insert(new CustomEmoji({
id: -1,
userID: h.getUserId(),
shorcut: shorcut,
path: path
}))
h.send({
emojiID: emojiID
})
}
}