enhance(backend): ファイル種別が判定できない場合、拡張子を参照するように
This commit is contained in:
parent
836ed98c54
commit
4fcb80bcf2
|
@ -469,6 +469,7 @@ export class DriveService {
|
||||||
if (user && this.meta.sensitiveMediaDetection === 'remote' && this.userEntityService.isLocalUser(user)) skipNsfwCheck = true;
|
if (user && this.meta.sensitiveMediaDetection === 'remote' && this.userEntityService.isLocalUser(user)) skipNsfwCheck = true;
|
||||||
|
|
||||||
const info = await this.fileInfoService.getFileInfo(path, {
|
const info = await this.fileInfoService.getFileInfo(path, {
|
||||||
|
fileName: name,
|
||||||
skipSensitiveDetection: skipNsfwCheck,
|
skipSensitiveDetection: skipNsfwCheck,
|
||||||
sensitiveThreshold: // 感度が高いほどしきい値は低くすることになる
|
sensitiveThreshold: // 感度が高いほどしきい値は低くすることになる
|
||||||
this.meta.sensitiveMediaDetectionSensitivity === 'veryHigh' ? 0.1 :
|
this.meta.sensitiveMediaDetectionSensitivity === 'veryHigh' ? 0.1 :
|
||||||
|
|
|
@ -64,6 +64,7 @@ export class FileInfoService {
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getFileInfo(path: string, opts: {
|
public async getFileInfo(path: string, opts: {
|
||||||
|
fileName?: string | null;
|
||||||
skipSensitiveDetection: boolean;
|
skipSensitiveDetection: boolean;
|
||||||
sensitiveThreshold?: number;
|
sensitiveThreshold?: number;
|
||||||
sensitiveThresholdForPorn?: number;
|
sensitiveThresholdForPorn?: number;
|
||||||
|
@ -76,6 +77,26 @@ export class FileInfoService {
|
||||||
|
|
||||||
let type = await this.detectType(path);
|
let type = await this.detectType(path);
|
||||||
|
|
||||||
|
if (type.mime === TYPE_OCTET_STREAM.mime && opts.fileName != null) {
|
||||||
|
const ext = opts.fileName.split('.').pop();
|
||||||
|
if (ext === 'txt') {
|
||||||
|
type = {
|
||||||
|
mime: 'text/plain',
|
||||||
|
ext: 'txt',
|
||||||
|
};
|
||||||
|
} else if (ext === 'csv') {
|
||||||
|
type = {
|
||||||
|
mime: 'text/csv',
|
||||||
|
ext: 'csv',
|
||||||
|
};
|
||||||
|
} else if (ext === 'json') {
|
||||||
|
type = {
|
||||||
|
mime: 'application/json',
|
||||||
|
ext: 'json',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// image dimensions
|
// image dimensions
|
||||||
let width: number | undefined;
|
let width: number | undefined;
|
||||||
let height: number | undefined;
|
let height: number | undefined;
|
||||||
|
|
Loading…
Reference in New Issue