server/database/entities/Emoji.ts

66 lines
1.2 KiB
TypeScript
Raw Normal View History

import {
BaseEntity,
Column,
Entity,
ManyToOne,
PrimaryGeneratedColumn,
} from "typeorm";
2023-09-12 22:48:10 +02:00
import { APIEmoji } from "~types/entities/emoji";
import { Instance } from "./Instance";
2023-09-12 22:48:10 +02:00
2023-09-28 20:19:21 +02:00
/**
* Represents an emoji entity in the database.
*/
2023-09-12 22:48:10 +02:00
@Entity({
name: "emojis",
})
export class Emoji extends BaseEntity {
2023-09-28 20:19:21 +02:00
/**
* The unique identifier for the emoji.
*/
2023-09-12 22:48:10 +02:00
@PrimaryGeneratedColumn("uuid")
id!: string;
2023-09-28 20:19:21 +02:00
/**
* The shortcode for the emoji.
*/
2023-09-12 22:48:10 +02:00
@Column("varchar")
shortcode!: string;
/**
* The instance that the emoji is from.
* If is null, the emoji is from the server's instance
*/
@ManyToOne(() => Instance, {
nullable: true,
})
instance!: Instance;
2023-09-28 20:19:21 +02:00
/**
* The URL for the emoji.
*/
2023-09-12 22:48:10 +02:00
@Column("varchar")
url!: string;
2023-09-28 20:19:21 +02:00
/**
* Whether the emoji is visible in the picker.
*/
2023-09-12 22:48:10 +02:00
@Column("boolean")
visible_in_picker!: boolean;
2023-09-28 20:19:21 +02:00
/**
* Converts the emoji to an APIEmoji object.
* @returns The APIEmoji object.
*/
2023-09-12 22:48:10 +02:00
// eslint-disable-next-line @typescript-eslint/require-await
async toAPI(): Promise<APIEmoji> {
return {
shortcode: this.shortcode,
static_url: "",
url: "",
visible_in_picker: false,
category: undefined,
2023-09-13 02:29:13 +02:00
};
2023-09-12 22:48:10 +02:00
}
2023-09-13 02:29:13 +02:00
}