mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
0765cf5955
- Joplin Server: Adds support for sharing a notebook - Desktop: Adds support for sharing a notebook with Joplin Server - Mobile: Adds support for reading and writing to a shared notebook (not possible to share a notebook) - Cli: Adds support for reading and writing to a shared notebook (not possible to share a notebook)
48 lines
1.2 KiB
TypeScript
48 lines
1.2 KiB
TypeScript
import JoplinDatabase from '../JoplinDatabase';
|
|
import Setting from '../models/Setting';
|
|
import SyncTargetJoplinServer from '../SyncTargetJoplinServer';
|
|
|
|
export default class DebugService {
|
|
|
|
private db_: JoplinDatabase;
|
|
|
|
public constructor(db: JoplinDatabase) {
|
|
this.db_ = db;
|
|
}
|
|
|
|
private get db(): JoplinDatabase {
|
|
return this.db_;
|
|
}
|
|
|
|
public async clearSyncState() {
|
|
const tableNames = [
|
|
'item_changes',
|
|
'deleted_items',
|
|
'sync_items',
|
|
'key_values',
|
|
];
|
|
|
|
const queries = [];
|
|
for (const n of tableNames) {
|
|
queries.push(`DELETE FROM ${n}`);
|
|
queries.push(`DELETE FROM sqlite_sequence WHERE name="${n}"`); // Reset autoincremented IDs
|
|
}
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
queries.push(`DELETE FROM settings WHERE key="sync.${i}.context"`);
|
|
queries.push(`DELETE FROM settings WHERE key="sync.${i}.auth"`);
|
|
}
|
|
|
|
await this.db.transactionExecBatch(queries);
|
|
}
|
|
|
|
public async setupJoplinServerUser(num: number) {
|
|
const id = SyncTargetJoplinServer.id();
|
|
Setting.setValue('sync.target', id);
|
|
Setting.setValue(`sync.${id}.path`, 'http://localhost:22300');
|
|
Setting.setValue(`sync.${id}.username`, `user${num}@example.com`);
|
|
Setting.setValue(`sync.${id}.password`, '123456');
|
|
}
|
|
|
|
}
|