feat: add get-server-version handler
This commit is contained in:
parent
7d31c51790
commit
37ca3c005a
1 changed files with 18 additions and 0 deletions
|
@ -1496,6 +1496,24 @@ handlers['subscribe-sign-out'] = async function() {
|
|||
return 'ok';
|
||||
};
|
||||
|
||||
handlers['get-server-version'] = async function() {
|
||||
if (!getServer() || getServer().BASE_SERVER === UNCONFIGURED_SERVER) {
|
||||
return { error: 'no-server' };
|
||||
}
|
||||
|
||||
let version;
|
||||
try {
|
||||
const res = await get(getServer().BASE_SERVER + '/info');
|
||||
|
||||
const info = JSON.parse(res);
|
||||
version = info.build.version;
|
||||
} catch (err) {
|
||||
return { error: 'network-failure' };
|
||||
}
|
||||
|
||||
return { version };
|
||||
};
|
||||
|
||||
handlers['get-server-url'] = async function() {
|
||||
return getServer() && getServer().BASE_SERVER;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue