2019-04-07 14:50:36 +02:00
|
|
|
import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm';
|
2021-08-19 14:55:45 +02:00
|
|
|
import { DriveFile } from './drive-file';
|
|
|
|
import { id } from '../id';
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
@Entity()
|
|
|
|
@Index(['usernameLower', 'host'], { unique: true })
|
|
|
|
export class User {
|
|
|
|
@PrimaryColumn(id())
|
|
|
|
public id: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The created date of the User.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public createdAt: Date;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
|
|
|
nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The updated date of the User.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public updatedAt: Date | null;
|
|
|
|
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 15:58:30 +01:00
|
|
|
nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public lastFetchedAt: Date | null;
|
|
|
|
|
2021-04-17 08:30:26 +02:00
|
|
|
@Index()
|
|
|
|
@Column('timestamp with time zone', {
|
2021-12-09 15:58:30 +01:00
|
|
|
nullable: true,
|
2021-04-17 08:30:26 +02:00
|
|
|
})
|
|
|
|
public lastActiveDate: Date | null;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
})
|
|
|
|
public hideOnlineStatus: boolean;
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 128,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The username of the User.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public username: string;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, select: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The username (lowercased) of the User.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public usernameLower: string;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The name of the User.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public name: string | null;
|
|
|
|
|
|
|
|
@Column('integer', {
|
|
|
|
default: 0,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The count of followers.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public followersCount: number;
|
|
|
|
|
|
|
|
@Column('integer', {
|
|
|
|
default: 0,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The count of following.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public followingCount: number;
|
|
|
|
|
|
|
|
@Column('integer', {
|
|
|
|
default: 0,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The count of notes.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public notesCount: number;
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The ID of avatar DriveFile.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public avatarId: DriveFile['id'] | null;
|
|
|
|
|
|
|
|
@OneToOne(type => DriveFile, {
|
2021-12-09 15:58:30 +01:00
|
|
|
onDelete: 'SET NULL',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public avatar: DriveFile | null;
|
|
|
|
|
|
|
|
@Column({
|
|
|
|
...id(),
|
|
|
|
nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The ID of banner DriveFile.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public bannerId: DriveFile['id'] | null;
|
|
|
|
|
|
|
|
@OneToOne(type => DriveFile, {
|
2021-12-09 15:58:30 +01:00
|
|
|
onDelete: 'SET NULL',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
@JoinColumn()
|
|
|
|
public banner: DriveFile | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
2021-12-09 15:58:30 +01:00
|
|
|
length: 128, array: true, default: '{}',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public tags: string[];
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public avatarUrl: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public bannerUrl: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2020-07-18 17:24:07 +02:00
|
|
|
length: 128, nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
2020-07-18 17:24:07 +02:00
|
|
|
public avatarBlurhash: string | null;
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
@Column('varchar', {
|
2020-07-18 17:24:07 +02:00
|
|
|
length: 128, nullable: true,
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
2020-07-18 17:24:07 +02:00
|
|
|
public bannerBlurhash: string | null;
|
2019-04-07 14:50:36 +02:00
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is suspended.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isSuspended: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is silenced.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isSilenced: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is locked.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isLocked: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is a bot.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isBot: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is a cat.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isCat: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is the admin.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isAdmin: boolean;
|
|
|
|
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is a moderator.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public isModerator: boolean;
|
|
|
|
|
2020-12-11 13:16:20 +01:00
|
|
|
@Index()
|
|
|
|
@Column('boolean', {
|
|
|
|
default: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is explorable.',
|
2020-12-11 13:16:20 +01:00
|
|
|
})
|
|
|
|
public isExplorable: boolean;
|
|
|
|
|
2021-08-21 05:41:56 +02:00
|
|
|
// アカウントが削除されたかどうかのフラグだが、完全に削除される際は物理削除なので実質削除されるまでの「削除が進行しているかどうか」のフラグ
|
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'Whether the User is deleted.',
|
2021-08-21 05:41:56 +02:00
|
|
|
})
|
|
|
|
public isDeleted: boolean;
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
@Column('varchar', {
|
2021-12-09 15:58:30 +01:00
|
|
|
length: 128, array: true, default: '{}',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public emojis: string[];
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
|
|
|
length: 128, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The host of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public host: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The inbox URL of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public inbox: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The sharedInbox URL of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public sharedInbox: string | null;
|
|
|
|
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The featured URL of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public featured: string | null;
|
|
|
|
|
|
|
|
@Index()
|
|
|
|
@Column('varchar', {
|
2019-04-11 12:03:49 +02:00
|
|
|
length: 512, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The URI of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public uri: string | null;
|
|
|
|
|
2021-02-06 03:50:33 +01:00
|
|
|
@Column('varchar', {
|
|
|
|
length: 512, nullable: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The URI of the user Follower Collection. It will be null if the origin of the user is local.',
|
2021-02-06 03:50:33 +01:00
|
|
|
})
|
|
|
|
public followersUri: string | null;
|
|
|
|
|
2022-02-06 08:02:48 +01:00
|
|
|
@Column('boolean', {
|
|
|
|
default: false,
|
|
|
|
comment: 'Whether to show users replying to other users in the timeline'
|
|
|
|
})
|
|
|
|
public showTimelineReplies: boolean;
|
|
|
|
|
2019-04-07 14:50:36 +02:00
|
|
|
@Index({ unique: true })
|
2019-04-08 13:29:52 +02:00
|
|
|
@Column('char', {
|
|
|
|
length: 16, nullable: true, unique: true,
|
2021-12-09 15:58:30 +01:00
|
|
|
comment: 'The native access token of the User. It will be null if the origin of the user is local.',
|
2019-04-07 14:50:36 +02:00
|
|
|
})
|
|
|
|
public token: string | null;
|
2019-04-11 18:52:25 +02:00
|
|
|
|
|
|
|
constructor(data: Partial<User>) {
|
|
|
|
if (data == null) return;
|
|
|
|
|
|
|
|
for (const [k, v] of Object.entries(data)) {
|
|
|
|
(this as any)[k] = v;
|
|
|
|
}
|
|
|
|
}
|
2019-04-07 14:50:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ILocalUser extends User {
|
|
|
|
host: null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IRemoteUser extends User {
|
|
|
|
host: string;
|
|
|
|
}
|