1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/packages/lib/SyncTargetNextcloud.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

// The Nextcloud sync target is essentially a wrapper over the WebDAV sync target,
// thus all the calls to SyncTargetWebDAV to avoid duplicate code.
const BaseSyncTarget = require('./BaseSyncTarget').default;
2020-11-05 18:58:23 +02:00
const { _ } = require('./locale');
const Setting = require('./models/Setting').default;
const Synchronizer = require('./Synchronizer').default;
const SyncTargetWebDAV = require('./SyncTargetWebDAV');
2018-01-25 21:01:14 +02:00
class SyncTargetNextcloud extends BaseSyncTarget {
2018-01-25 21:01:14 +02:00
static id() {
return 5;
}
static supportsConfigCheck() {
return true;
2018-01-25 21:01:14 +02:00
}
static targetName() {
return 'nextcloud';
2018-01-25 21:01:14 +02:00
}
static label() {
return _('Nextcloud');
2018-01-25 21:01:14 +02:00
}
2018-03-26 19:33:55 +02:00
async isAuthenticated() {
2018-01-25 21:01:14 +02:00
return true;
}
static async checkConfig(options) {
return SyncTargetWebDAV.checkConfig(options);
2018-01-25 21:01:14 +02:00
}
async initFileApi() {
const fileApi = await SyncTargetWebDAV.newFileApi_(SyncTargetNextcloud.id(), {
path: () => Setting.value('sync.5.path'),
username: () => Setting.value('sync.5.username'),
password: () => Setting.value('sync.5.password'),
ignoreTlsErrors: () => Setting.value('net.ignoreTlsErrors'),
});
2018-01-25 21:01:14 +02:00
fileApi.setLogger(this.logger());
2018-01-25 21:01:14 +02:00
return fileApi;
}
async initSynchronizer() {
return new Synchronizer(this.db(), await this.fileApi(), Setting.value('appType'));
2018-01-25 21:01:14 +02:00
}
2018-01-25 21:01:14 +02:00
}
2019-07-29 15:43:53 +02:00
module.exports = SyncTargetNextcloud;