The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/cloud/server/functions/getConfirmationPoll.ts

30 lines
867 B

import { HTTP } from 'meteor/http';
import { settings } from '../../../settings/server';
import { SystemLogger } from '../../../../server/lib/logger/system';
import { CloudConfirmationPollData } from '../../../../definition/ICloud';
export async function getConfirmationPoll(deviceCode: string): Promise<CloudConfirmationPollData> {
const cloudUrl = settings.get('Cloud_Url');
let result;
try {
result = HTTP.get(`${cloudUrl}/api/v2/register/workspace/poll?token=${deviceCode}`);
} catch (e) {
if (e.response && e.response.data && e.response.data.error) {
SystemLogger.error(`Failed to register with Rocket.Chat Cloud. ErrorCode: ${e.response.data.error}`);
} else {
SystemLogger.error(e);
}
throw e;
}
const { data } = result;
if (!data) {
throw new Error('Failed to retrieve registration confirmation poll data');
}
return data;
}