Skip to content

Commit

Permalink
Expose mobile api ids in API (#457)
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan authored May 26, 2024
1 parent 22526ee commit 2076336
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 8 additions & 1 deletion routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,16 @@ exports.hidenotification = function (req, res) {
return res.status(200).json({});
});
}

exports.proxyurlget = function (req, res) {
res.status(200).json({
'url': system.getProxyURL()
});
};

exports.appids = function (req, res) {
res.status(200).json({
'ios': system.getAppleId(),
'android': system.getAndroidId()
});
};
9 changes: 5 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ Routes.prototype.setupProxyRoutes = function (app) {

Routes.prototype.setupAppRoutes = function (app) {
// myOH API for mobile apps
app.all('/api/v1/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationsget);
app.all('/api/v1/hidenotification/:id', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.hidenotification);
app.all('/api/v1/settings/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationssettingsget);
app.all('/api/v1/proxyurl', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.proxyurlget);
app.get('/api/v1/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationsget);
app.get('/api/v1/hidenotification/:id', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.hidenotification);
app.get('/api/v1/settings/notifications', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.notificationssettingsget);
app.get('/api/v1/proxyurl', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.proxyurlget);
app.get('/api/v1/appids', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, api_routes.appids);

// Android app registration (FCM)
app.all('/addAndroidRegistration*', this.ensureRestAuthenticated, this.setOpenhab, this.preassembleBody, fcmRegistrationService.registerAndroid);
Expand Down
12 changes: 10 additions & 2 deletions system/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,16 @@ System.prototype.isIFTTTEnabled = function() {
* @return {string}
*/
System.prototype.getAppleLink = function() {
return 'https://itunes.apple.com/app/id' + this.getAppleId();
};

System.prototype.getAppleId = function() {
let appleId = '492054521';
try {
appleId = this.getConfig(['apps', 'appleId']);
} catch (err) {}

return 'https://itunes.apple.com/app/id' + appleId;
return appleId;
};

/**
Expand All @@ -252,12 +256,16 @@ System.prototype.getAppleLink = function() {
* @return {string}
*/
System.prototype.getAndroidLink = function () {
return 'https://play.google.com/store/apps/details?id=' + this.getAndroidId();
};

System.prototype.getAndroidId = function () {
let playStoreId = 'org.openhab.habdroid';
try {
playStoreId = this.getConfig(['apps', 'playStoreId']);
} catch (err) {}

return 'https://play.google.com/store/apps/details?id=' + playStoreId;
return playStoreId;
};

/**
Expand Down

0 comments on commit 2076336

Please sign in to comment.