This commit is contained in:
fly_mc 2024-10-02 14:44:30 +08:00
parent 83e77d241b
commit 90c2f2c149
13 changed files with 39 additions and 21 deletions

View file

@ -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) {

View file

@ -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,

View file

@ -59,6 +59,8 @@ export class EmailService {
} : undefined,
} as any);
const siteName = meta.name || this.config.host;
const htmlContent = `<!doctype html>
<html>
<head>
@ -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 {
</footer>
</main>
<nav>
<a href="${ this.config.url }">${ this.config.host }</a>
<a href="${ this.config.url }">${ siteName }</a>
</nav>
</body>
</html>`;
@ -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,
});

View file

@ -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';
}
}

View file

@ -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]) {

View file

@ -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;

View file

@ -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');

View file

@ -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<typeof meta, typeof paramDef> { // eslint-
}
}
if (ps.localHostOnly) {
query.andWhere('note.userHost IS NULL');
}
// Search notes
const notes = await query.limit(ps.limit).getMany();

View file

@ -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');

View file

@ -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')), {}, {

View file

@ -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'];

View file

@ -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[][];

View file

@ -36,7 +36,7 @@ async function offlineContentHTML() {
reload: i18n.ts?.reload ?? 'Reload',
};
return `<!DOCTYPE html><html lang="ja"><head><meta charset="UTF-8"><meta content="width=device-width,initial-scale=1"name="viewport"><title>${messages.title}</title><style>body{background-color:#0c1210;color:#dee7e4;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;margin:0;padding:24px;box-sizing:border-box}.icon{max-width:120px;width:100%;height:auto;margin-bottom:20px;}.message{text-align:center;font-size:20px;font-weight:700;margin-bottom:20px}.version{text-align:center;font-size:90%;margin-bottom:20px}button{padding:7px 14px;min-width:100px;font-weight:700;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;border-radius:99rem;background-color:#b4e900;color:#192320;border:none;cursor:pointer;-webkit-tap-highlight-color:transparent}button:hover{background-color:#c6ff03}</style></head><body><svg class="icon"fill="none"height="24"stroke="currentColor"stroke-linecap="round"stroke-linejoin="round"stroke-width="2"viewBox="0 0 24 24"width="24"xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z"fill="none"stroke="none"/><path d="M9.58 5.548c.24 -.11 .492 -.207 .752 -.286c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 .957 -.383 1.824 -1.003 2.454m-2.997 1.033h-11.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.13 -.582 .37 -1.128 .7 -1.62"/><path d="M3 3l18 18"/></svg><div class="message">${messages.header}</div><div class="version">v${_VERSION_}</div><button onclick="reloadPage()">${messages.reload}</button><script>function reloadPage(){location.reload(!0)}</script></body></html>`;
return `<!DOCTYPE html><html lang="ja"><head><meta charset="UTF-8"><meta content="width=device-width,initial-scale=1"name="viewport"><title>${messages.title}</title><style>body{background-color:#0c1210;color:#dee7e4;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:100vh;margin:0;padding:24px;box-sizing:border-box}.icon{max-width:120px;width:100%;height:auto;margin-bottom:20px;}.message{text-align:center;font-size:20px;font-weight:700;margin-bottom:20px}.version{text-align:center;font-size:90%;margin-bottom:20px}button{padding:7px 14px;min-width:100px;font-weight:700;font-family:Hiragino Maru Gothic Pro,BIZ UDGothic,Roboto,HelveticaNeue,Arial,sans-serif;line-height:1.35;border-radius:99rem;background-color:#ff82ab;color:#192320;border:none;cursor:pointer;-webkit-tap-highlight-color:transparent}button:hover{background-color:#fac5eb}</style></head><body><svg class="icon"fill="none"height="24"stroke="currentColor"stroke-linecap="round"stroke-linejoin="round"stroke-width="2"viewBox="0 0 24 24"width="24"xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0z"fill="none"stroke="none"/><path d="M9.58 5.548c.24 -.11 .492 -.207 .752 -.286c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 .957 -.383 1.824 -1.003 2.454m-2.997 1.033h-11.343c-2.572 -.004 -4.657 -2.011 -4.657 -4.487c0 -2.475 2.085 -4.482 4.657 -4.482c.13 -.582 .37 -1.128 .7 -1.62"/><path d="M3 3l18 18"/></svg><div class="message">${messages.header}</div><div class="version">v${_VERSION_}</div><button onclick="reloadPage()">${messages.reload}</button><script>function reloadPage(){location.reload(!0)}</script></body></html>`;
}
globalThis.addEventListener('fetch', ev => {