appstore: move existing apps sync to common code
This commit is contained in:
+5
-9
@@ -298,7 +298,6 @@ async function registerCloudron(data) {
|
||||
if (response.status === 401) throw new BoxError(BoxError.LICENSE_ERROR, 'Setup token invalid');
|
||||
if (response.status !== 201) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unable to register cloudron: ${response.statusCode} ${error.message}`);
|
||||
|
||||
// cloudronId, token
|
||||
if (!response.body.cloudronId) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Invalid response - no cloudron id');
|
||||
if (!response.body.cloudronToken) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Invalid response - no token');
|
||||
|
||||
@@ -306,6 +305,11 @@ async function registerCloudron(data) {
|
||||
await settings.set(settings.APPSTORE_API_TOKEN_KEY, response.body.cloudronToken);
|
||||
|
||||
debug(`registerCloudron: Cloudron registered with id ${response.body.cloudronId}`);
|
||||
|
||||
// app could already have been installed if we deleted the cloudron.io record and user re-registers
|
||||
for (const app of await apps.list()) {
|
||||
await purchaseApp({ appId: app.id, appstoreId: app.appStoreId, manifestId: app.manifest.id || 'customapp' });
|
||||
}
|
||||
}
|
||||
|
||||
async function updateCloudron(data) {
|
||||
@@ -339,10 +343,6 @@ async function registerCloudronWithSetupToken(options) {
|
||||
const { domain } = await dashboard.getLocation();
|
||||
|
||||
await registerCloudron({ domain, setupToken: options.setupToken, version: constants.VERSION });
|
||||
|
||||
for (const app of await apps.list()) {
|
||||
await purchaseApp({ appId: app.id, appstoreId: app.appStoreId, manifestId: app.manifest.id || 'customapp' });
|
||||
}
|
||||
}
|
||||
|
||||
async function registerCloudronWithLogin(options) {
|
||||
@@ -354,10 +354,6 @@ async function registerCloudronWithLogin(options) {
|
||||
const { domain } = await dashboard.getLocation();
|
||||
|
||||
await registerCloudron({ domain, accessToken: result.accessToken, version: constants.VERSION });
|
||||
|
||||
for (const app of await apps.list()) {
|
||||
await purchaseApp({ appId: app.id, appstoreId: app.appStoreId, manifestId: app.manifest.id || 'customapp' });
|
||||
}
|
||||
}
|
||||
|
||||
async function unregister() {
|
||||
|
||||
Reference in New Issue
Block a user