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,10 +105,11 @@ 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 {
 | 
								try {
 | 
				
			||||||
				await Promise.all([
 | 
									await Promise.all([
 | 
				
			||||||
						DriveFile.findOne({ 'metadata.uri': element }).then(file => {
 | 
										DriveFile.findOne({ 'metadata.uri': uri }).then(file => {
 | 
				
			||||||
						if (file === null) {
 | 
											if (file === null) {
 | 
				
			||||||
							return;
 | 
												return;
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
| 
						 | 
					@ -118,7 +119,7 @@ class Creator {
 | 
				
			||||||
							$id: file._id
 | 
												$id: file._id
 | 
				
			||||||
						};
 | 
											};
 | 
				
			||||||
					}, () => {}),
 | 
										}, () => {}),
 | 
				
			||||||
						Post.findOne({ uri: element }).then(post => {
 | 
										Post.findOne({ uri }).then(post => {
 | 
				
			||||||
						if (post === null) {
 | 
											if (post === null) {
 | 
				
			||||||
							return;
 | 
												return;
 | 
				
			||||||
						}
 | 
											}
 | 
				
			||||||
| 
						 | 
					@ -135,7 +136,6 @@ class Creator {
 | 
				
			||||||
					object
 | 
										object
 | 
				
			||||||
				};
 | 
									};
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			const { resolver, object } = await collection.resolver.resolveOne(element);
 | 
								const { resolver, object } = await collection.resolver.resolveOne(element);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue