Refacor electron app and add migrations
This commit is contained in:
35
electron/entities/AttachmentEntity.ts
Normal file
35
electron/entities/AttachmentEntity.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('attachments')
|
||||
export class AttachmentEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Column('text')
|
||||
messageId!: string;
|
||||
|
||||
@Column('text')
|
||||
filename!: string;
|
||||
|
||||
@Column('integer')
|
||||
size!: number;
|
||||
|
||||
@Column('text')
|
||||
mime!: string;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isImage!: number;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
uploaderPeerId!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
filePath!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
savedPath!: string | null;
|
||||
}
|
||||
32
electron/entities/BanEntity.ts
Normal file
32
electron/entities/BanEntity.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('bans')
|
||||
export class BanEntity {
|
||||
@PrimaryColumn('text')
|
||||
oderId!: string;
|
||||
|
||||
@PrimaryColumn('text')
|
||||
roomId!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
userId!: string | null;
|
||||
|
||||
@Column('text')
|
||||
bannedBy!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
displayName!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
reason!: string | null;
|
||||
|
||||
@Column('integer', { nullable: true })
|
||||
expiresAt!: number | null;
|
||||
|
||||
@Column('integer')
|
||||
timestamp!: number;
|
||||
}
|
||||
41
electron/entities/MessageEntity.ts
Normal file
41
electron/entities/MessageEntity.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('messages')
|
||||
export class MessageEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Column('text')
|
||||
roomId!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
channelId!: string | null;
|
||||
|
||||
@Column('text')
|
||||
senderId!: string;
|
||||
|
||||
@Column('text')
|
||||
senderName!: string;
|
||||
|
||||
@Column('text')
|
||||
content!: string;
|
||||
|
||||
@Column('integer')
|
||||
timestamp!: number;
|
||||
|
||||
@Column('integer', { nullable: true })
|
||||
editedAt!: number | null;
|
||||
|
||||
@Column('text', { default: '[]' })
|
||||
reactions!: string;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isDeleted!: number;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
replyToId!: string | null;
|
||||
}
|
||||
10
electron/entities/MetaEntity.ts
Normal file
10
electron/entities/MetaEntity.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
|
||||
@Entity('meta')
|
||||
export class MetaEntity {
|
||||
@PrimaryColumn('text')
|
||||
key!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
value!: string | null;
|
||||
}
|
||||
22
electron/entities/ReactionEntity.ts
Normal file
22
electron/entities/ReactionEntity.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Entity, PrimaryColumn, Column } from 'typeorm';
|
||||
|
||||
@Entity('reactions')
|
||||
export class ReactionEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Column('text')
|
||||
messageId!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
oderId!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
userId!: string | null;
|
||||
|
||||
@Column('text')
|
||||
emoji!: string;
|
||||
|
||||
@Column('integer')
|
||||
timestamp!: number;
|
||||
}
|
||||
50
electron/entities/RoomEntity.ts
Normal file
50
electron/entities/RoomEntity.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('rooms')
|
||||
export class RoomEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Column('text')
|
||||
name!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
description!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
topic!: string | null;
|
||||
|
||||
@Column('text')
|
||||
hostId!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
password!: string | null;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isPrivate!: number;
|
||||
|
||||
@Column('integer')
|
||||
createdAt!: number;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
userCount!: number;
|
||||
|
||||
@Column('integer', { nullable: true })
|
||||
maxUsers!: number | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
icon!: string | null;
|
||||
|
||||
@Column('integer', { nullable: true })
|
||||
iconUpdatedAt!: number | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
permissions!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
channels!: string | null;
|
||||
}
|
||||
50
electron/entities/UserEntity.ts
Normal file
50
electron/entities/UserEntity.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
Entity,
|
||||
PrimaryColumn,
|
||||
Column
|
||||
} from 'typeorm';
|
||||
|
||||
@Entity('users')
|
||||
export class UserEntity {
|
||||
@PrimaryColumn('text')
|
||||
id!: string;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
oderId!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
username!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
displayName!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
avatarUrl!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
status!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
role!: string | null;
|
||||
|
||||
@Column('integer', { nullable: true })
|
||||
joinedAt!: number | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
peerId!: string | null;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isOnline!: number;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isAdmin!: number;
|
||||
|
||||
@Column('integer', { default: 0 })
|
||||
isRoomOwner!: number;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
voiceState!: string | null;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
screenShareState!: string | null;
|
||||
}
|
||||
7
electron/entities/index.ts
Normal file
7
electron/entities/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export { MessageEntity } from './MessageEntity';
|
||||
export { UserEntity } from './UserEntity';
|
||||
export { RoomEntity } from './RoomEntity';
|
||||
export { ReactionEntity } from './ReactionEntity';
|
||||
export { BanEntity } from './BanEntity';
|
||||
export { AttachmentEntity } from './AttachmentEntity';
|
||||
export { MetaEntity } from './MetaEntity';
|
||||
Reference in New Issue
Block a user