+
+
+
+ {{ $t('export-notes') }}
+
+
@@ -252,6 +260,15 @@ export default Vue.extend({
email: this.email == '' ? null : this.email
});
});
+ },
+
+ exportNotes() {
+ this.$root.api('i/export-notes', {});
+
+ this.$root.dialog({
+ type: 'info',
+ text: this.$t('export-requested')
+ });
}
}
});
diff --git a/src/queue/index.ts b/src/queue/index.ts
index 65c52d864c..cf8af17a48 100644
--- a/src/queue/index.ts
+++ b/src/queue/index.ts
@@ -1,9 +1,9 @@
import * as Queue from 'bee-queue';
import config from '../config';
-import http from './processors/http';
+
import { ILocalUser } from '../models/user';
-import Logger from '../misc/logger';
import { program } from '../argv';
+import handler from './processors';
const enableQueue = config.redis != null && !program.disableQueue;
@@ -36,7 +36,7 @@ export function createHttpJob(data: any) {
.backoff('exponential', 16384) // 16s
.save();
} else {
- return http({ data }, () => {});
+ return handler({ data }, () => {});
}
}
@@ -51,10 +51,18 @@ export function deliver(user: ILocalUser, content: any, to: any) {
});
}
-export const queueLogger = new Logger('queue');
+export function createExportNotesJob(user: ILocalUser) {
+ if (!enableQueue) throw 'queue disabled';
+
+ return queue.createJob({
+ type: 'exportNotes',
+ user: user
+ })
+ .save();
+}
export default function() {
if (enableQueue) {
- queue.process(128, http);
+ queue.process(128, handler);
}
}
diff --git a/src/queue/logger.ts b/src/queue/logger.ts
new file mode 100644
index 0000000000..99d88bd63b
--- /dev/null
+++ b/src/queue/logger.ts
@@ -0,0 +1,3 @@
+import Logger from '../misc/logger';
+
+export const queueLogger = new Logger('queue', 'orange');
diff --git a/src/queue/processors/export-notes.ts b/src/queue/processors/export-notes.ts
new file mode 100644
index 0000000000..52845a5a9c
--- /dev/null
+++ b/src/queue/processors/export-notes.ts
@@ -0,0 +1,128 @@
+import * as bq from 'bee-queue';
+import * as tmp from 'tmp';
+import * as fs from 'fs';
+import * as mongo from 'mongodb';
+
+import { queueLogger } from '../logger';
+import Note, { INote } from '../../models/note';
+import addFile from '../../services/drive/add-file';
+import User from '../../models/user';
+import dateFormat = require('dateformat');
+
+const logger = queueLogger.createSubLogger('export-notes');
+
+export async function exportNotes(job: bq.Job, done: any): Promise