mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 06:49:23 +00:00
Can delete an emoji
This commit is contained in:
parent
8693c1e556
commit
96ab83af7b
@ -119,6 +119,8 @@ export const Routes : Route[] = [
|
|||||||
|
|
||||||
{path: "/settings/upload_custom_emoji", cb: (h) => SettingsController.UploadCustomEmoji(h)},
|
{path: "/settings/upload_custom_emoji", cb: (h) => SettingsController.UploadCustomEmoji(h)},
|
||||||
|
|
||||||
|
{path: "/settings/delete_custom_emoji", cb: (h) => SettingsController.DeleteCustomEmoji(h)},
|
||||||
|
|
||||||
|
|
||||||
// Friends controller
|
// Friends controller
|
||||||
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
|
{path: "/friends/getList", cb: (h) => FriendsController.GetList(h)},
|
||||||
|
@ -286,6 +286,19 @@ export class SettingsController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a custom emoji of the user
|
||||||
|
*
|
||||||
|
* @param h Request handler
|
||||||
|
*/
|
||||||
|
public static async DeleteCustomEmoji(h: RequestHandler) {
|
||||||
|
const emoji = await h.postEmojiID("emojiID");
|
||||||
|
|
||||||
|
await CustomEmojisHelper.Delete(emoji);
|
||||||
|
|
||||||
|
h.success()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an emoji into an API entry
|
* Convert an emoji into an API entry
|
||||||
*
|
*
|
||||||
|
@ -29,4 +29,8 @@ export class CustomEmoji implements CustomEmojiBuilder {
|
|||||||
get url() : string {
|
get url() : string {
|
||||||
return pathUserData(this.path, false);
|
return pathUserData(this.path, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sysPath() : string {
|
||||||
|
return pathUserData(this.path, true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
import { CustomEmoji } from "../entities/CustomEmoji";
|
import { CustomEmoji } from "../entities/CustomEmoji";
|
||||||
import { DatabaseHelper } from "./DatabaseHelper";
|
import { DatabaseHelper } from "./DatabaseHelper";
|
||||||
|
import { existsSync, unlinkSync } from "fs";
|
||||||
|
|
||||||
const EMOJIS_TABLE = "comunic_custom_emojis";
|
const EMOJIS_TABLE = "comunic_custom_emojis";
|
||||||
|
|
||||||
@ -62,6 +63,22 @@ export class CustomEmojisHelper {
|
|||||||
return this.DbToCustomEmoji(row);
|
return this.DbToCustomEmoji(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a custom emoji
|
||||||
|
*
|
||||||
|
* @param e Information about the emoji to delete
|
||||||
|
*/
|
||||||
|
public static async Delete(e: CustomEmoji) {
|
||||||
|
|
||||||
|
if(existsSync(e.sysPath))
|
||||||
|
unlinkSync(e.sysPath)
|
||||||
|
|
||||||
|
await DatabaseHelper.DeleteRows(EMOJIS_TABLE, {
|
||||||
|
id: e.id
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn a database entry into a custom emoji
|
* Turn a database entry into a custom emoji
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user