/* This file is part of Ezra Bible App.
Copyright (C) 2019 - 2026 Ezra Bible App Development Team <contact@ezrabibleapp.net>
Ezra Bible App is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Ezra Bible App is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Ezra Bible App. See the file LICENSE.
If not, see <http://www.gnu.org/licenses/>. */
/**
* Shared (frontend and backend) rules for determining the active cloud sync provider.
* @module cloudSyncProvider
* @category Utility
*/
const SUPPORTED_CLOUD_SYNC_PROVIDERS = ['dropbox', 'nextcloud'];
/**
* Resolve the active cloud sync provider from the raw settings values.
* Installations from before the provider selection existed have no `cloudSyncProvider` setting;
* if they have a Dropbox token they are treated as using Dropbox.
* @param {string|null|undefined} cloudSyncProvider value of the `cloudSyncProvider` setting
* @param {string|null|undefined} dropboxToken value of the `dropboxToken` setting
* @returns {('dropbox'|'nextcloud'|null)}
*/
module.exports.resolveCloudSyncProvider = (cloudSyncProvider, dropboxToken) => {
if (cloudSyncProvider !== undefined && cloudSyncProvider !== null && cloudSyncProvider !== '') {
return SUPPORTED_CLOUD_SYNC_PROVIDERS.includes(cloudSyncProvider) ? cloudSyncProvider : null;
}
if (dropboxToken !== undefined && dropboxToken !== null && dropboxToken !== '') {
return 'dropbox';
}
return null;
};
module.exports.SUPPORTED_CLOUD_SYNC_PROVIDERS = SUPPORTED_CLOUD_SYNC_PROVIDERS;
Source