Refactor: Better variable name
This commit is contained in:
		
							parent
							
								
									f79e05195b
								
							
						
					
					
						commit
						a6f63e055a
					
				
					 1 changed files with 13 additions and 13 deletions
				
			
		| 
						 | 
					@ -27,44 +27,44 @@ class Creator {
 | 
				
			||||||
		this.distribute = distribute;
 | 
							this.distribute = distribute;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private async createImage(object) {
 | 
						private async createImage(image) {
 | 
				
			||||||
		if ('attributedTo' in object && this.actor.account.uri !== object.attributedTo) {
 | 
							if ('attributedTo' in image && this.actor.account.uri !== image.attributedTo) {
 | 
				
			||||||
			throw new Error();
 | 
								throw new Error();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const { _id } = await uploadFromUrl(object.url, this.actor);
 | 
							const { _id } = await uploadFromUrl(image.url, this.actor);
 | 
				
			||||||
		return createRemoteUserObject('driveFiles.files', _id, object);
 | 
							return createRemoteUserObject('driveFiles.files', _id, image);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private async createNote(resolver: Resolver, object) {
 | 
						private async createNote(resolver: Resolver, note) {
 | 
				
			||||||
		if ('attributedTo' in object && this.actor.account.uri !== object.attributedTo) {
 | 
							if ('attributedTo' in note && this.actor.account.uri !== note.attributedTo) {
 | 
				
			||||||
			throw new Error();
 | 
								throw new Error();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const mediaIds = 'attachment' in object &&
 | 
							const mediaIds = 'attachment' in note &&
 | 
				
			||||||
			(await Promise.all(await this.create(resolver, object.attachment)))
 | 
								(await Promise.all(await this.create(resolver, note.attachment)))
 | 
				
			||||||
				.filter(media => media !== null && media.object.$ref === 'driveFiles.files')
 | 
									.filter(media => media !== null && media.object.$ref === 'driveFiles.files')
 | 
				
			||||||
				.map(({ object }) => object.$id);
 | 
									.map(({ object }) => object.$id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const { window } = new JSDOM(object.content);
 | 
							const { window } = new JSDOM(note.content);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const inserted = await createPost({
 | 
							const inserted = await createPost({
 | 
				
			||||||
			channelId: undefined,
 | 
								channelId: undefined,
 | 
				
			||||||
			index: undefined,
 | 
								index: undefined,
 | 
				
			||||||
			createdAt: new Date(object.published),
 | 
								createdAt: new Date(note.published),
 | 
				
			||||||
			mediaIds,
 | 
								mediaIds,
 | 
				
			||||||
			replyId: undefined,
 | 
								replyId: undefined,
 | 
				
			||||||
			repostId: undefined,
 | 
								repostId: undefined,
 | 
				
			||||||
			poll: undefined,
 | 
								poll: undefined,
 | 
				
			||||||
			text: window.document.body.textContent,
 | 
								text: window.document.body.textContent,
 | 
				
			||||||
			textHtml: object.content && createDOMPurify(window).sanitize(object.content),
 | 
								textHtml: note.content && createDOMPurify(window).sanitize(note.content),
 | 
				
			||||||
			userId: this.actor._id,
 | 
								userId: this.actor._id,
 | 
				
			||||||
			appId: null,
 | 
								appId: null,
 | 
				
			||||||
			viaMobile: false,
 | 
								viaMobile: false,
 | 
				
			||||||
			geo: undefined
 | 
								geo: undefined
 | 
				
			||||||
		}, null, null, []);
 | 
							}, null, null, []);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const promisedRemoteUserObject = createRemoteUserObject('posts', inserted._id, object);
 | 
							const promisedRemoteUserObject = createRemoteUserObject('posts', inserted._id, note);
 | 
				
			||||||
		const promises = [];
 | 
							const promises = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (this.distribute) {
 | 
							if (this.distribute) {
 | 
				
			||||||
| 
						 | 
					@ -72,7 +72,7 @@ class Creator {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Register to search database
 | 
							// Register to search database
 | 
				
			||||||
		if (object.content && config.elasticsearch.enable) {
 | 
							if (note.content && config.elasticsearch.enable) {
 | 
				
			||||||
			const es = require('../../db/elasticsearch');
 | 
								const es = require('../../db/elasticsearch');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			promises.push(new Promise((resolve, reject) => {
 | 
								promises.push(new Promise((resolve, reject) => {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue