fixes
This commit is contained in:
parent
174a8b1b3e
commit
417f52359d
21 changed files with 88 additions and 70 deletions
|
@ -119,8 +119,7 @@ function loadConfigBoot(): Config {
|
||||||
if (typeof exception === 'string') {
|
if (typeof exception === 'string') {
|
||||||
configLogger.error(exception);
|
configLogger.error(exception);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
} else if ((exception as any).code === 'ENOENT') {
|
||||||
if (exception.code === 'ENOENT') {
|
|
||||||
configLogger.error('Configuration file not found', null, true);
|
configLogger.error('Configuration file not found', null, true);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ export class AntennaService implements OnApplicationShutdown {
|
||||||
this.redisSubscriber.off('message', this.onRedisMessage);
|
this.redisSubscriber.off('message', this.onRedisMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async onRedisMessage(_, data) {
|
private async onRedisMessage(_: string, data: string): Promise<void> {
|
||||||
const obj = JSON.parse(data);
|
const obj = JSON.parse(data);
|
||||||
|
|
||||||
if (obj.channel === 'internal') {
|
if (obj.channel === 'internal') {
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class ObjectStorageQueueProcessorsService {
|
||||||
public start(q: Bull.Queue) {
|
public start(q: Bull.Queue) {
|
||||||
const jobs = {
|
const jobs = {
|
||||||
deleteFile: (job) => this.deleteFileProcessorService.process(job),
|
deleteFile: (job) => this.deleteFileProcessorService.process(job),
|
||||||
cleanRemoteFiles: (job) => this.cleanRemoteFilesProcessorService.process(job),
|
cleanRemoteFiles: (job, done) => this.cleanRemoteFilesProcessorService.process(job, done),
|
||||||
} as Record<string, Bull.ProcessCallbackFunction<ObjectStorageJobData | Bull.ProcessPromiseFunction<ObjectStorageJobData>>>;
|
} as Record<string, Bull.ProcessCallbackFunction<ObjectStorageJobData | Bull.ProcessPromiseFunction<ObjectStorageJobData>>>;
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(jobs)) {
|
for (const [k, v] of Object.entries(jobs)) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ export class NodeinfoServerService {
|
||||||
router.get(nodeinfo2_0path, async ctx => {
|
router.get(nodeinfo2_0path, async ctx => {
|
||||||
const base = await cache.fetch(null, () => nodeinfo2());
|
const base = await cache.fetch(null, () => nodeinfo2());
|
||||||
|
|
||||||
delete base.software.repository;
|
delete (base as any).software.repository;
|
||||||
|
|
||||||
ctx.body = { version: '2.0', ...base };
|
ctx.body = { version: '2.0', ...base };
|
||||||
ctx.set('Cache-Control', 'public, max-age=600');
|
ctx.set('Cache-Control', 'public, max-age=600');
|
||||||
|
|
|
@ -72,7 +72,7 @@ export class StreamingApiServerService {
|
||||||
|
|
||||||
const ev = new EventEmitter();
|
const ev = new EventEmitter();
|
||||||
|
|
||||||
async function onRedisMessage(_: string, data: string) {
|
async function onRedisMessage(_: string, data: string): Promise<void> {
|
||||||
const parsed = JSON.parse(data);
|
const parsed = JSON.parse(data);
|
||||||
ev.emit(parsed.channel, parsed.message);
|
ev.emit(parsed.channel, parsed.message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { AbuseUserReportsRepository } from '@/models/index.js';
|
import type { AbuseUserReportsRepository } from '@/models/index.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { AbuseUserReportEntityService } from '@/core/entities/AbuseUserReportEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -93,6 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.abuseUserReportsRepository)
|
@Inject(DI.abuseUserReportsRepository)
|
||||||
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
private abuseUserReportsRepository: AbuseUserReportsRepository,
|
||||||
|
|
||||||
|
private abuseUserReportEntityService: AbuseUserReportEntityService,
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { QueueService } from '@/core/QueueService.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -28,6 +29,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
private userSuspendService: UserSuspendService,
|
private userSuspendService: UserSuspendService,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { UsersRepository } from '@/models/index.js';
|
import type { UsersRepository } from '@/models/index.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -27,6 +28,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
private moderationLogService: ModerationLogService,
|
private moderationLogService: ModerationLogService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import type { DriveFilesRepository } from '@/models/index.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -47,6 +48,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.driveFilesRepository)
|
@Inject(DI.driveFilesRepository)
|
||||||
private driveFilesRepository: DriveFilesRepository,
|
private driveFilesRepository: DriveFilesRepository,
|
||||||
|
|
||||||
|
private driveFileEntityService: DriveFileEntityService,
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
|
|
@ -192,12 +192,14 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
throw new ApiError(meta.errors.noSuchFile);
|
throw new ApiError(meta.errors.noSuchFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const res = file as Partial<typeof file>;
|
||||||
|
|
||||||
if (!me.isAdmin) {
|
if (!me.isAdmin) {
|
||||||
delete file.requestIp;
|
delete res.requestIp;
|
||||||
delete file.requestHeaders;
|
delete res.requestHeaders;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
return res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import type { EmojisRepository } from '@/models/index.js';
|
||||||
import type { Emoji } from '@/models/entities/Emoji.js';
|
import type { Emoji } from '@/models/entities/Emoji.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -71,6 +72,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.emojisRepository)
|
@Inject(DI.emojisRepository)
|
||||||
private emojisRepository: EmojisRepository,
|
private emojisRepository: EmojisRepository,
|
||||||
|
|
||||||
|
private emojiEntityService: EmojiEntityService,
|
||||||
private queryService: QueryService,
|
private queryService: QueryService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { URL } from 'node:url';
|
import { URL } from 'node:url';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DeliverQueue } from '@/core/queue/QueueModule.js';
|
import type { DeliverQueue } from '@/core/queue/QueueModule.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { URL } from 'node:url';
|
import { URL } from 'node:url';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { InboxQueue } from '@/core/queue/QueueModule.js';
|
import type { InboxQueue } from '@/core/queue/QueueModule.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, SystemQueue, WebhookDeliverQueue } from '@/core/queue/QueueModule.js';
|
import type { DbQueue, DeliverQueue, EndedPollNotificationQueue, InboxQueue, ObjectStorageQueue, SystemQueue, WebhookDeliverQueue } from '@/core/queue/QueueModule.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
import { UserSuspendService } from '@/core/UserSuspendService.js';
|
||||||
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
import { UserFollowingService } from '@/core/UserFollowingService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -36,6 +37,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.notificationsRepository)
|
@Inject(DI.notificationsRepository)
|
||||||
private notificationsRepository: NotificationsRepository,
|
private notificationsRepository: NotificationsRepository,
|
||||||
|
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
private userFollowingService: UserFollowingService,
|
private userFollowingService: UserFollowingService,
|
||||||
private userSuspendService: UserSuspendService,
|
private userSuspendService: UserSuspendService,
|
||||||
private moderationLogService: ModerationLogService,
|
private moderationLogService: ModerationLogService,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { NotesRepository, AntennaNotesRepository } from '@/models/index.js';
|
import type { NotesRepository, AntennaNotesRepository, AntennasRepository } from '@/models/index.js';
|
||||||
import { QueryService } from '@/core/QueryService.js';
|
import { QueryService } from '@/core/QueryService.js';
|
||||||
import { NoteReadService } from '@/core/NoteReadService.js';
|
import { NoteReadService } from '@/core/NoteReadService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const channel = await Channels.findOneBy({
|
const channel = await this.channelsRepository.findOneBy({
|
||||||
id: ps.channelId,
|
id: ps.channelId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { IsNull } from 'typeorm';
|
import { IsNull } from 'typeorm';
|
||||||
import type { InstancesRepository, NotesRepository, UsersRepository } from '@/models/index.js';
|
import type { InstancesRepository, NoteReactionsRepository, NotesRepository, UsersRepository } from '@/models/index.js';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,7 @@ export class DiscordServerService {
|
||||||
|
|
||||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||||
this.redisClient.get(sessid, async (_, state) => {
|
this.redisClient.get(sessid, async (_, state) => {
|
||||||
|
if (state == null) throw new Error('empty state');
|
||||||
res(JSON.parse(state));
|
res(JSON.parse(state));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -169,22 +170,22 @@ export class DiscordServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
||||||
oauth2!.getOAuthAccessToken(code, {
|
oauth2!.getOAuthAccessToken(code, {
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
redirect_uri,
|
redirect_uri,
|
||||||
}, (err, accessToken, refreshToken, result) => {
|
}, (err, accessToken, refreshToken, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
rej(err);
|
rej(err);
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
rej(result.error);
|
rej(result.error);
|
||||||
} else {
|
} else {
|
||||||
res({
|
res({
|
||||||
accessToken,
|
accessToken,
|
||||||
refreshToken,
|
refreshToken,
|
||||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
|
@ -230,6 +231,7 @@ export class DiscordServerService {
|
||||||
|
|
||||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||||
this.redisClient.get(userToken, async (_, state) => {
|
this.redisClient.get(userToken, async (_, state) => {
|
||||||
|
if (state == null) throw new Error('empty state');
|
||||||
res(JSON.parse(state));
|
res(JSON.parse(state));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -240,22 +242,22 @@ export class DiscordServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
const { accessToken, refreshToken, expiresDate } = await new Promise<any>((res, rej) =>
|
||||||
oauth2!.getOAuthAccessToken(code, {
|
oauth2!.getOAuthAccessToken(code, {
|
||||||
grant_type: 'authorization_code',
|
grant_type: 'authorization_code',
|
||||||
redirect_uri,
|
redirect_uri,
|
||||||
}, (err, accessToken, refreshToken, result) => {
|
}, (err, accessToken, refreshToken, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
rej(err);
|
rej(err);
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
rej(result.error);
|
rej(result.error);
|
||||||
} else {
|
} else {
|
||||||
res({
|
res({
|
||||||
accessToken,
|
accessToken,
|
||||||
refreshToken,
|
refreshToken,
|
||||||
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
expiresDate: Date.now() + Number(result.expires_in) * 1000,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
const { id, username, discriminator } = (await this.httpRequestService.getJson('https://discord.com/api/users/@me', '*/*', 10 * 1000, {
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
|
|
|
@ -157,6 +157,7 @@ export class GithubServerService {
|
||||||
|
|
||||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||||
this.redisClient.get(sessid, async (_, state) => {
|
this.redisClient.get(sessid, async (_, state) => {
|
||||||
|
if (state == null) throw new Error('empty state');
|
||||||
res(JSON.parse(state));
|
res(JSON.parse(state));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -167,17 +168,17 @@ export class GithubServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { accessToken } = await new Promise<any>((res, rej) =>
|
const { accessToken } = await new Promise<any>((res, rej) =>
|
||||||
oauth2!.getOAuthAccessToken(code, {
|
oauth2!.getOAuthAccessToken(code, {
|
||||||
redirect_uri,
|
redirect_uri,
|
||||||
}, (err, accessToken, refresh, result) => {
|
}, (err, accessToken, refresh, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
rej(err);
|
rej(err);
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
rej(result.error);
|
rej(result.error);
|
||||||
} else {
|
} else {
|
||||||
res({ accessToken });
|
res({ accessToken });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
||||||
'Authorization': `bearer ${accessToken}`,
|
'Authorization': `bearer ${accessToken}`,
|
||||||
|
@ -208,6 +209,7 @@ export class GithubServerService {
|
||||||
|
|
||||||
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
const { redirect_uri, state } = await new Promise<any>((res, rej) => {
|
||||||
this.redisClient.get(userToken, async (_, state) => {
|
this.redisClient.get(userToken, async (_, state) => {
|
||||||
|
if (state == null) throw new Error('empty state');
|
||||||
res(JSON.parse(state));
|
res(JSON.parse(state));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -218,18 +220,18 @@ export class GithubServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { accessToken } = await new Promise<any>((res, rej) =>
|
const { accessToken } = await new Promise<any>((res, rej) =>
|
||||||
oauth2!.getOAuthAccessToken(
|
oauth2!.getOAuthAccessToken(
|
||||||
code,
|
code,
|
||||||
{ redirect_uri },
|
{ redirect_uri },
|
||||||
(err, accessToken, refresh, result) => {
|
(err, accessToken, refresh, result) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
rej(err);
|
rej(err);
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
rej(result.error);
|
rej(result.error);
|
||||||
} else {
|
} else {
|
||||||
res({ accessToken });
|
res({ accessToken });
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
const { login, id } = (await this.httpRequestService.getJson('https://api.github.com/user', 'application/vnd.github.v3+json', 10 * 1000, {
|
||||||
'Authorization': `bearer ${accessToken}`,
|
'Authorization': `bearer ${accessToken}`,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
"strictPropertyInitialization": false,
|
"strictPropertyInitialization": false,
|
||||||
|
"skipLibCheck": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
|
|
Loading…
Reference in a new issue