-
+ {{ $t('export-and-import') }}
@@ -99,7 +99,10 @@
- {{ $t('export') }}
+
+ {{ $t('export') }}
+ {{ $t('import') }}
+
@@ -119,7 +122,7 @@ import { apiUrl, host } from '../../../../config';
import { toUnicode } from 'punycode';
import langmap from 'langmap';
import { unique } from '../../../../../../prelude/array';
-import { faDownload } from '@fortawesome/free-solid-svg-icons';
+import { faDownload, faUpload } from '@fortawesome/free-solid-svg-icons';
export default Vue.extend({
i18n: i18n('common/views/components/profile-editor.vue'),
@@ -148,7 +151,7 @@ export default Vue.extend({
avatarUploading: false,
bannerUploading: false,
exportTarget: 'notes',
- faDownload
+ faDownload, faUpload
};
},
@@ -294,6 +297,21 @@ export default Vue.extend({
});
},
+ doImport() {
+ this.$chooseDriveFile().then(file => {
+ this.$root.api(
+ this.exportTarget == 'user-lists' ? 'i/import-user-lists' :
+ null, {
+ fileId: file.id
+ });
+
+ this.$root.dialog({
+ type: 'info',
+ text: this.$t('import-requested')
+ });
+ });
+ },
+
async deleteAccount() {
const { canceled: canceled, result: password } = await this.$root.dialog({
title: this.$t('enter-password'),
diff --git a/src/queue/index.ts b/src/queue/index.ts
index 00a4a48f14..09e0ad59c9 100644
--- a/src/queue/index.ts
+++ b/src/queue/index.ts
@@ -9,6 +9,7 @@ import processDeliver from './processors/deliver';
import processInbox from './processors/inbox';
import processDb from './processors/db';
import { queueLogger } from './logger';
+import { IDriveFile } from '../models/drive-file';
function initializeQueue(name: string) {
return new Queue(name, config.redis != null ? {
@@ -145,6 +146,16 @@ export function createExportUserListsJob(user: ILocalUser) {
});
}
+export function createImportUserListsJob(user: ILocalUser, fileId: IDriveFile['_id']) {
+ return dbQueue.add('importUserLists', {
+ user: user,
+ fileId: fileId
+ }, {
+ removeOnComplete: true,
+ removeOnFail: true
+ });
+}
+
export default function() {
if (!program.onlyServer) {
deliverQueue.process(128, processDeliver);
diff --git a/src/queue/processors/db/import-user-lists.ts b/src/queue/processors/db/import-user-lists.ts
new file mode 100644
index 0000000000..ee1468d5ae
--- /dev/null
+++ b/src/queue/processors/db/import-user-lists.ts
@@ -0,0 +1,140 @@
+import * as Bull from 'bull';
+import * as tmp from 'tmp';
+import * as fs from 'fs';
+import * as util from 'util';
+import * as mongo from 'mongodb';
+import * as request from 'request';
+
+import { queueLogger } from '../../logger';
+import User from '../../../models/user';
+import config from '../../../config';
+import UserList from '../../../models/user-list';
+import DriveFile from '../../../models/drive-file';
+import chalk from 'chalk';
+import { getOriginalUrl } from '../../../misc/get-drive-file-url';
+import parseAcct from '../../../misc/acct/parse';
+import resolveUser from '../../../remote/resolve-user';
+
+const logger = queueLogger.createSubLogger('import-user-lists');
+
+export async function importUserLists(job: Bull.Job, done: any): Promise