diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2019-04-10 15:04:27 +0900 |
| commit | 626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c (patch) | |
| tree | 23b89c000b1b169c36cffc7a345a2fc1ebe33347 /src/models | |
| parent | Delete get-user-summary.ts (diff) | |
| download | misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.gz misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.tar.bz2 misskey-626cfb61ac3940bee7a3acf1b1c5c4cae4ae410c.zip | |
テーブル分割
Diffstat (limited to 'src/models')
| -rw-r--r-- | src/models/entities/user-keypair.ts | 5 | ||||
| -rw-r--r-- | src/models/entities/user-profile.ts (renamed from src/models/entities/user-service-linking.ts) | 102 | ||||
| -rw-r--r-- | src/models/entities/user-publickey.ts | 5 | ||||
| -rw-r--r-- | src/models/entities/user.ts | 81 | ||||
| -rw-r--r-- | src/models/index.ts | 4 | ||||
| -rw-r--r-- | src/models/repositories/user.ts | 15 |
6 files changed, 107 insertions, 105 deletions
diff --git a/src/models/entities/user-keypair.ts b/src/models/entities/user-keypair.ts index be264641f7..9181abf8cb 100644 --- a/src/models/entities/user-keypair.ts +++ b/src/models/entities/user-keypair.ts @@ -4,11 +4,8 @@ import { id } from '../id'; @Entity() export class UserKeypair { - @PrimaryColumn(id()) - public id: string; - @Index({ unique: true }) - @Column(id()) + @PrimaryColumn(id()) public userId: User['id']; @OneToOne(type => User, { diff --git a/src/models/entities/user-service-linking.ts b/src/models/entities/user-profile.ts index 3d99554e1e..24b92231f5 100644 --- a/src/models/entities/user-service-linking.ts +++ b/src/models/entities/user-profile.ts @@ -1,14 +1,11 @@ -import { PrimaryColumn, Entity, Index, JoinColumn, Column, OneToOne } from 'typeorm'; -import { User } from './user'; +import { Entity, Column, Index, OneToOne, JoinColumn, PrimaryColumn } from 'typeorm'; import { id } from '../id'; +import { User } from './user'; @Entity() -export class UserServiceLinking { - @PrimaryColumn(id()) - public id: string; - +export class UserProfile { @Index({ unique: true }) - @Column(id()) + @PrimaryColumn(id()) public userId: User['id']; @OneToOne(type => User, { @@ -17,6 +14,96 @@ export class UserServiceLinking { @JoinColumn() public user: User | null; + @Column('varchar', { + length: 128, nullable: true, + comment: 'The location of the User.' + }) + public location: string | null; + + @Column('char', { + length: 10, nullable: true, + comment: 'The birthday (YYYY-MM-DD) of the User.' + }) + public birthday: string | null; + + @Column('varchar', { + length: 1024, nullable: true, + comment: 'The description (bio) of the User.' + }) + public description: string | null; + + @Column('jsonb', { + default: [], + }) + public fields: { + name: string; + value: string; + }[]; + + @Column('varchar', { + length: 128, nullable: true, + comment: 'The email address of the User.' + }) + public email: string | null; + + @Column('varchar', { + length: 128, nullable: true, + }) + public emailVerifyCode: string | null; + + @Column('boolean', { + default: false, + }) + public emailVerified: boolean; + + @Column('varchar', { + length: 128, nullable: true, + }) + public twoFactorTempSecret: string | null; + + @Column('varchar', { + length: 128, nullable: true, + }) + public twoFactorSecret: string | null; + + @Column('boolean', { + default: false, + }) + public twoFactorEnabled: boolean; + + @Column('varchar', { + length: 128, nullable: true, + comment: 'The password hash of the User. It will be null if the origin of the user is local.' + }) + public password: string | null; + + @Column('jsonb', { + default: {}, + comment: 'The client-specific data of the User.' + }) + public clientData: Record<string, any>; + + @Column('boolean', { + default: false, + }) + public autoWatch: boolean; + + @Column('boolean', { + default: false, + }) + public autoAcceptFollowed: boolean; + + @Column('boolean', { + default: false, + }) + public alwaysMarkNsfw: boolean; + + @Column('boolean', { + default: false, + }) + public carefulBot: boolean; + + //#region Linking @Column('boolean', { default: false, }) @@ -96,6 +183,7 @@ export class UserServiceLinking { length: 64, nullable: true, default: null, }) public discordDiscriminator: string | null; + //#endregion //#region Denormalized fields @Index() diff --git a/src/models/entities/user-publickey.ts b/src/models/entities/user-publickey.ts index 6c019f3313..81c42404fa 100644 --- a/src/models/entities/user-publickey.ts +++ b/src/models/entities/user-publickey.ts @@ -4,11 +4,8 @@ import { id } from '../id'; @Entity() export class UserPublickey { - @PrimaryColumn(id()) - public id: string; - @Index({ unique: true }) - @Column(id()) + @PrimaryColumn(id()) public userId: User['id']; @OneToOne(type => User, { diff --git a/src/models/entities/user.ts b/src/models/entities/user.ts index 0a2878c0c9..40d27a42bb 100644 --- a/src/models/entities/user.ts +++ b/src/models/entities/user.ts @@ -45,18 +45,6 @@ export class User { }) public name: string | null; - @Column('varchar', { - length: 128, nullable: true, - comment: 'The location of the User.' - }) - public location: string | null; - - @Column('char', { - length: 10, nullable: true, - comment: 'The birthday (YYYY-MM-DD) of the User.' - }) - public birthday: string | null; - @Column('integer', { default: 0, comment: 'The count of followers.' @@ -101,12 +89,6 @@ export class User { @JoinColumn() public banner: DriveFile | null; - @Column('varchar', { - length: 1024, nullable: true, - comment: 'The description (bio) of the User.' - }) - public description: string | null; - @Index() @Column('varchar', { length: 128, array: true, default: '{}' @@ -114,32 +96,6 @@ export class User { public tags: string[]; @Column('varchar', { - length: 128, nullable: true, - comment: 'The email address of the User.' - }) - public email: string | null; - - @Column('varchar', { - length: 128, nullable: true, - }) - public emailVerifyCode: string | null; - - @Column('boolean', { - default: false, - }) - public emailVerified: boolean; - - @Column('varchar', { - length: 128, nullable: true, - }) - public twoFactorTempSecret: string | null; - - @Column('varchar', { - length: 128, nullable: true, - }) - public twoFactorSecret: string | null; - - @Column('varchar', { length: 256, nullable: true, }) public avatarUrl: string | null; @@ -206,11 +162,6 @@ export class User { }) public isVerified: boolean; - @Column('boolean', { - default: false, - }) - public twoFactorEnabled: boolean; - @Column('varchar', { length: 128, array: true, default: '{}' }) @@ -248,44 +199,12 @@ export class User { }) public uri: string | null; - @Column('varchar', { - length: 128, nullable: true, - comment: 'The password hash of the User. It will be null if the origin of the user is local.' - }) - public password: string | null; - @Index({ unique: true }) @Column('char', { length: 16, nullable: true, unique: true, comment: 'The native access token of the User. It will be null if the origin of the user is local.' }) public token: string | null; - - @Column('jsonb', { - default: {}, - comment: 'The client-specific data of the User.' - }) - public clientData: Record<string, any>; - - @Column('boolean', { - default: false, - }) - public autoWatch: boolean; - - @Column('boolean', { - default: false, - }) - public autoAcceptFollowed: boolean; - - @Column('boolean', { - default: false, - }) - public alwaysMarkNsfw: boolean; - - @Column('boolean', { - default: false, - }) - public carefulBot: boolean; } export interface ILocalUser extends User { diff --git a/src/models/index.ts b/src/models/index.ts index f88bb8d636..d66e4e710a 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -25,7 +25,6 @@ import { FollowRequestRepository } from './repositories/follow-request'; import { MutingRepository } from './repositories/muting'; import { BlockingRepository } from './repositories/blocking'; import { NoteReactionRepository } from './repositories/note-reaction'; -import { UserServiceLinking } from './entities/user-service-linking'; import { NotificationRepository } from './repositories/notification'; import { NoteFavoriteRepository } from './repositories/note-favorite'; import { ReversiMatchingRepository } from './repositories/games/reversi/matching'; @@ -35,6 +34,7 @@ import { AppRepository } from './repositories/app'; import { FollowingRepository } from './repositories/following'; import { AbuseUserReportRepository } from './repositories/abuse-user-report'; import { AuthSessionRepository } from './repositories/auth-session'; +import { UserProfile } from './entities/user-profile'; export const Apps = getCustomRepository(AppRepository); export const Notes = getCustomRepository(NoteRepository); @@ -45,12 +45,12 @@ export const NoteUnreads = getRepository(NoteUnread); export const Polls = getRepository(Poll); export const PollVotes = getRepository(PollVote); export const Users = getCustomRepository(UserRepository); +export const UserProfiles = getRepository(UserProfile); export const UserKeypairs = getRepository(UserKeypair); export const UserPublickeys = getRepository(UserPublickey); export const UserLists = getCustomRepository(UserListRepository); export const UserListJoinings = getRepository(UserListJoining); export const UserNotePinings = getRepository(UserNotePining); -export const UserServiceLinkings = getRepository(UserServiceLinking); export const Followings = getCustomRepository(FollowingRepository); export const FollowRequests = getCustomRepository(FollowRequestRepository); export const Instances = getRepository(Instance); diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index 3939e3142a..9e11b2aa88 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -1,6 +1,6 @@ import { EntityRepository, Repository, In } from 'typeorm'; import { User, ILocalUser, IRemoteUser } from '../entities/user'; -import { Emojis, Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings } from '..'; +import { Emojis, Notes, NoteUnreads, FollowRequests, Notifications, MessagingMessages, UserNotePinings, Followings, Blockings, Mutings, UserProfiles } from '..'; import rap from '@prezzemolo/rap'; @EntityRepository(User) @@ -80,6 +80,7 @@ export class UserRepository extends Repository<User> { const relation = meId && (meId !== user.id) && opts.detail ? await this.getRelation(meId, user.id) : null; const pins = opts.detail ? await UserNotePinings.find({ userId: user.id }) : []; + const profile = opts.detail ? await UserProfiles.findOne({ userId: user.id }) : null; return await rap({ id: user.id, @@ -116,9 +117,9 @@ export class UserRepository extends Repository<User> { } : {}), ...(opts.detail ? { - description: user.description, - location: user.location, - birthday: user.birthday, + description: profile.description, + location: profile.location, + birthday: profile.birthday, followersCount: user.followersCount, followingCount: user.followingCount, notesCount: user.notesCount, @@ -131,9 +132,9 @@ export class UserRepository extends Repository<User> { ...(opts.detail && meId === user.id ? { avatarId: user.avatarId, bannerId: user.bannerId, - autoWatch: user.autoWatch, - alwaysMarkNsfw: user.alwaysMarkNsfw, - carefulBot: user.carefulBot, + autoWatch: profile.autoWatch, + alwaysMarkNsfw: profile.alwaysMarkNsfw, + carefulBot: profile.carefulBot, hasUnreadMessagingMessage: MessagingMessages.count({ where: { recipientId: user.id, |