mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-02 16:37:36 +01:00
Merge pull request #1387 from akihikodaki/duplicate
Always deduplicate Activity Streams objects by id
This commit is contained in:
commit
507159916d
1 changed files with 28 additions and 28 deletions
|
@ -105,36 +105,36 @@ class Creator {
|
||||||
const collection = await parentResolver.resolveCollection(value);
|
const collection = await parentResolver.resolveCollection(value);
|
||||||
|
|
||||||
return collection.object.map(async element => {
|
return collection.object.map(async element => {
|
||||||
if (typeof element === 'string') {
|
const uri = element.id || element;
|
||||||
try {
|
|
||||||
await Promise.all([
|
|
||||||
DriveFile.findOne({ 'metadata.uri': element }).then(file => {
|
|
||||||
if (file === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw {
|
try {
|
||||||
$ref: 'driveFile.files',
|
await Promise.all([
|
||||||
$id: file._id
|
DriveFile.findOne({ 'metadata.uri': uri }).then(file => {
|
||||||
};
|
if (file === null) {
|
||||||
}, () => {}),
|
return;
|
||||||
Post.findOne({ uri: element }).then(post => {
|
}
|
||||||
if (post === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw {
|
throw {
|
||||||
$ref: 'posts',
|
$ref: 'driveFile.files',
|
||||||
$id: post._id
|
$id: file._id
|
||||||
};
|
};
|
||||||
}, () => {})
|
}, () => {}),
|
||||||
]);
|
Post.findOne({ uri }).then(post => {
|
||||||
} catch (object) {
|
if (post === null) {
|
||||||
return {
|
return;
|
||||||
resolver: collection.resolver,
|
}
|
||||||
object
|
|
||||||
};
|
throw {
|
||||||
}
|
$ref: 'posts',
|
||||||
|
$id: post._id
|
||||||
|
};
|
||||||
|
}, () => {})
|
||||||
|
]);
|
||||||
|
} catch (object) {
|
||||||
|
return {
|
||||||
|
resolver: collection.resolver,
|
||||||
|
object
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { resolver, object } = await collection.resolver.resolveOne(element);
|
const { resolver, object } = await collection.resolver.resolveOne(element);
|
||||||
|
|
Loading…
Reference in a new issue