wip
This commit is contained in:
		
							parent
							
								
									df71c90f9f
								
							
						
					
					
						commit
						335200c31e
					
				
					 9 changed files with 17 additions and 206 deletions
				
			
		| 
						 | 
				
			
			@ -17,6 +17,7 @@ import { isLocalUser, IUser, IRemoteUser } from '../../models/user';
 | 
			
		|||
import delFile from './delete-file';
 | 
			
		||||
import config from '../../config';
 | 
			
		||||
import { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
 | 
			
		||||
import { updateDriveStats } from '../update-chart';
 | 
			
		||||
 | 
			
		||||
const log = debug('misskey:drive:add-file');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -377,7 +378,8 @@ export default async function(
 | 
			
		|||
		publishDriveStream(user._id, 'file_created', packedFile);
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	// TODO: サムネイル生成
 | 
			
		||||
	// 統計を更新
 | 
			
		||||
	updateDriveStats(driveFile, true);
 | 
			
		||||
 | 
			
		||||
	return driveFile;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@ import * as Minio from 'minio';
 | 
			
		|||
import DriveFile, { DriveFileChunk, IDriveFile } from '../../models/drive-file';
 | 
			
		||||
import DriveFileThumbnail, { DriveFileThumbnailChunk } from '../../models/drive-file-thumbnail';
 | 
			
		||||
import config from '../../config';
 | 
			
		||||
import { updateDriveStats } from '../update-chart';
 | 
			
		||||
 | 
			
		||||
export default async function(file: IDriveFile, isExpired = false) {
 | 
			
		||||
	if (file.metadata.storage == 'minio') {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,4 +46,7 @@ export default async function(file: IDriveFile, isExpired = false) {
 | 
			
		|||
		await DriveFileThumbnail.remove({ _id: thumbnail._id });
 | 
			
		||||
	}
 | 
			
		||||
	//#endregion
 | 
			
		||||
 | 
			
		||||
	// 統計を更新
 | 
			
		||||
	updateDriveStats(file, false);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,7 @@ import registerHashtag from '../register-hashtag';
 | 
			
		|||
import isQuote from '../../misc/is-quote';
 | 
			
		||||
import { TextElementMention } from '../../mfm/parse/elements/mention';
 | 
			
		||||
import { TextElementHashtag } from '../../mfm/parse/elements/hashtag';
 | 
			
		||||
import { updateNoteStats } from '../update-chart';
 | 
			
		||||
 | 
			
		||||
type NotificationType = 'reply' | 'renote' | 'quote' | 'mention';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -142,6 +143,9 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
 | 
			
		|||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// 統計を更新
 | 
			
		||||
	updateNoteStats(note, true);
 | 
			
		||||
 | 
			
		||||
	// ハッシュタグ登録
 | 
			
		||||
	tags.map(tag => registerHashtag(user, tag));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,7 @@ import pack from '../../remote/activitypub/renderer';
 | 
			
		|||
import { deliver } from '../../queue';
 | 
			
		||||
import Following from '../../models/following';
 | 
			
		||||
import renderNote from '../../remote/activitypub/renderer/note';
 | 
			
		||||
import { updateNoteStats } from '../update-chart';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 投稿を削除します。
 | 
			
		||||
| 
						 | 
				
			
			@ -43,4 +44,7 @@ export default async function(user: IUser, note: INote) {
 | 
			
		|||
		});
 | 
			
		||||
	}
 | 
			
		||||
	//#endregion
 | 
			
		||||
 | 
			
		||||
	// 統計を更新
 | 
			
		||||
	updateNoteStats(note, false);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -201,13 +201,13 @@ export async function updateNoteStats(note: INote, isAdditional: boolean) {
 | 
			
		|||
	await update(inc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function updateDriveStats(user: IUser, file: IDriveFile, isAdditional: boolean) {
 | 
			
		||||
export async function updateDriveStats(file: IDriveFile, isAdditional: boolean) {
 | 
			
		||||
	const inc = {} as any;
 | 
			
		||||
 | 
			
		||||
	const amount = isAdditional ? 1 : -1;
 | 
			
		||||
	const size = isAdditional ? file.length : -file.length;
 | 
			
		||||
 | 
			
		||||
	if (isLocalUser(user)) {
 | 
			
		||||
	if (isLocalUser(file.metadata._user)) {
 | 
			
		||||
		inc['drive.local.totalCount'] = amount;
 | 
			
		||||
		inc['drive.local.diffCount'] = amount;
 | 
			
		||||
		inc['drive.local.totalSize'] = size;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue