From 90c2f2c149bb5e7df106992653217c9c809fbe18 Mon Sep 17 00:00:00 2001 From: fly_mc Date: Wed, 2 Oct 2024 14:44:30 +0800 Subject: [PATCH] fix --- packages/backend/src/boot/master.ts | 2 +- packages/backend/src/core/DriveService.ts | 10 +++++----- packages/backend/src/core/EmailService.ts | 10 ++++++---- packages/backend/src/core/NoteCreateService.ts | 3 ++- packages/backend/src/misc/correct-filename.ts | 2 +- .../processors/CleanRemoteFilesProcessorService.ts | 7 ++++++- packages/backend/src/server/FileServerService.ts | 2 +- .../src/server/api/endpoints/notes/search-by-tag.ts | 5 +++++ packages/backend/test/unit/misc/correct-filename.ts | 2 +- packages/frontend/src/boot/main-boot.ts | 4 ++-- packages/misskey-js/src/autogen/entities.ts | 2 +- packages/misskey-js/src/autogen/types.ts | 9 +++++++-- packages/sw/src/sw.ts | 2 +- 13 files changed, 39 insertions(+), 21 deletions(-) diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts index bb0c9e6c2..41fa5aba4 100644 --- a/packages/backend/src/boot/master.ts +++ b/packages/backend/src/boot/master.ts @@ -27,7 +27,7 @@ const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../../built/meta.json const logger = new Logger('core', 'cyan'); const bootLogger = logger.createSubLogger('boot', 'magenta'); -const themeColor = chalk.hex('#e1aac6'); +const themeColor = chalk.hex('#f7c3de'); function greet() { if (!envOption.quiet) { diff --git a/packages/backend/src/core/DriveService.ts b/packages/backend/src/core/DriveService.ts index c332e5a0a..79ca3baad 100644 --- a/packages/backend/src/core/DriveService.ts +++ b/packages/backend/src/core/DriveService.ts @@ -165,9 +165,9 @@ export class DriveService { // 拡張子からContent-Typeを設定してそうな挙動を示すオブジェクトストレージ (upcloud?) も存在するので、 // 許可されているファイル形式でしかURLに拡張子をつけない - if (!FILE_TYPE_BROWSERSAFE.includes(type)) { - ext = ''; - } + // if (!FILE_TYPE_BROWSERSAFE.includes(type)) { + // ext = ''; + // } const baseUrl = this.meta.objectStorageBaseUrl ?? `${ this.meta.objectStorageUseSSL ? 'https' : 'http' }://${ this.meta.objectStorageEndpoint }${ this.meta.objectStoragePort ? `:${this.meta.objectStoragePort}` : '' }/${ this.meta.objectStorageBucket }`; @@ -372,8 +372,8 @@ export class DriveService { */ @bindThis private async upload(key: string, stream: fs.ReadStream | Buffer, type: string, ext?: string | null, filename?: string) { - if (type === 'image/apng') type = 'image/png'; - if (!FILE_TYPE_BROWSERSAFE.includes(type)) type = 'application/octet-stream'; + // if (type === 'image/apng') type = 'image/png'; + // if (!FILE_TYPE_BROWSERSAFE.includes(type)) type = 'application/octet-stream'; const params = { Bucket: this.meta.objectStorageBucket, diff --git a/packages/backend/src/core/EmailService.ts b/packages/backend/src/core/EmailService.ts index a176474b9..aaad681f9 100644 --- a/packages/backend/src/core/EmailService.ts +++ b/packages/backend/src/core/EmailService.ts @@ -59,6 +59,8 @@ export class EmailService { } : undefined, } as any); + const siteName = meta.name || this.config.host; + const htmlContent = ` @@ -78,7 +80,7 @@ export class EmailService { a { text-decoration: none; - color: #86b300; + color: #fa9bcc; } a:hover { text-decoration: underline; @@ -92,7 +94,7 @@ export class EmailService { } main > header { padding: 32px; - background: #86b300; + background: #fa9bcc; } main > header > img { max-width: 128px; @@ -135,7 +137,7 @@ export class EmailService { `; @@ -147,7 +149,7 @@ export class EmailService { const info = await transporter.sendMail({ from: this.meta.email!, to: to, - subject: subject, + subject: `[${siteName}] ${subject}`, text: text, html: inlinedHtml, }); diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index 89e3eafa0..6c60b4f0d 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -257,7 +257,8 @@ export class NoteCreateService implements OnApplicationShutdown { if (this.utilityService.isKeyWordIncluded(data.cw ?? data.text ?? '', sensitiveWords)) { data.visibility = 'home'; } else if ((await this.roleService.getUserPolicies(user.id)).canPublicNote === false) { - data.visibility = 'home'; + // User are banned from creating public notes + data.visibility = 'followers'; } } diff --git a/packages/backend/src/misc/correct-filename.ts b/packages/backend/src/misc/correct-filename.ts index f7ee02781..95e1e8b03 100644 --- a/packages/backend/src/misc/correct-filename.ts +++ b/packages/backend/src/misc/correct-filename.ts @@ -25,7 +25,7 @@ const extRegExp = /\.[0-9a-zA-Z]+$/i; * extはfile-typeのextを想定 */ export function correctFilename(filename: string, ext: string | null) { - const dotExt = ext ? ext[0] === '.' ? ext : `.${ext}` : '.unknown'; + const dotExt = ext ? ext[0] === '.' ? ext : `.${ext}` : ''; const match = extRegExp.exec(filename); if (!match || !match[0]) { diff --git a/packages/backend/src/queue/processors/CleanRemoteFilesProcessorService.ts b/packages/backend/src/queue/processors/CleanRemoteFilesProcessorService.ts index 728fc9e72..9bf141027 100644 --- a/packages/backend/src/queue/processors/CleanRemoteFilesProcessorService.ts +++ b/packages/backend/src/queue/processors/CleanRemoteFilesProcessorService.ts @@ -54,7 +54,12 @@ export class CleanRemoteFilesProcessorService { cursor = files.at(-1)?.id ?? null; - await Promise.all(files.map(file => this.driveService.deleteFileSync(file, true))); + try { + await Promise.all(files.map(file => this.driveService.deleteFileSync(file, true))); + } catch (err) { + // 打印错误日志,但不终止执行 + this.logger.error('Failed to delete some cached remote files:' + (err as Error).toString()); + } deletedCount += 8; diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index 41b6d2e83..6dc765402 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -228,7 +228,7 @@ export class FileServerService { if (file.fileRole !== 'original') { const filename = rename(file.filename, { suffix: file.fileRole === 'thumbnail' ? '-thumb' : '-web', - extname: file.ext ? `.${file.ext}` : '.unknown', + extname: file.ext ? `.${file.ext}` : '', }).toString(); reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.mime) ? file.mime : 'application/octet-stream'); diff --git a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts index 626ff080c..2066fa654 100644 --- a/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts +++ b/packages/backend/src/server/api/endpoints/notes/search-by-tag.ts @@ -41,6 +41,7 @@ export const paramDef = { sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, + localHostOnly: { type: 'boolean', default: false }, tag: { type: 'string', minLength: 1 }, query: { @@ -133,6 +134,10 @@ export default class extends Endpoint { // eslint- } } + if (ps.localHostOnly) { + query.andWhere('note.userHost IS NULL'); + } + // Search notes const notes = await query.limit(ps.limit).getMany(); diff --git a/packages/backend/test/unit/misc/correct-filename.ts b/packages/backend/test/unit/misc/correct-filename.ts index c76fb4c49..a56009cb4 100644 --- a/packages/backend/test/unit/misc/correct-filename.ts +++ b/packages/backend/test/unit/misc/correct-filename.ts @@ -7,7 +7,7 @@ import { correctFilename } from '@/misc/correct-filename.js'; describe(correctFilename, () => { it('no ext to null', () => { - expect(correctFilename('test', null)).toBe('test.unknown'); + expect(correctFilename('test', null)).toBe('test'); }); it('no ext to jpg', () => { expect(correctFilename('test', 'jpg')).toBe('test.jpg'); diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index ddd47ca44..c73369ad1 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -256,7 +256,7 @@ export async function mainBoot() { // } //} //miLocalStorage.setItem('lastUsed', Date.now().toString()); - + /* const latestDonationInfoShownAt = miLocalStorage.getItem('latestDonationInfoShownAt'); const neverShowDonationInfo = miLocalStorage.getItem('neverShowDonationInfo'); if (neverShowDonationInfo !== 'true' && (createdAt.getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 3))) && !location.pathname.startsWith('/miauth')) { @@ -266,7 +266,7 @@ export async function mainBoot() { }); } } - + */ const modifiedVersionMustProminentlyOfferInAgplV3Section13Read = miLocalStorage.getItem('modifiedVersionMustProminentlyOfferInAgplV3Section13Read'); if (modifiedVersionMustProminentlyOfferInAgplV3Section13Read !== 'true' && instance.repositoryUrl !== 'https://github.com/misskey-dev/misskey') { const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSourceCodeAvailablePopup.vue')), {}, { diff --git a/packages/misskey-js/src/autogen/entities.ts b/packages/misskey-js/src/autogen/entities.ts index f0e349f0e..ca0f9cbb1 100644 --- a/packages/misskey-js/src/autogen/entities.ts +++ b/packages/misskey-js/src/autogen/entities.ts @@ -414,7 +414,7 @@ export type NotesConversationResponse = operations['notes___conversation']['resp export type NotesCreateRequest = operations['notes___create']['requestBody']['content']['application/json']; export type NotesCreateResponse = operations['notes___create']['responses']['200']['content']['application/json']; export type NotesDeleteRequest = operations['notes___delete']['requestBody']['content']['application/json']; -export type NotesUpdateRequest = operations['notes/update']['requestBody']['content']['application/json']; +export type NotesUpdateRequest = operations['notes___update']['requestBody']['content']['application/json']; export type NotesFavoritesCreateRequest = operations['notes___favorites___create']['requestBody']['content']['application/json']; export type NotesFavoritesDeleteRequest = operations['notes___favorites___delete']['requestBody']['content']['application/json']; export type NotesFeaturedRequest = operations['notes___featured']['requestBody']['content']['application/json']; diff --git a/packages/misskey-js/src/autogen/types.ts b/packages/misskey-js/src/autogen/types.ts index 1c650ba87..bfd133c72 100644 --- a/packages/misskey-js/src/autogen/types.ts +++ b/packages/misskey-js/src/autogen/types.ts @@ -2667,7 +2667,7 @@ export type paths = { * * **Credential required**: *Yes* / **Permission**: *write:notes* */ - post: operations['notes/update']; + post: operations['notes___update']; }; '/notes/favorites/create': { /** @@ -4858,6 +4858,7 @@ export type components = { canImportFollowing: boolean; canImportMuting: boolean; canImportUserLists: boolean; + canEditNote: boolean; }; ReversiGameLite: { /** Format: id */ @@ -21544,13 +21545,15 @@ export type operations = { * * **Credential required**: *Yes* / **Permission**: *write:notes* */ - 'notes/update': { + notes___update: { requestBody: { content: { 'application/json': { /** Format: misskey:id */ noteId: string; text: string; + fileIds?: string[]; + mediaIds?: string[]; cw: string | null; }; }; @@ -22463,6 +22466,8 @@ export type operations = { untilId?: string; /** @default 10 */ limit?: number; + /** @default false */ + localHostOnly?: boolean; tag?: string; /** @description The outer arrays are chained with OR, the inner arrays are chained with AND. */ query?: string[][]; diff --git a/packages/sw/src/sw.ts b/packages/sw/src/sw.ts index bf980b83a..a6e308866 100644 --- a/packages/sw/src/sw.ts +++ b/packages/sw/src/sw.ts @@ -36,7 +36,7 @@ async function offlineContentHTML() { reload: i18n.ts?.reload ?? 'Reload', }; - return `${messages.title}
${messages.header}
v${_VERSION_}
`; + return `${messages.title}
${messages.header}
v${_VERSION_}
`; } globalThis.addEventListener('fetch', ev => {