Refactor
This commit is contained in:
		@@ -1,15 +0,0 @@
 | 
			
		||||
import { Notes } from '../models';
 | 
			
		||||
 | 
			
		||||
export default async function(userId: string, renoteId: string, excludeNoteId: string | undefined): Promise<number> {
 | 
			
		||||
	// 指定したユーザーの指定したノートのリノートがいくつあるか数える
 | 
			
		||||
	const query = Notes.createQueryBuilder('note')
 | 
			
		||||
		.where('note.userId = :userId', { userId })
 | 
			
		||||
		.andWhere('note.renoteId = :renoteId', { renoteId })
 | 
			
		||||
 | 
			
		||||
	// 指定した投稿を除く
 | 
			
		||||
	if (excludeNoteId) {
 | 
			
		||||
		query.andWhere('note.id != :excludeNoteId', { excludeNoteId })
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return await query.getCount();
 | 
			
		||||
}
 | 
			
		||||
@@ -30,7 +30,7 @@ import { isDuplicateKeyValueError } from '../../misc/is-duplicate-key-value-erro
 | 
			
		||||
import { ensure } from '../../prelude/ensure';
 | 
			
		||||
import { checkHitAntenna } from '../../misc/check-hit-antenna';
 | 
			
		||||
import { addNoteToAntenna } from '../add-note-to-antenna';
 | 
			
		||||
import countSameRenotes from '../count-same-renotes';
 | 
			
		||||
import { countSameRenotes } from '../../misc/count-same-renotes';
 | 
			
		||||
 | 
			
		||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
 | 
			
		||||
 | 
			
		||||
@@ -237,7 +237,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
 | 
			
		||||
		saveReply(data.reply, note);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	//この投稿を除く指定したユーザーによる指定したノートのリノートが存在しないとき
 | 
			
		||||
	// この投稿を除く指定したユーザーによる指定したノートのリノートが存在しないとき
 | 
			
		||||
	if (data.renote && (await countSameRenotes(user.id, data.renote.id, note.id) === 0)) {
 | 
			
		||||
		incRenoteCount(data.renote);
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ import { Note } from '../../models/entities/note';
 | 
			
		||||
import { Notes, Users, Instances } from '../../models';
 | 
			
		||||
import { notesChart, perUserNotesChart, instanceChart } from '../chart';
 | 
			
		||||
import { deliverToFollowers } from '../../remote/activitypub/deliver-manager';
 | 
			
		||||
import countSameRenotes from '../count-same-renotes';
 | 
			
		||||
import { countSameRenotes } from '../../misc/count-same-renotes';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 投稿を削除します。
 | 
			
		||||
@@ -21,7 +21,7 @@ import countSameRenotes from '../count-same-renotes';
 | 
			
		||||
export default async function(user: User, note: Note, quiet = false) {
 | 
			
		||||
	const deletedAt = new Date();
 | 
			
		||||
 | 
			
		||||
	//この投稿を除く指定したユーザーによる指定したノートのリノートが存在しないとき
 | 
			
		||||
	// この投稿を除く指定したユーザーによる指定したノートのリノートが存在しないとき
 | 
			
		||||
	if (note.renoteId && (await countSameRenotes(user.id, note.renoteId, note.id)) === 0) {
 | 
			
		||||
		Notes.decrement({ id: note.renoteId }, 'renoteCount', 1);
 | 
			
		||||
		Notes.decrement({ id: note.renoteId }, 'score', 1);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user