2023-09-29 01:58:05 +02:00
|
|
|
import {
|
|
|
|
|
BaseEntity,
|
|
|
|
|
Column,
|
|
|
|
|
Entity,
|
|
|
|
|
ManyToOne,
|
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
|
} from "typeorm";
|
2023-09-12 22:48:10 +02:00
|
|
|
import { APIEmoji } from "~types/entities/emoji";
|
2023-09-29 01:58:05 +02:00
|
|
|
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;
|
|
|
|
|
|
2023-09-29 01:58:05 +02:00
|
|
|
/**
|
|
|
|
|
* The instance that the emoji is from.
|
|
|
|
|
* If is null, the emoji is from the server's instance
|
|
|
|
|
*/
|
|
|
|
|
@ManyToOne(() => Instance, {
|
|
|
|
|
nullable: true,
|
|
|
|
|
})
|
2023-10-08 22:20:42 +02:00
|
|
|
instance!: Instance | null;
|
2023-09-29 01:58:05 +02:00
|
|
|
|
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,
|
2023-10-08 22:20:42 +02:00
|
|
|
static_url: this.url, // TODO: Add static version
|
|
|
|
|
url: this.url,
|
|
|
|
|
visible_in_picker: this.visible_in_picker,
|
2023-09-12 22:48:10 +02:00
|
|
|
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
|
|
|
}
|