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
|
|
@ -10,6 +10,7 @@ import signin from '../common/signin.js';
|
|||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Users, UserProfiles } from '@/models/index.js';
|
||||
import { ILocalUser } from '@/models/entities/user.js';
|
||||
import { IsNull } from 'typeorm';
|
||||
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
|
|
@ -40,12 +41,12 @@ router.get('/disconnect/discord', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
delete profile.integrations.discord;
|
||||
|
||||
|
|
@ -206,7 +207,7 @@ router.get('/dc/cb', async ctx => {
|
|||
},
|
||||
});
|
||||
|
||||
signin(ctx, await Users.findOne(profile.userId) as ILocalUser, true);
|
||||
signin(ctx, await Users.findOneBy({ id: profile.userId }) as ILocalUser, true);
|
||||
} else {
|
||||
const code = ctx.query.code;
|
||||
|
||||
|
|
@ -252,12 +253,12 @@ router.get('/dc/cb', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
await UserProfiles.update(user.id, {
|
||||
integrations: {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import signin from '../common/signin.js';
|
|||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Users, UserProfiles } from '@/models/index.js';
|
||||
import { ILocalUser } from '@/models/entities/user.js';
|
||||
import { IsNull } from 'typeorm';
|
||||
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
|
|
@ -40,12 +41,12 @@ router.get('/disconnect/github', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
delete profile.integrations.github;
|
||||
|
||||
|
|
@ -184,7 +185,7 @@ router.get('/gh/cb', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
signin(ctx, await Users.findOne(link.userId) as ILocalUser, true);
|
||||
signin(ctx, await Users.findOneBy({ id: link.userId }) as ILocalUser, true);
|
||||
} else {
|
||||
const code = ctx.query.code;
|
||||
|
||||
|
|
@ -227,12 +228,12 @@ router.get('/gh/cb', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
await UserProfiles.update(user.id, {
|
||||
integrations: {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import signin from '../common/signin.js';
|
|||
import { fetchMeta } from '@/misc/fetch-meta.js';
|
||||
import { Users, UserProfiles } from '@/models/index.js';
|
||||
import { ILocalUser } from '@/models/entities/user.js';
|
||||
import { IsNull } from 'typeorm';
|
||||
|
||||
function getUserToken(ctx: Koa.BaseContext): string | null {
|
||||
return ((ctx.headers['cookie'] || '').match(/igi=(\w+)/) || [null, null])[1];
|
||||
|
|
@ -39,12 +40,12 @@ router.get('/disconnect/twitter', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
delete profile.integrations.twitter;
|
||||
|
||||
|
|
@ -143,7 +144,7 @@ router.get('/tw/cb', async ctx => {
|
|||
return;
|
||||
}
|
||||
|
||||
signin(ctx, await Users.findOne(link.userId) as ILocalUser, true);
|
||||
signin(ctx, await Users.findOneBy({ id: link.userId }) as ILocalUser, true);
|
||||
} else {
|
||||
const verifier = ctx.query.oauth_verifier;
|
||||
|
||||
|
|
@ -162,12 +163,12 @@ router.get('/tw/cb', async ctx => {
|
|||
|
||||
const result = await twAuth!.done(JSON.parse(twCtx), verifier);
|
||||
|
||||
const user = await Users.findOneOrFail({
|
||||
host: null,
|
||||
const user = await Users.findOneByOrFail({
|
||||
host: IsNull(),
|
||||
token: userToken,
|
||||
});
|
||||
|
||||
const profile = await UserProfiles.findOneOrFail(user.id);
|
||||
const profile = await UserProfiles.findOneByOrFail({ userId: user.id });
|
||||
|
||||
await UserProfiles.update(user.id, {
|
||||
integrations: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue