Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVE] Connectivity Services License Sync #15022

Merged
merged 3 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/cloud/server/functions/getWorkspaceLicense.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HTTP } from 'meteor/http';
import { getWorkspaceAccessToken } from './getWorkspaceAccessToken';
import { settings } from '../../../settings';
import { Settings } from '../../../models';
import { callbacks } from '../../../callbacks';


export function getWorkspaceLicense() {
Expand Down Expand Up @@ -39,5 +40,7 @@ export function getWorkspaceLicense() {

Settings.updateValueById('Cloud_Workspace_License', remoteLicense.license);

callbacks.run('workspaceLicenseChanged', remoteLicense.license);

return { updated: true, license: remoteLicense.license };
}
23 changes: 21 additions & 2 deletions app/cloud/server/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
import { Meteor } from 'meteor/meteor';
import { SyncedCron } from 'meteor/littledata:synced-cron';

import './methods';
import { getWorkspaceAccessToken } from './functions/getWorkspaceAccessToken';
import { getWorkspaceLicense } from './functions/getWorkspaceLicense';
import { getUserCloudAccessToken } from './functions/getUserCloudAccessToken';
import { getWorkspaceKey } from './functions/getWorkspaceKey';
import { syncWorkspace } from './functions/syncWorkspace';
import { Permissions } from '../../models';

if (Permissions) {
Permissions.createOrUpdate('manage-cloud', ['admin']);
}

// Ensure the client/workspace access token is valid
getWorkspaceAccessToken();

const licenseCronName = 'Cloud Workspace Sync';

Meteor.startup(function() {
// run token/license sync if registered
syncWorkspace();

SyncedCron.remove(licenseCronName);
geekgonecrazy marked this conversation as resolved.
Show resolved Hide resolved
SyncedCron.add({
name: licenseCronName,
schedule(parser) {
// Every 12 hours
return parser.cron('0 */12 * * *');
},
job: syncWorkspace,
});
});

export { getWorkspaceAccessToken, getWorkspaceLicense, getWorkspaceKey, getUserCloudAccessToken };