2018-02-06 20:59:36 +02:00
|
|
|
// The Nextcloud sync target is essentially a wrapper over the WebDAV sync target,
|
|
|
|
// thus all the calls to SyncTargetWebDAV to avoid duplicate code.
|
|
|
|
|
2021-01-29 20:45:11 +02:00
|
|
|
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 {
|
2019-12-13 03:16:34 +02:00
|
|
|
|
2018-01-25 21:01:14 +02:00
|
|
|
static id() {
|
|
|
|
return 5;
|
|
|
|
}
|
|
|
|
|
2018-02-06 20:59:36 +02:00
|
|
|
static supportsConfigCheck() {
|
|
|
|
return true;
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static targetName() {
|
2018-03-09 22:59:12 +02:00
|
|
|
return 'nextcloud';
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static label() {
|
2018-03-09 22:59:12 +02:00
|
|
|
return _('Nextcloud');
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
2021-08-16 16:20:14 +02:00
|
|
|
static description() {
|
|
|
|
return 'A suite of client-server software for creating and using file hosting services.';
|
|
|
|
}
|
|
|
|
|
2018-03-26 19:33:55 +02:00
|
|
|
async isAuthenticated() {
|
2018-01-25 21:01:14 +02:00
|
|
|
return true;
|
2018-02-06 20:59:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static async checkConfig(options) {
|
|
|
|
return SyncTargetWebDAV.checkConfig(options);
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
async initFileApi() {
|
2018-02-21 20:36:29 +02:00
|
|
|
const fileApi = await SyncTargetWebDAV.newFileApi_(SyncTargetNextcloud.id(), {
|
2018-03-15 19:57:11 +02:00
|
|
|
path: () => Setting.value('sync.5.path'),
|
|
|
|
username: () => Setting.value('sync.5.username'),
|
|
|
|
password: () => Setting.value('sync.5.password'),
|
2021-04-25 10:50:52 +02:00
|
|
|
ignoreTlsErrors: () => Setting.value('net.ignoreTlsErrors'),
|
2018-02-06 20:59:36 +02:00
|
|
|
});
|
|
|
|
|
2018-01-25 21:01:14 +02:00
|
|
|
fileApi.setLogger(this.logger());
|
2018-02-06 20:59:36 +02:00
|
|
|
|
2018-01-25 21:01:14 +02:00
|
|
|
return fileApi;
|
|
|
|
}
|
|
|
|
|
|
|
|
async initSynchronizer() {
|
2018-03-09 22:59:12 +02:00
|
|
|
return new Synchronizer(this.db(), await this.fileApi(), Setting.value('appType'));
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
2019-12-13 03:16:34 +02:00
|
|
|
|
2018-01-25 21:01:14 +02:00
|
|
|
}
|
|
|
|
|
2019-07-29 15:43:53 +02:00
|
|
|
module.exports = SyncTargetNextcloud;
|