1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-28 06:48:36 +09:00
This commit is contained in:
syuilo 2022-09-20 05:32:18 +09:00
parent 1ed06e490c
commit 567c550120
13 changed files with 28 additions and 31 deletions

View File

@ -147,7 +147,7 @@ export class DriveService {
} }
const baseUrl = meta.objectStorageBaseUrl const baseUrl = meta.objectStorageBaseUrl
|| `${ meta.objectStorageUseSSL ? 'https' : 'http' }://${ meta.objectStorageEndpoint }${ meta.objectStoragePort ? `:${meta.objectStoragePort}` : '' }/${ meta.objectStorageBucket }`; ?? `${ meta.objectStorageUseSSL ? 'https' : 'http' }://${ meta.objectStorageEndpoint }${ meta.objectStoragePort ? `:${meta.objectStoragePort}` : '' }/${ meta.objectStorageBucket }`;
// for original // for original
const key = `${meta.objectStoragePrefix}/${uuid()}${ext}`; const key = `${meta.objectStoragePrefix}/${uuid()}${ext}`;
@ -285,7 +285,7 @@ export class DriveService {
satisfyWebpublic = !!( satisfyWebpublic = !!(
type !== 'image/svg+xml' && type !== 'image/webp' && type !== 'image/svg+xml' && type !== 'image/webp' &&
!(metadata.exif || metadata.iptc || metadata.xmp || metadata.tifftagPhotoshop) && !(metadata.exif ?? metadata.iptc ?? metadata.xmp ?? metadata.tifftagPhotoshop) &&
metadata.width && metadata.width <= 2048 && metadata.width && metadata.width <= 2048 &&
metadata.height && metadata.height <= 2048 metadata.height && metadata.height <= 2048
); );
@ -438,7 +438,7 @@ export class DriveService {
//} //}
// detect name // detect name
const detectedName = name || (info.type.ext ? `untitled.${info.type.ext}` : 'untitled'); const detectedName = name ?? (info.type.ext ? `untitled.${info.type.ext}` : 'untitled');
if (user && !force) { if (user && !force) {
// Check if there is a file with the same hash // Check if there is a file with the same hash

View File

@ -3,9 +3,9 @@
* https://en.wikipedia.org/wiki/Identicon * https://en.wikipedia.org/wiki/Identicon
*/ */
import { WriteStream } from 'node:fs';
import * as p from 'pureimage'; import * as p from 'pureimage';
import gen from 'random-seed'; import gen from 'random-seed';
import type { WriteStream } from 'node:fs';
const size = 128; // px const size = 128; // px
const n = 5; // resolution const n = 5; // resolution

View File

@ -1,15 +1,15 @@
import { Packed } from './schema.js'; import type { Packed } from './schema.js';
export function isInstanceMuted(note: Packed<'Note'>, mutedInstances: Set<string>): boolean { export function isInstanceMuted(note: Packed<'Note'>, mutedInstances: Set<string>): boolean {
if (mutedInstances.has(note?.user?.host ?? '')) return true; if (mutedInstances.has(note.user.host ?? '')) return true;
if (mutedInstances.has(note?.reply?.user?.host ?? '')) return true; if (mutedInstances.has(note.reply?.user.host ?? '')) return true;
if (mutedInstances.has(note?.renote?.user?.host ?? '')) return true; if (mutedInstances.has(note.renote?.user.host ?? '')) return true;
return false; return false;
} }
export function isUserFromMutedInstance(notif: Packed<'Notification'>, mutedInstances: Set<string>): boolean { export function isUserFromMutedInstance(notif: Packed<'Notification'>, mutedInstances: Set<string>): boolean {
if (mutedInstances.has(notif?.user?.host ?? '')) return true; if (mutedInstances.has(notif.user?.host ?? '')) return true;
return false; return false;
} }

View File

@ -1,4 +1,4 @@
import { Note } from '@/models/entities/Note.js'; import type { Note } from '@/models/entities/Note.js';
export default function(note: Note): boolean { export default function(note: Note): boolean {
return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0)); return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0));

View File

@ -1,6 +1,6 @@
import * as os from 'node:os'; import * as os from 'node:os';
import sysUtils from 'systeminformation'; import sysUtils from 'systeminformation';
import Logger from '@/core/logger.js'; import type Logger from '@/logger.js';
export async function showMachineInfo(parentLogger: Logger) { export async function showMachineInfo(parentLogger: Logger) {
const logger = parentLogger.createSubLogger('machine'); const logger = parentLogger.createSubLogger('machine');

View File

@ -1,6 +1,6 @@
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { NotesRepository, UsersRepository } from '@/models/index.js'; import { NotesRepository, UsersRepository } from '@/models/index.js';
import { IdentifiableError } from '@/misc/identifiable-error.js'; import { IdentifiableError } from '@/misc/identifiable-error.js';
import type { User } from '@/models/entities/User.js'; import type { User } from '@/models/entities/User.js';
import type { Note } from '@/models/entities/Note.js'; import type { Note } from '@/models/entities/Note.js';

View File

@ -1,9 +1,6 @@
import rndstr from 'rndstr'; import rndstr from 'rndstr';
import { Note } from '@/models/entities/Note.js'; import type { Note } from '@/models/entities/Note.js';
import { User } from '@/models/entities/User.js'; import type { User } from '@/models/entities/User.js';
import { Notes, UserProfiles, NoteReactions } from '@/models/index.js';
import { generateMutedUserQuery } from './generate-muted-user-query.js';
import { generateBlockedUserQuery } from './generate-block-query.js';
// TODO: リアクション、Renote、返信などをしたートは除外する // TODO: リアクション、Renote、返信などをしたートは除外する
@ -21,9 +18,9 @@ export async function injectFeatured(timeline: Note[], user?: User | null) {
const query = Notes.createQueryBuilder('note') const query = Notes.createQueryBuilder('note')
.addSelect('note.score') .addSelect('note.score')
.where('note.userHost IS NULL') .where('note.userHost IS NULL')
.andWhere(`note.score > 0`) .andWhere('note.score > 0')
.andWhere(`note.createdAt > :date`, { date: new Date(Date.now() - day) }) .andWhere('note.createdAt > :date', { date: new Date(Date.now() - day) })
.andWhere(`note.visibility = 'public'`) .andWhere('note.visibility = \'public\'')
.innerJoinAndSelect('note.user', 'user'); .innerJoinAndSelect('note.user', 'user');
if (user) { if (user) {

View File

@ -1,7 +1,6 @@
import rndstr from 'rndstr'; import rndstr from 'rndstr';
import { Note } from '@/models/entities/Note.js'; import type { Note } from '@/models/entities/Note.js';
import { User } from '@/models/entities/User.js'; import type { User } from '@/models/entities/User.js';
import { PromoReads, PromoNotes, Notes, Users } from '@/models/index.js';
export async function injectPromo(timeline: Note[], user?: User | null) { export async function injectPromo(timeline: Note[], user?: User | null) {
if (timeline.length < 5) return; if (timeline.length < 5) return;

View File

@ -25,7 +25,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const ep = endpoints.find(x => x.name === ps.endpoint); const ep = endpoints.find(x => x.name === ps.endpoint);
if (ep == null) return null; if (ep == null) return null;
return { return {
params: Object.entries(ep.params.properties || {}).map(([k, v]) => ({ params: Object.entries(ep.params.properties ?? {}).map(([k, v]) => ({
name: k, name: k,
type: v.type.charAt(0).toUpperCase() + v.type.slice(1), type: v.type.charAt(0).toUpperCase() + v.type.slice(1),
})), })),

View File

@ -53,9 +53,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const mutedNotes = await this.notesRepository.find({ const mutedNotes = await this.notesRepository.find({
where: [{ where: [{
id: note.threadId || note.id, id: note.threadId ?? note.id,
}, { }, {
threadId: note.threadId || note.id, threadId: note.threadId ?? note.id,
}], }],
}); });
@ -64,7 +64,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
await this.noteThreadMutingsRepository.insert({ await this.noteThreadMutingsRepository.insert({
id: this.idService.genId(), id: this.idService.genId(),
createdAt: new Date(), createdAt: new Date(),
threadId: note.threadId || note.id, threadId: note.threadId ?? note.id,
userId: me.id, userId: me.id,
}); });
}); });

View File

@ -45,7 +45,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}); });
await this.noteThreadMutingsRepository.delete({ await this.noteThreadMutingsRepository.delete({
threadId: note.threadId || note.id, threadId: note.threadId ?? note.id,
userId: me.id, userId: me.id,
}); });
}); });

View File

@ -1,4 +1,5 @@
import { refs, Schema } from '@/misc/schema.js'; import type { Schema } from '@/misc/schema.js';
import { refs } from '@/misc/schema.js';
export function convertSchemaToOpenApiSchema(schema: Schema) { export function convertSchemaToOpenApiSchema(schema: Schema) {
const res: any = schema; const res: any = schema;
@ -55,6 +56,6 @@ export const schemas = {
}, },
...Object.fromEntries( ...Object.fromEntries(
Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]) Object.entries(refs).map(([key, schema]) => [key, convertSchemaToOpenApiSchema(schema)]),
), ),
}; };

View File

@ -38,7 +38,7 @@ module.exports = {
'vue/no-multi-spaces': ['error', { 'vue/no-multi-spaces': ['error', {
'ignoreProperties': false, 'ignoreProperties': false,
}], }],
'vue/no-v-html': 'error', 'vue/no-v-html': 'warn',
'vue/order-in-components': 'error', 'vue/order-in-components': 'error',
'vue/html-indent': ['warn', 'tab', { 'vue/html-indent': ['warn', 'tab', {
'attribute': 1, 'attribute': 1,