diff --git a/util/src/entities/Channel.ts b/src/util/entities/Channel.ts
index 10fa03ff..577b627e 100644
--- a/util/src/entities/Channel.ts
+++ b/src/util/entities/Channel.ts
@@ -58,7 +58,7 @@ export class Channel extends BaseClass {
recipients?: Recipient[];
@Column({ nullable: true })
- last_message_id: string;
+ last_message_id?: string;
@Column({ nullable: true })
@RelationId((channel: Channel) => channel.guild)
@@ -81,7 +81,7 @@ export class Channel extends BaseClass {
// for group DMs and owned custom channel types
@Column({ nullable: true })
@RelationId((channel: Channel) => channel.owner)
- owner_id: string;
+ owner_id?: string;
@JoinColumn({ name: "owner_id" })
@ManyToOne(() => User)
@@ -169,7 +169,7 @@ export class Channel extends BaseClass {
}
if (!opts?.skipNameChecks) {
- const guild = await Guild.findOneOrFail({ id: channel.guild_id });
+ const guild = await Guild.findOneOrFail({ where: { id: channel.guild_id } });
if (!guild.features.includes("ALLOW_INVALID_CHANNEL_NAMES") && channel.name) {
for (var character of InvisibleCharacters)
if (channel.name.includes(character))
@@ -202,7 +202,7 @@ export class Channel extends BaseClass {
case ChannelType.GUILD_NEWS:
case ChannelType.GUILD_VOICE:
if (channel.parent_id && !opts?.skipExistsCheck) {
- const exists = await Channel.findOneOrFail({ id: channel.parent_id });
+ const exists = await Channel.findOneOrFail({ where: { id: channel.parent_id } });
if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
if (exists.guild_id !== channel.guild_id)
throw new HTTPError("The category channel needs to be in the guild");
@@ -230,7 +230,7 @@ export class Channel extends BaseClass {
};
await Promise.all([
- new Channel(channel).save(),
+ Channel.create(channel).save(),
!opts?.skipEventEmit
? emitEvent({
event: "CHANNEL_CREATE",
@@ -281,15 +281,15 @@ export class Channel extends BaseClass {
if (channel == null) {
name = trimSpecial(name);
- channel = await new Channel({
+ channel = await Channel.create({
name,
type,
- owner_id: type === ChannelType.DM ? undefined : null, // 1:1 DMs are ownerless in fosscord-server
+ owner_id: undefined,
created_at: new Date(),
- last_message_id: null,
+ last_message_id: undefined,
recipients: channelRecipients.map(
(x) =>
- new Recipient({ user_id: x, closed: !(type === ChannelType.GROUP_DM || x === creator_user_id) })
+ Recipient.create({ user_id: x, closed: !(type === ChannelType.GROUP_DM || x === creator_user_id) })
),
nsfw: false,
}).save();
|