mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 00:49:17 +09:00
refactor(ApImageService.ts
): 冗長だった部分を短く
This commit is contained in:
parent
1454d04c37
commit
67f9d9db4c
@ -62,7 +62,7 @@ export class ApImageService {
|
|||||||
|
|
||||||
const instance = await this.metaService.fetch();
|
const instance = await this.metaService.fetch();
|
||||||
|
|
||||||
let file = await this.driveService.uploadFromUrl({
|
const file = await this.driveService.uploadFromUrl({
|
||||||
url: image.url,
|
url: image.url,
|
||||||
user: actor,
|
user: actor,
|
||||||
uri: image.url,
|
uri: image.url,
|
||||||
@ -70,21 +70,11 @@ export class ApImageService {
|
|||||||
isLink: !instance.cacheRemoteFiles,
|
isLink: !instance.cacheRemoteFiles,
|
||||||
comment: truncate(image.name ?? undefined, DB_MAX_IMAGE_COMMENT_LENGTH),
|
comment: truncate(image.name ?? undefined, DB_MAX_IMAGE_COMMENT_LENGTH),
|
||||||
});
|
});
|
||||||
|
if (!file.isLink || file.url === image.url) return file;
|
||||||
|
|
||||||
if (file.isLink) {
|
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、URLを更新する
|
||||||
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、
|
await this.driveFilesRepository.update({ id: file.id }, { url: image.url, uri: image.url });
|
||||||
// URLを更新する
|
return await this.driveFilesRepository.findOneByOrFail({ id: file.id });
|
||||||
if (file.url !== image.url) {
|
|
||||||
await this.driveFilesRepository.update({ id: file.id }, {
|
|
||||||
url: image.url,
|
|
||||||
uri: image.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
file = await this.driveFilesRepository.findOneByOrFail({ id: file.id });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user