Skip to content

Commit

Permalink
パーソナル(ユーザー)メモ機能を削除 (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
adzukimame authored Dec 11, 2024
1 parent e06fd64 commit 1fa43d4
Show file tree
Hide file tree
Showing 22 changed files with 18 additions and 507 deletions.
18 changes: 18 additions & 0 deletions packages/backend/migration/1733908053587-RemoveUserMemo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default class RemoveUserMemo1733908053587 {
name = 'RemoveUserMemo1733908053587'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_memo" DROP CONSTRAINT "FK_66ac4a82894297fd09ba61f3d35"`);
await queryRunner.query(`ALTER TABLE "user_memo" DROP CONSTRAINT "FK_650b49c5639b5840ee6a2b8f83e"`);
await queryRunner.query(`DROP TABLE "user_memo"`);
}

async down(queryRunner) {
await queryRunner.query(`CREATE TABLE "user_memo" ("id" character varying(32) NOT NULL, "userId" character varying(32) NOT NULL, "targetUserId" character varying(32) NOT NULL, "memo" character varying(2048) NOT NULL, CONSTRAINT "PK_e9aaa58f7d3699a84d79078f4d9" PRIMARY KEY ("id")); COMMENT ON COLUMN "user_memo"."userId" IS 'The ID of author.'; COMMENT ON COLUMN "user_memo"."targetUserId" IS 'The ID of target user.'; COMMENT ON COLUMN "user_memo"."memo" IS 'Memo.'`);
await queryRunner.query(`CREATE INDEX "IDX_650b49c5639b5840ee6a2b8f83" ON "user_memo" ("userId") `);
await queryRunner.query(`CREATE INDEX "IDX_66ac4a82894297fd09ba61f3d3" ON "user_memo" ("targetUserId") `);
await queryRunner.query(`CREATE UNIQUE INDEX "IDX_faef300913c738265638ba3ebc" ON "user_memo" ("userId", "targetUserId") `);
await queryRunner.query(`ALTER TABLE "user_memo" ADD CONSTRAINT "FK_650b49c5639b5840ee6a2b8f83e" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE "user_memo" ADD CONSTRAINT "FK_66ac4a82894297fd09ba61f3d35" FOREIGN KEY ("targetUserId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}
}
21 changes: 0 additions & 21 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type {
MutingsRepository,
NoteUnreadsRepository,
RenoteMutingsRepository,
UserMemoRepository,
UserNotePiningsRepository,
UserProfilesRepository,
UserSecurityKeysRepository,
Expand Down Expand Up @@ -124,9 +123,6 @@ export class UserEntityService implements OnModuleInit {

@Inject(DI.userProfilesRepository)
private userProfilesRepository: UserProfilesRepository,

@Inject(DI.userMemosRepository)
private userMemosRepository: UserMemoRepository,
) {
}

Expand Down Expand Up @@ -380,7 +376,6 @@ export class UserEntityService implements OnModuleInit {
includeSecrets?: boolean,
userProfile?: MiUserProfile,
userRelations?: Map<MiUser['id'], UserRelation>,
userMemos?: Map<MiUser['id'], string | null>,
pinNotes?: Map<MiUser['id'], MiUserNotePining[]>,
},
): Promise<Packed<S>> {
Expand Down Expand Up @@ -409,16 +404,6 @@ export class UserEntityService implements OnModuleInit {
}
}

let memo: string | null = null;
if (isDetailed && meId) {
if (opts.userMemos) {
memo = opts.userMemos.get(user.id) ?? null;
} else {
memo = await this.userMemosRepository.findOneBy({ userId: meId, targetUserId: user.id })
.then(row => row?.memo ?? null);
}
}

let pins: MiUserNotePining[] = [];
if (isDetailed) {
if (opts.pinNotes) {
Expand Down Expand Up @@ -517,7 +502,6 @@ export class UserEntityService implements OnModuleInit {
isAdministrator: role.isAdministrator,
displayOrder: role.displayOrder,
}))),
memo: memo,
moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined,
} : {}),

Expand Down Expand Up @@ -624,7 +608,6 @@ export class UserEntityService implements OnModuleInit {

let profilesMap: Map<MiUser['id'], MiUserProfile> = new Map();
let userRelations: Map<MiUser['id'], UserRelation> = new Map();
let userMemos: Map<MiUser['id'], string | null> = new Map();
let pinNotes: Map<MiUser['id'], MiUserNotePining[]> = new Map();

if (options?.schema !== 'UserLite') {
Expand All @@ -633,9 +616,6 @@ export class UserEntityService implements OnModuleInit {

const meId = me ? me.id : null;
if (meId) {
userMemos = await this.userMemosRepository.findBy({ userId: meId })
.then(memos => new Map(memos.map(memo => [memo.targetUserId, memo.memo])));

if (_userIds.length > 0) {
userRelations = await this.getRelations(meId, _userIds);
pinNotes = await this.userNotePiningsRepository.createQueryBuilder('pin')
Expand Down Expand Up @@ -667,7 +647,6 @@ export class UserEntityService implements OnModuleInit {
...options,
userProfile: profilesMap.get(u.id),
userRelations: userRelations,
userMemos: userMemos,
pinNotes: pinNotes,
},
)),
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/di-symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,5 @@ export const DI = {
roleAssignmentsRepository: Symbol('roleAssignmentsRepository'),
flashsRepository: Symbol('flashsRepository'),
flashLikesRepository: Symbol('flashLikesRepository'),
userMemosRepository: Symbol('userMemosRepository'),
//#endregion
};
9 changes: 0 additions & 9 deletions packages/backend/src/models/RepositoryModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import {
MiUserList,
MiUserListFavorite,
MiUserListMembership,
MiUserMemo,
MiUserNotePining,
MiUserPending,
MiUserProfile,
Expand Down Expand Up @@ -356,12 +355,6 @@ const $roleAssignmentsRepository: Provider = {
inject: [DI.db],
};

const $userMemosRepository: Provider = {
provide: DI.userMemosRepository,
useFactory: (db: DataSource) => db.getRepository(MiUserMemo).extend(miRepository as MiRepository<MiUserMemo>),
inject: [DI.db],
};

@Module({
imports: [],
providers: [
Expand Down Expand Up @@ -414,7 +407,6 @@ const $userMemosRepository: Provider = {
$roleAssignmentsRepository,
$flashsRepository,
$flashLikesRepository,
$userMemosRepository,
],
exports: [
$usersRepository,
Expand Down Expand Up @@ -466,7 +458,6 @@ const $userMemosRepository: Provider = {
$roleAssignmentsRepository,
$flashsRepository,
$flashLikesRepository,
$userMemosRepository,
],
})
export class RepositoryModule {
Expand Down
47 changes: 0 additions & 47 deletions packages/backend/src/models/UserMemo.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/backend/src/models/_.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { MiUserPending } from '@/models/UserPending.js';
import { MiUserProfile } from '@/models/UserProfile.js';
import { MiUserPublickey } from '@/models/UserPublickey.js';
import { MiUserSecurityKey } from '@/models/UserSecurityKey.js';
import { MiUserMemo } from '@/models/UserMemo.js';
import { MiWebhook } from '@/models/Webhook.js';
import { MiChannel } from '@/models/Channel.js';
import { MiRole } from '@/models/Role.js';
Expand Down Expand Up @@ -155,7 +154,6 @@ export {
MiRoleAssignment,
MiFlash,
MiFlashLike,
MiUserMemo,
};

export type AccessTokensRepository = Repository<MiAccessToken> & MiRepository<MiAccessToken>;
Expand Down Expand Up @@ -207,4 +205,3 @@ export type RolesRepository = Repository<MiRole> & MiRepository<MiRole>;
export type RoleAssignmentsRepository = Repository<MiRoleAssignment> & MiRepository<MiRoleAssignment>;
export type FlashsRepository = Repository<MiFlash> & MiRepository<MiFlash>;
export type FlashLikesRepository = Repository<MiFlashLike> & MiRepository<MiFlashLike>;
export type UserMemoRepository = Repository<MiUserMemo> & MiRepository<MiUserMemo>;
4 changes: 0 additions & 4 deletions packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,6 @@ export const packedUserDetailedNotMeOnlySchema = {
ref: 'RoleLite',
},
},
memo: {
type: 'string',
nullable: true, optional: false,
},
moderationNote: {
type: 'string',
nullable: false, optional: true,
Expand Down
2 changes: 0 additions & 2 deletions packages/backend/src/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { MiRole } from '@/models/Role.js';
import { MiRoleAssignment } from '@/models/RoleAssignment.js';
import { MiFlash } from '@/models/Flash.js';
import { MiFlashLike } from '@/models/FlashLike.js';
import { MiUserMemo } from '@/models/UserMemo.js';

import { Config } from '@/config.js';
import MisskeyLogger from '@/logger.js';
Expand Down Expand Up @@ -176,7 +175,6 @@ export const entities = [
MiRoleAssignment,
MiFlash,
MiFlashLike,
MiUserMemo,
...charts,
];

Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/server/api/EndpointsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ import * as ep___users_relation from './endpoints/users/relation.js';
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
import * as ep___users_search from './endpoints/users/search.js';
import * as ep___users_show from './endpoints/users/show.js';
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';
import { GetterService } from './GetterService.js';
import { ApiLoggerService } from './ApiLoggerService.js';
import type { Provider } from '@nestjs/common';
Expand Down Expand Up @@ -585,7 +584,6 @@ const $users_relation: Provider = { provide: 'ep:users/relation', useClass: ep__
const $users_searchByUsernameAndHost: Provider = { provide: 'ep:users/search-by-username-and-host', useClass: ep___users_searchByUsernameAndHost.default };
const $users_search: Provider = { provide: 'ep:users/search', useClass: ep___users_search.default };
const $users_show: Provider = { provide: 'ep:users/show', useClass: ep___users_show.default };
const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass: ep___users_updateMemo.default };

@Module({
imports: [
Expand Down Expand Up @@ -881,7 +879,6 @@ const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass:
$users_searchByUsernameAndHost,
$users_search,
$users_show,
$users_updateMemo,
],
exports: [
$admin_meta,
Expand Down Expand Up @@ -1171,7 +1168,6 @@ const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass:
$users_searchByUsernameAndHost,
$users_search,
$users_show,
$users_updateMemo,
],
})
export class EndpointsModule {}
2 changes: 0 additions & 2 deletions packages/backend/src/server/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ import * as ep___users_relation from './endpoints/users/relation.js';
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
import * as ep___users_search from './endpoints/users/search.js';
import * as ep___users_show from './endpoints/users/show.js';
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';

const eps = [
['admin/meta', ep___admin_meta],
Expand Down Expand Up @@ -584,7 +583,6 @@ const eps = [
['users/search-by-username-and-host', ep___users_searchByUsernameAndHost],
['users/search', ep___users_search],
['users/show', ep___users_show],
['users/update-memo', ep___users_updateMemo],
];

interface IEndpointMetaBase {
Expand Down
89 changes: 0 additions & 89 deletions packages/backend/src/server/api/endpoints/users/update-memo.ts

This file was deleted.

Loading

0 comments on commit 1fa43d4

Please sign in to comment.