mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 19:43:09 +02:00
Resolve #2600
This commit is contained in:
parent
35f91fa280
commit
a7237d157a
1 changed files with 17 additions and 2 deletions
|
@ -2,7 +2,7 @@ import * as debug from 'debug';
|
|||
|
||||
import uploadFromUrl from '../../../services/drive/upload-from-url';
|
||||
import { IRemoteUser } from '../../../models/user';
|
||||
import { IDriveFile } from '../../../models/drive-file';
|
||||
import DriveFile, { IDriveFile } from '../../../models/drive-file';
|
||||
import Resolver from '../resolver';
|
||||
|
||||
const log = debug('misskey:activitypub');
|
||||
|
@ -24,7 +24,22 @@ export async function createImage(actor: IRemoteUser, value: any): Promise<IDriv
|
|||
|
||||
log(`Creating the Image: ${image.url}`);
|
||||
|
||||
return await uploadFromUrl(image.url, actor, null, image.url, image.sensitive);
|
||||
let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive);
|
||||
|
||||
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、
|
||||
// URLを更新する
|
||||
if (file.metadata.url !== image.url) {
|
||||
file = await DriveFile.findOneAndUpdate({ _id: file._id }, {
|
||||
$set: {
|
||||
'metadata.url': image.url,
|
||||
'metadata.uri': image.url
|
||||
}
|
||||
}, {
|
||||
returnNewDocument: true
|
||||
});
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue