🐛 fix sticker packs

This commit is contained in:
Flam3rboy 2021-10-15 00:03:19 +02:00
parent d8f77c687e
commit fb3f957f30
3 changed files with 10 additions and 6 deletions

View File

@ -1,11 +1,13 @@
import { Request, Response, Router } from "express"; import { Request, Response, Router } from "express";
import { route } from "@fosscord/api"; import { route } from "@fosscord/api";
import { StickerPack } from "@fosscord/util/src/entities/StickerPack"; import { StickerPack } from "@fosscord/util";
const router: Router = Router(); const router: Router = Router();
router.get("/", route({}), async (req: Request, res: Response) => { router.get("/", route({}), async (req: Request, res: Response) => {
res.json(await StickerPack.find({})); const sticker_packs = await StickerPack.find({ relations: ["stickers"] });
res.json({ sticker_packs });
}); });
export default router; export default router;

View File

@ -179,6 +179,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
x.guild_hashes = {}; // @ts-ignore x.guild_hashes = {}; // @ts-ignore
x.guild_scheduled_events = []; // @ts-ignore x.guild_scheduled_events = []; // @ts-ignore
x.threads = []; x.threads = [];
x.premium_subscription_count = 30;
x.premium_tier = 3;
return x; return x;
}), }),
guild_experiments: [], // TODO guild_experiments: [], // TODO

View File

@ -1,8 +1,8 @@
import { Column, Entity, JoinColumn, OneToMany, OneToOne, RelationId } from "typeorm"; import { Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, RelationId } from "typeorm";
import { Sticker } from "."; import { Sticker } from ".";
import { BaseClass } from "./BaseClass"; import { BaseClass } from "./BaseClass";
@Entity("stickers") @Entity("sticker_packs")
export class StickerPack extends BaseClass { export class StickerPack extends BaseClass {
@Column() @Column()
name: string; name: string;
@ -13,7 +13,7 @@ export class StickerPack extends BaseClass {
@Column({ nullable: true }) @Column({ nullable: true })
banner_asset_id?: string; banner_asset_id?: string;
@OneToMany(() => Sticker, (sticker: Sticker) => sticker.pack_id, { @OneToMany(() => Sticker, (sticker: Sticker) => sticker.pack, {
cascade: true, cascade: true,
orphanedRowAction: "delete", orphanedRowAction: "delete",
}) })
@ -25,7 +25,7 @@ export class StickerPack extends BaseClass {
@RelationId((pack: StickerPack) => pack.cover_sticker) @RelationId((pack: StickerPack) => pack.cover_sticker)
cover_sticker_id?: string; cover_sticker_id?: string;
@OneToOne(() => Sticker, { nullable: true }) @ManyToOne(() => Sticker, { nullable: true })
@JoinColumn() @JoinColumn()
cover_sticker?: Sticker; cover_sticker?: Sticker;
} }