refactor: migrate to typeorm 3.0 (#8443)
* wip * wip * wip * Update following.ts * wip * wip * wip * Update resolve-user.ts * maxQueryExecutionTime * wip * wip
This commit is contained in:
parent
41c87074e6
commit
1c67c26bd8
325 changed files with 1314 additions and 1494 deletions
|
|
@ -6,7 +6,7 @@ import { toDbReaction, decodeReaction } from '@/misc/reaction-lib.js';
|
|||
import { User, IRemoteUser } from '@/models/entities/user.js';
|
||||
import { Note } from '@/models/entities/note.js';
|
||||
import { NoteReactions, Users, NoteWatchings, Notes, Emojis, Blockings } from '@/models/index.js';
|
||||
import { Not } from 'typeorm';
|
||||
import { IsNull, Not } from 'typeorm';
|
||||
import { perUserReactionsChart } from '@/services/chart/index.js';
|
||||
import { genId } from '@/misc/gen-id.js';
|
||||
import { createNotification } from '../../create-notification.js';
|
||||
|
|
@ -18,7 +18,7 @@ import { IdentifiableError } from '@/misc/identifiable-error.js';
|
|||
export default async (user: { id: User['id']; host: User['host']; }, note: Note, reaction?: string) => {
|
||||
// Check blocking
|
||||
if (note.userId !== user.id) {
|
||||
const block = await Blockings.findOne({
|
||||
const block = await Blockings.findOneBy({
|
||||
blockerId: note.userId,
|
||||
blockeeId: user.id,
|
||||
});
|
||||
|
|
@ -43,7 +43,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
await NoteReactions.insert(record);
|
||||
} catch (e) {
|
||||
if (isDuplicateKeyValueError(e)) {
|
||||
const exists = await NoteReactions.findOneOrFail({
|
||||
const exists = await NoteReactions.findOneByOrFail({
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
@ -79,7 +79,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
const emoji = await Emojis.findOne({
|
||||
where: {
|
||||
name: decodedReaction.name,
|
||||
host: decodedReaction.host,
|
||||
host: decodedReaction.host ?? IsNull(),
|
||||
},
|
||||
select: ['name', 'host', 'originalUrl', 'publicUrl'],
|
||||
});
|
||||
|
|
@ -103,7 +103,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
}
|
||||
|
||||
// Fetch watchers
|
||||
NoteWatchings.find({
|
||||
NoteWatchings.findBy({
|
||||
noteId: note.id,
|
||||
userId: Not(user.id),
|
||||
}).then(watchers => {
|
||||
|
|
@ -121,7 +121,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note,
|
|||
const content = renderActivity(await renderLike(record, note));
|
||||
const dm = new DeliverManager(user, content);
|
||||
if (note.userHost !== null) {
|
||||
const reactee = await Users.findOne(note.userId);
|
||||
const reactee = await Users.findOneBy({ id: note.userId });
|
||||
dm.addDirectRecipe(reactee as IRemoteUser);
|
||||
}
|
||||
dm.addFollowersRecipe();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { decodeReaction } from '@/misc/reaction-lib.js';
|
|||
|
||||
export default async (user: { id: User['id']; host: User['host']; }, note: Note) => {
|
||||
// if already unreacted
|
||||
const exist = await NoteReactions.findOne({
|
||||
const exist = await NoteReactions.findOneBy({
|
||||
noteId: note.id,
|
||||
userId: user.id,
|
||||
});
|
||||
|
|
@ -48,7 +48,7 @@ export default async (user: { id: User['id']; host: User['host']; }, note: Note)
|
|||
const content = renderActivity(renderUndo(await renderLike(exist, note), user));
|
||||
const dm = new DeliverManager(user, content);
|
||||
if (note.userHost !== null) {
|
||||
const reactee = await Users.findOne(note.userId);
|
||||
const reactee = await Users.findOneBy({ id: note.userId });
|
||||
dm.addDirectRecipe(reactee as IRemoteUser);
|
||||
}
|
||||
dm.addFollowersRecipe();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue