From 9d1ed1eb0dfce53aa0db7f33f376774b1521a5ae Mon Sep 17 00:00:00 2001
From: MeiMei <30769358+mei23@users.noreply.github.com>
Date: Fri, 3 May 2019 18:33:25 +0900
Subject: [PATCH] Some import and export fixes (#4842)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Fix: Mastodon v2.8.0 のフォローリストがインポートできない

* Fix: エクスポートリクエストに失敗してもエラーが出ない (#4821)

* エクスポートファイルでは同一ハッシュチェックをしないように
---
 .../views/components/settings/profile.vue       | 17 +++++++++++------
 src/queue/processors/db/export-blocking.ts      |  2 +-
 src/queue/processors/db/export-following.ts     |  2 +-
 src/queue/processors/db/export-mute.ts          |  2 +-
 src/queue/processors/db/export-notes.ts         |  2 +-
 src/queue/processors/db/export-user-lists.ts    |  2 +-
 src/queue/processors/db/import-following.ts     |  3 ++-
 7 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/client/app/common/views/components/settings/profile.vue b/src/client/app/common/views/components/settings/profile.vue
index c1ecfafe16..a22fd6df98 100644
--- a/src/client/app/common/views/components/settings/profile.vue
+++ b/src/client/app/common/views/components/settings/profile.vue
@@ -290,12 +290,17 @@ export default Vue.extend({
 				this.exportTarget == 'mute' ? 'i/export-mute' :
 				this.exportTarget == 'blocking' ? 'i/export-blocking' :
 				this.exportTarget == 'user-lists' ? 'i/export-user-lists' :
-				null, {});
-
-			this.$root.dialog({
-				type: 'info',
-				text: this.$t('export-requested')
-			});
+				null, {}).then(() => {
+					this.$root.dialog({
+						type: 'info',
+						text: this.$t('export-requested')
+					});
+				}).catch((e: any) => {
+					this.$root.dialog({
+						type: 'error',
+						text: e.message
+					});
+				});
 		},
 
 		doImport() {
diff --git a/src/queue/processors/db/export-blocking.ts b/src/queue/processors/db/export-blocking.ts
index c4b8c9438d..0504ab8c30 100644
--- a/src/queue/processors/db/export-blocking.ts
+++ b/src/queue/processors/db/export-blocking.ts
@@ -85,7 +85,7 @@ export async function exportBlocking(job: Bull.Job, done: any): Promise<void> {
 	logger.succ(`Exported to: ${path}`);
 
 	const fileName = 'blocking-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
-	const driveFile = await addFile(user, path, fileName);
+	const driveFile = await addFile(user, path, fileName, null, null, true);
 
 	logger.succ(`Exported to: ${driveFile.id}`);
 	cleanup();
diff --git a/src/queue/processors/db/export-following.ts b/src/queue/processors/db/export-following.ts
index 9fab5bb21a..996ef6310d 100644
--- a/src/queue/processors/db/export-following.ts
+++ b/src/queue/processors/db/export-following.ts
@@ -85,7 +85,7 @@ export async function exportFollowing(job: Bull.Job, done: any): Promise<void> {
 	logger.succ(`Exported to: ${path}`);
 
 	const fileName = 'following-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
-	const driveFile = await addFile(user, path, fileName);
+	const driveFile = await addFile(user, path, fileName, null, null, true);
 
 	logger.succ(`Exported to: ${driveFile.id}`);
 	cleanup();
diff --git a/src/queue/processors/db/export-mute.ts b/src/queue/processors/db/export-mute.ts
index b957b48b20..5531553220 100644
--- a/src/queue/processors/db/export-mute.ts
+++ b/src/queue/processors/db/export-mute.ts
@@ -85,7 +85,7 @@ export async function exportMute(job: Bull.Job, done: any): Promise<void> {
 	logger.succ(`Exported to: ${path}`);
 
 	const fileName = 'mute-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
-	const driveFile = await addFile(user, path, fileName);
+	const driveFile = await addFile(user, path, fileName, null, null, true);
 
 	logger.succ(`Exported to: ${driveFile.id}`);
 	cleanup();
diff --git a/src/queue/processors/db/export-notes.ts b/src/queue/processors/db/export-notes.ts
index d03a216a59..94a4302e05 100644
--- a/src/queue/processors/db/export-notes.ts
+++ b/src/queue/processors/db/export-notes.ts
@@ -108,7 +108,7 @@ export async function exportNotes(job: Bull.Job, done: any): Promise<void> {
 	logger.succ(`Exported to: ${path}`);
 
 	const fileName = 'notes-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.json';
-	const driveFile = await addFile(user, path, fileName);
+	const driveFile = await addFile(user, path, fileName, null, null, true);
 
 	logger.succ(`Exported to: ${driveFile.id}`);
 	cleanup();
diff --git a/src/queue/processors/db/export-user-lists.ts b/src/queue/processors/db/export-user-lists.ts
index 5cd978c1aa..447cdaa174 100644
--- a/src/queue/processors/db/export-user-lists.ts
+++ b/src/queue/processors/db/export-user-lists.ts
@@ -62,7 +62,7 @@ export async function exportUserLists(job: Bull.Job, done: any): Promise<void> {
 	logger.succ(`Exported to: ${path}`);
 
 	const fileName = 'user-lists-' + dateFormat(new Date(), 'yyyy-mm-dd-HH-MM-ss') + '.csv';
-	const driveFile = await addFile(user, path, fileName);
+	const driveFile = await addFile(user, path, fileName, null, null, true);
 
 	logger.succ(`Exported to: ${driveFile.id}`);
 	cleanup();
diff --git a/src/queue/processors/db/import-following.ts b/src/queue/processors/db/import-following.ts
index 8de3193e46..ff4ff6b6ab 100644
--- a/src/queue/processors/db/import-following.ts
+++ b/src/queue/processors/db/import-following.ts
@@ -35,7 +35,8 @@ export async function importFollowing(job: Bull.Job, done: any): Promise<void> {
 		linenum++;
 
 		try {
-			const { username, host } = parseAcct(line.trim());
+			const acct = line.split(',')[0].trim();
+			const { username, host } = parseAcct(acct);
 
 			let target = isSelfHost(host!) ? await Users.findOne({
 				host: null,