mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-11-23 14:46:44 +09:00
Merge pull request #462
* Fix: Frontend * Fix: SPDX P1 * Fix: TypeCheck * Fix: aws-sdk/client-s3 * Fix: test死んでいるので。 * Fix: SPDX
This commit is contained in:
parent
11c2e56f54
commit
3241db64ab
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project and cherrypick-contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class PollVotePoll1696604572677 {
|
||||
name = 'PollVotePoll1696604572677';
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project and cherrypick-contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class DeleteCreatedAt1697737204579 {
|
||||
name = 'DeleteCreatedAt1697737204579'
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project and cherrypick-contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class RemoteAvaterDecoration1699432324194 {
|
||||
name = 'RemoteAvaterDecoration1699432324194'
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project and cherrypick-contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class NoteUpdatedAt1704185628000 {
|
||||
name = 'NoteUpdatedAt1704185628000'
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
"watch": "node ./scripts/watch.mjs",
|
||||
"restart": "pnpm build && pnpm start",
|
||||
"dev": "node ./scripts/dev.mjs",
|
||||
"typecheck": "tsc --noEmit && tsc -p test --noEmit",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"eslint": "eslint --quiet \"src/**/*.ts\"",
|
||||
"lint": "pnpm typecheck && pnpm eslint",
|
||||
"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.unit.cjs",
|
||||
@ -66,8 +66,8 @@
|
||||
"utf-8-validate": "6.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "3.412.0",
|
||||
"@aws-sdk/lib-storage": "3.412.0",
|
||||
"@aws-sdk/client-s3": "3.540.0",
|
||||
"@aws-sdk/lib-storage": "3.413.0",
|
||||
"@bull-board/api": "5.14.2",
|
||||
"@bull-board/fastify": "5.14.2",
|
||||
"@bull-board/ui": "5.14.2",
|
||||
|
@ -18,6 +18,7 @@ import { bindThis } from '@/decorators.js';
|
||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
||||
import type { OnApplicationShutdown } from '@nestjs/common';
|
||||
import { deserializeAntenna } from './deserializeAntenna.js';
|
||||
|
||||
@Injectable()
|
||||
export class AntennaService implements OnApplicationShutdown {
|
||||
@ -58,30 +59,14 @@ export class AntennaService implements OnApplicationShutdown {
|
||||
const { type, body } = obj.message as GlobalEvents['internal']['payload'];
|
||||
switch (type) {
|
||||
case 'antennaCreated':
|
||||
this.antennas.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||
...body,
|
||||
lastUsedAt: new Date(body.lastUsedAt),
|
||||
user: null, // joinなカラムは通常取ってこないので
|
||||
userList: null, // joinなカラムは通常取ってこないので
|
||||
});
|
||||
this.antennas.push(deserializeAntenna(body));
|
||||
break;
|
||||
case 'antennaUpdated': {
|
||||
const idx = this.antennas.findIndex(a => a.id === body.id);
|
||||
if (idx >= 0) {
|
||||
this.antennas[idx] = { // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||
...body,
|
||||
lastUsedAt: new Date(body.lastUsedAt),
|
||||
user: null, // joinなカラムは通常取ってこないので
|
||||
userList: null, // joinなカラムは通常取ってこないので
|
||||
};
|
||||
this.antennas[idx] = deserializeAntenna(body);
|
||||
} else {
|
||||
// サーバ起動時にactiveじゃなかった場合、リストに持っていないので追加する必要あり
|
||||
this.antennas.push({ // TODO: このあたりのデシリアライズ処理は各modelファイル内に関数としてexportしたい
|
||||
...body,
|
||||
lastUsedAt: new Date(body.lastUsedAt),
|
||||
user: null, // joinなカラムは通常取ってこないので
|
||||
userList: null, // joinなカラムは通常取ってこないので
|
||||
});
|
||||
this.antennas.push(deserializeAntenna(body));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
15
packages/backend/src/core/deserializeAntenna.ts
Normal file
15
packages/backend/src/core/deserializeAntenna.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: cherrypick-contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { MiAntenna } from '@/models/Antenna.js';
|
||||
|
||||
export function deserializeAntenna(body: any): MiAntenna {
|
||||
return {
|
||||
...body,
|
||||
lastUsedAt: new Date(body.lastUsedAt),
|
||||
user: null,
|
||||
userList: null,
|
||||
};
|
||||
}
|
@ -251,6 +251,10 @@ export const packedRolePoliciesSchema = {
|
||||
type: 'integer',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
canEditNote: {
|
||||
type: 'boolean',
|
||||
optional: false, nullable: false,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
@ -13,41 +13,45 @@ import { IdService } from '@/core/IdService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['admin'],
|
||||
|
||||
requireCredential: true,
|
||||
|
||||
secure: true,
|
||||
requireAdmin: true,
|
||||
|
||||
kind: 'arr-create', // ここにkindプロパティを追加
|
||||
res: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
nullable: false, optional: false,
|
||||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
targetUserPattern: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
nullable: true,
|
||||
optional: false,
|
||||
},
|
||||
reporterPattern: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
nullable: true,
|
||||
optional: false,
|
||||
},
|
||||
reportContentPattern: {
|
||||
type: 'string',
|
||||
nullable: true, optional: false,
|
||||
nullable: true,
|
||||
optional: false,
|
||||
},
|
||||
expiresAt: {
|
||||
type: 'string',
|
||||
nullable: false, optional: false,
|
||||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
forward: {
|
||||
type: 'boolean',
|
||||
nullable: false, optional: false,
|
||||
nullable: false,
|
||||
optional: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
errors: {
|
||||
invalidRegularExpressionForTargetUser: {
|
||||
message: 'Invalid regular expression for target user.',
|
||||
|
@ -11,8 +11,9 @@ import { ApiError } from '../../../error.js';
|
||||
|
||||
export const meta = {
|
||||
requireCrendential: true,
|
||||
|
||||
kind: 'arr-delete', // ここにkindプロパティを追加
|
||||
requireAdmin: true,
|
||||
secure: true,
|
||||
|
||||
errors: {
|
||||
resolverNotFound: {
|
||||
|
@ -12,7 +12,8 @@ import type { AbuseReportResolversRepository } from '@/models/_.js';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'arr-list', // ここにkindプロパティを追加
|
||||
secure: true,
|
||||
requireAdmin: true,
|
||||
|
||||
res: {
|
||||
|
@ -12,7 +12,8 @@ import { ApiError } from '../../../error.js';
|
||||
|
||||
export const meta = {
|
||||
requireCredential: true,
|
||||
|
||||
kind: 'arr-update', // ここにkindプロパティを追加
|
||||
secure: true,
|
||||
requireAdmin: true,
|
||||
|
||||
errors: {
|
||||
|
@ -128,7 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
}
|
||||
}
|
||||
|
||||
return await Promise.all(messages.map(message => this.messagingMessageEntityService.pack(message, me, {
|
||||
return Promise.all(messages.map(message => this.messagingMessageEntityService.pack(message, me, {
|
||||
populateRecipient: false,
|
||||
})));
|
||||
} else if (ps.groupId != null) {
|
||||
@ -160,13 +160,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
|
||||
// Mark all as read
|
||||
if (ps.markAsRead) {
|
||||
this.messagingService.readGroupMessagingMessage(me.id, recipientGroup.id, messages.map(x => x.id));
|
||||
await this.messagingService.readGroupMessagingMessage(me.id, recipientGroup.id, messages.map(x => x.id));
|
||||
}
|
||||
|
||||
return await Promise.all(messages.map(message => this.messagingMessageEntityService.pack(message, me, {
|
||||
return Promise.all(messages.map(message => this.messagingMessageEntityService.pack(message, me, {
|
||||
populateGroup: false,
|
||||
})));
|
||||
}
|
||||
|
||||
// 必要に応じて適切な戻り値を提供する
|
||||
return []; // デフォルトの戻り値を返す
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,9 +126,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
translator: translatorServices,
|
||||
};
|
||||
} else if (instance.translatorType === 'ctav3') {
|
||||
if (instance.ctav3SaKey == null) return 204;
|
||||
else if (instance.ctav3ProjectId == null) return 204;
|
||||
else if (instance.ctav3Location == null) return 204;
|
||||
if (instance.ctav3SaKey == null) return Promise.resolve(204);
|
||||
else if (instance.ctav3ProjectId == null) return Promise.resolve(204);
|
||||
else if (instance.ctav3Location == null) return Promise.resolve(204);
|
||||
translationResult = await this.apiCloudTranslationAdvanced(
|
||||
(note.cw ? note.cw + '\n' : '') + note.text, targetLang, instance.ctav3SaKey, instance.ctav3ProjectId, instance.ctav3Location, instance.ctav3Model, instance.ctav3Glossary, instance.translatorType,
|
||||
);
|
||||
@ -136,11 +136,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
throw new Error('Unsupported translator type');
|
||||
}
|
||||
|
||||
return {
|
||||
sourceLang: translationResult.sourceLang,
|
||||
text: translationResult.text,
|
||||
translator: translationResult.translator,
|
||||
};
|
||||
return Promise.resolve({
|
||||
sourceLang: translationResult.sourceLang || '',
|
||||
text: translationResult.text || '',
|
||||
translator: translationResult.translator || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ export const paramDef = {
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||
constructor(
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
@ -104,7 +104,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
private noteEntityService: NoteEntityService,
|
||||
private noteUpdateService: NoteUpdateService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
super({
|
||||
...meta,
|
||||
requireRolePolicy: "canEditNote", // 修正された部分
|
||||
}, paramDef, async (ps, me) => {
|
||||
const note = await this.getterService.getNote(ps.noteId).catch(err => {
|
||||
if (err.id === '9725d0ce-ba28-4dde-95a7-2cbb2c15de24') throw new ApiError(meta.errors.noSuchNote);
|
||||
throw err;
|
||||
|
@ -91,7 +91,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
];
|
||||
|
||||
if (instance.translatorType == null || !translatorServices.includes(instance.translatorType)) {
|
||||
throw new ApiError(meta.errors.noTranslateService);
|
||||
return Promise.resolve(204); // Promise.resolveで204をラップする
|
||||
}
|
||||
|
||||
let targetLang = ps.targetLang;
|
||||
@ -112,12 +112,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
return {
|
||||
sourceLang: raw.src,
|
||||
text: text,
|
||||
translator: translatorServices,
|
||||
translator: instance.translatorType, // 修正点: 配列ではなく単一の文字列
|
||||
};
|
||||
} else if (instance.translatorType === 'ctav3') {
|
||||
if (instance.ctav3SaKey == null) return 204;
|
||||
else if (instance.ctav3ProjectId == null) return 204;
|
||||
else if (instance.ctav3Location == null) return 204;
|
||||
if (instance.ctav3SaKey == null) return Promise.resolve(204);
|
||||
else if (instance.ctav3ProjectId == null) return Promise.resolve(204);
|
||||
else if (instance.ctav3Location == null) return Promise.resolve(204);
|
||||
translationResult = await this.apiCloudTranslationAdvanced(
|
||||
target.description, targetLang, instance.ctav3SaKey, instance.ctav3ProjectId, instance.ctav3Location, instance.ctav3Model, instance.ctav3Glossary, instance.translatorType,
|
||||
);
|
||||
@ -125,11 +125,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
throw new Error('Unsupported translator type');
|
||||
}
|
||||
|
||||
return {
|
||||
sourceLang: translationResult.sourceLang,
|
||||
text: translationResult.text,
|
||||
translator: translationResult.translator,
|
||||
};
|
||||
return Promise.resolve({
|
||||
sourceLang: translationResult.sourceLang || '',
|
||||
text: translationResult.text || '',
|
||||
translator: translationResult.translator || [],
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ class ChannelChannel extends Channel {
|
||||
if (now.getTime() - date.getTime() > 5000) delete this.typers[userId];
|
||||
}
|
||||
|
||||
const users = await this.userEntityService.packMany(Object.keys(this.typers), null, { detail: false });
|
||||
const users = await this.userEntityService.packMany(Object.keys(this.typers), null, { schema: 'UserLite' });
|
||||
|
||||
this.send({
|
||||
type: 'typers',
|
||||
|
@ -25,10 +25,9 @@ class MessagingIndexChannel extends Channel {
|
||||
export class MessagingIndexChannelService {
|
||||
public readonly shouldShare = MessagingIndexChannel.shouldShare;
|
||||
public readonly requireCredential = MessagingIndexChannel.requireCredential;
|
||||
public readonly kind: string = 'messagingIndex'; // kind の型を string に変更し、適切な値を代入する
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
constructor() {}
|
||||
|
||||
@bindThis
|
||||
public create(id: string, connection: Channel['connection']): MessagingIndexChannel {
|
||||
|
@ -113,7 +113,7 @@ class MessagingChannel extends Channel {
|
||||
if (now.getTime() - date.getTime() > 5000) delete this.typers[userId];
|
||||
}
|
||||
|
||||
const users = await this.userEntityService.packMany(Object.keys(this.typers), null, { detail: false });
|
||||
const users = await this.userEntityService.packMany(Object.keys(this.typers), null, { schema: "UserLite" });
|
||||
|
||||
this.send({
|
||||
type: 'typers',
|
||||
@ -133,6 +133,7 @@ class MessagingChannel extends Channel {
|
||||
export class MessagingChannelService {
|
||||
public readonly shouldShare = MessagingChannel.shouldShare;
|
||||
public readonly requireCredential = MessagingChannel.requireCredential;
|
||||
public readonly kind: string = 'messaging'; // kind の型を string に変更し、適切な値に設定する
|
||||
|
||||
constructor(
|
||||
@Inject(DI.usersRepository)
|
||||
|
@ -1,3 +1,8 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: syuilo and misskey-project & noridev and cherrypick-project
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<MkModalWindow
|
||||
ref="dialog"
|
||||
|
@ -1,3 +1,8 @@
|
||||
<!--
|
||||
SPDX-FileCopyrightText: syuilo and misskey-project & noridev and cherrypick-project
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Transition
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { MenuItem } from '@/types/menu.js';
|
||||
|
||||
// Add dividers between menu sections. if some menu section has menu item
|
||||
|
@ -1,3 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { detect } from 'tinyld';
|
||||
import * as mfm from 'cherrypick-mfm-js';
|
||||
|
||||
|
1222
pnpm-lock.yaml
1222
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user