Skip to content

Commit

Permalink
Merge pull request #266 from smartdevicelink/develop
Browse files Browse the repository at this point in the history
Release 2.12
  • Loading branch information
renonick87 authored Oct 27, 2021
2 parents a05cf59 + 5b41af1 commit 05576a8
Show file tree
Hide file tree
Showing 24 changed files with 530 additions and 246 deletions.
2 changes: 2 additions & 0 deletions app/v1/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function exposeRoutes () {
app.put('/applications/groups', auth.validateAuth, applications.putFunctionalGroup);
// webengine app store
app.get('/applications/store', cors(), applications.getAppStore);
app.get('/applications/store/staging', cors(), applications.getStagingAppStore);
app.post('/webhook', applications.webhook); //webhook route
//begin policy table routes
app.options('/staging/policy', cors())
Expand All @@ -105,6 +106,7 @@ function exposeRoutes () {
app.get('/module', auth.validateAuth, moduleConfig.get);
app.post('/module', auth.validateAuth, moduleConfig.post);
app.post('/module/promote', auth.validateAuth, moduleConfig.promote);
app.post('/module/promoteNoId', auth.validateAuth, moduleConfig.promoteNoId);
app.get('/about', auth.validateAuth, about.getInfo);
app.post('/security/certificate', certificates.createCertificate);
app.post('/security/private', certificates.createPrivateKey);
Expand Down
36 changes: 36 additions & 0 deletions app/v1/applications/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,41 @@ function queryAndStoreCategories(callback) {
});
}

function getStagingAppStore (req, res, next) {
let filterObj = {
approval_status: 'STAGING',
platform: 'EMBEDDED',
};

if (req.query.uuid) {
filterObj.app_uuid = req.query.uuid;
}
if (req.query.transport_type) {
filterObj.transport_type = req.query.transport_type;
}

let chosenFlow = helper.createAppInfoFlow('multiFilter', filterObj);

const finalFlow = flow([
chosenFlow,
helper.appStoreTransformation.bind(null, req.query.min_rpc_version, req.query.min_protocol_version),
], { method: 'waterfall' });

finalFlow(function (err, apps) {
if (err) {
app.locals.log.error(err);
return res.parcel.setStatus(500)
.setMessage("Internal Server Error")
.deliver();
}
return res.parcel.setStatus(200)
.setData({
applications: apps,
})
.deliver();
})
}

function getAppStore (req, res, next) {
// only let embedded apps through
let filterObj = {
Expand Down Expand Up @@ -670,4 +705,5 @@ module.exports = {
updateAppCertificate: updateAppCertificate,
checkAndUpdateCertificates: checkAndUpdateCertificates,
getAppStore: getAppStore,
getStagingAppStore: getStagingAppStore,
};
13 changes: 12 additions & 1 deletion app/v1/messages/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ module.exports = {
categoryByLanguage: getMessageCategoriesByLanguage,
categoryByMaxId: getMessageCategoriesByMaxId,
byIds: getMessagesByIdsStagingFilter,
groupsByIds: getMessageGroupsByIdsStagingFilter
groupsByIds: getMessageGroupsByIdsStagingFilter,
highestGroupId: getHighestMessageGroupId,
},
getMessageNamesStaging: getMessageNamesStaging,
getLanguages: getLanguages,
Expand All @@ -44,6 +45,16 @@ function getMessagesStatus (isProduction) {
}
}

//retrieve the highest id message group found
function getHighestMessageGroupId (isProduction) {
let viewName = isProduction ? 'view_message_group_production' : 'view_message_group_staging';

let sqlString = sql.select('MAX(id) AS id')
.from(viewName);

return sqlString.toString();
}

//retrieve message group information such as categories
function getMessageGroups (isProduction, category, hideDeleted = false) {
let viewName = isProduction ? 'view_message_group_production' : 'view_message_group_staging';
Expand Down
29 changes: 29 additions & 0 deletions app/v1/module-config/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,34 @@ function post(isProduction, req, res, next) {
}
}

function promoteNoId (req, res, next) {
if (res.parcel.message) {
return res.parcel.deliver();
}

// retrieve the staging config
const flow = helper.getModuleConfigFlow('status', false);

flow(function(err, data) {
if (err) {
app.locals.log.error(err);
return res.parcel
.setStatus(500)
.setMessage('Internal server error')
.deliver();
}
if (!certController.openSSLEnabled) { // cert gen not enabled
data.forEach(obj => {
delete obj.certificate;
delete obj.private_key
})
}
// modify the body and pass the express parameters along as if we are posting to production
req.body = data[0];
post(true, req, res, next);
});
}

function checkAndUpdateCertificate (cb) {
if (!certController.openSSLEnabled) {
if (cb) {
Expand Down Expand Up @@ -183,5 +211,6 @@ module.exports = {
get: get,
post: post.bind(null, false),
promote: post.bind(null, true),
promoteNoId: promoteNoId,
checkAndUpdateCertificate: checkAndUpdateCertificate
};
85 changes: 51 additions & 34 deletions app/v1/module-config/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ function validatePost (req, res) {
req.body.exchange_after_x_days -= 0;
req.body.timeout_after_x_seconds -= 0;

if (!check.number(req.body.exchange_after_x_ignition_cycles)) {
return setError("exchange_after_x_ignition_cycles required");
if (!check.number(req.body.exchange_after_x_ignition_cycles) ||
(check.number(req.body.exchange_after_x_ignition_cycles) && req.body.exchange_after_x_ignition_cycles > 255)) {
return setError("exchange_after_x_ignition_cycles required and should not exceed 255");
}
if (!check.number(req.body.exchange_after_x_kilometers)) {
return setError("exchange_after_x_kilometers required");
}
if (!check.number(req.body.exchange_after_x_days)) {
return setError("exchange_after_x_days required");
if (!check.number(req.body.exchange_after_x_days) ||
(check.number(req.body.exchange_after_x_days) && req.body.exchange_after_x_days > 255)) {
return setError("exchange_after_x_days required and should not exceed 255");
}
if (!check.number(req.body.timeout_after_x_seconds)) {
return setError("timeout_after_x_seconds required");
if (!check.number(req.body.timeout_after_x_seconds) ||
(check.number(req.body.timeout_after_x_seconds) && req.body.timeout_after_x_seconds > 65535)) {
return setError("timeout_after_x_seconds required and should not exceed 65535");
}
if (!check.array(req.body.seconds_between_retries)) {
return setError("seconds_between_retries required");
Expand Down Expand Up @@ -58,26 +61,33 @@ function validatePost (req, res) {
req.body.notifications_per_minute_by_priority.COMMUNICATION -= 0;
req.body.notifications_per_minute_by_priority.NORMAL -= 0;
req.body.notifications_per_minute_by_priority.NONE -= 0;
if (!check.number(req.body.notifications_per_minute_by_priority.EMERGENCY)) {
return setError("EMERGENCY notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.EMERGENCY) ||
(check.number(req.body.notifications_per_minute_by_priority.EMERGENCY) && req.body.notifications_per_minute_by_priority.EMERGENCY > 255)) {
return setError("EMERGENCY notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.NAVIGATION)) {
return setError("NAVIGATION notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.NAVIGATION) ||
(check.number(req.body.notifications_per_minute_by_priority.NAVIGATION) && req.body.notifications_per_minute_by_priority.NAVIGATION > 255)) {
return setError("NAVIGATION notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.PROJECTION)) {
return setError("PROJECTION notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.PROJECTION) ||
(check.number(req.body.notifications_per_minute_by_priority.PROJECTION) && req.body.notifications_per_minute_by_priority.PROJECTION > 255)) {
return setError("PROJECTION notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.VOICECOM)) {
return setError("VOICECOM notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.VOICECOM) ||
(check.number(req.body.notifications_per_minute_by_priority.VOICECOM) && req.body.notifications_per_minute_by_priority.VOICECOM > 255)) {
return setError("VOICECOM notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.COMMUNICATION)) {
return setError("COMMUNICATION notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.COMMUNICATION) ||
(check.number(req.body.notifications_per_minute_by_priority.COMMUNICATION) && req.body.notifications_per_minute_by_priority.COMMUNICATION > 255)) {
return setError("COMMUNICATION notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.NORMAL)) {
return setError("NORMAL notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.NORMAL) ||
(check.number(req.body.notifications_per_minute_by_priority.NORMAL) && req.body.notifications_per_minute_by_priority.NORMAL > 255)) {
return setError("NORMAL notification count required and should not exceed 255");
}
if (!check.number(req.body.notifications_per_minute_by_priority.NONE)) {
return setError("NONE notification count required");
if (!check.number(req.body.notifications_per_minute_by_priority.NONE) ||
(check.number(req.body.notifications_per_minute_by_priority.NONE) && req.body.notifications_per_minute_by_priority.NONE > 255)) {
return setError("NONE notification count required and should not exceed 255");
}

req.body.subtle_notifications_per_minute_by_priority.EMERGENCY -= 0;
Expand All @@ -87,26 +97,33 @@ function validatePost (req, res) {
req.body.subtle_notifications_per_minute_by_priority.COMMUNICATION -= 0;
req.body.subtle_notifications_per_minute_by_priority.NORMAL -= 0;
req.body.subtle_notifications_per_minute_by_priority.NONE -= 0;
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.EMERGENCY)) {
return setError("Subtle EMERGENCY notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.EMERGENCY) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.EMERGENCY) && req.body.subtle_notifications_per_minute_by_priority.EMERGENCY > 255)) {
return setError("Subtle EMERGENCY notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NAVIGATION)) {
return setError("Subtle NAVIGATION notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NAVIGATION) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.NAVIGATION) && req.body.subtle_notifications_per_minute_by_priority.NAVIGATION > 255)) {
return setError("Subtle NAVIGATION notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.PROJECTION)) {
return setError("Subtle PROJECTION notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.PROJECTION) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.PROJECTION) && req.body.subtle_notifications_per_minute_by_priority.PROJECTION > 255)) {
return setError("Subtle PROJECTION notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.VOICECOM)) {
return setError("Subtle VOICECOM notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.VOICECOM) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.VOICECOM) && req.body.subtle_notifications_per_minute_by_priority.VOICECOM > 255)) {
return setError("Subtle VOICECOM notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.COMMUNICATION)) {
return setError("Subtle COMMUNICATION notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.COMMUNICATION) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.COMMUNICATION) && req.body.subtle_notifications_per_minute_by_priority.COMMUNICATION > 255)) {
return setError("Subtle COMMUNICATION notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NORMAL)) {
return setError("Subtle NORMAL notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NORMAL) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.NORMAL) && req.body.subtle_notifications_per_minute_by_priority.NORMAL > 255)) {
return setError("Subtle NORMAL notification count required and should not exceed 255");
}
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NONE)) {
return setError("Subtle NONE notification count required");
if (!check.number(req.body.subtle_notifications_per_minute_by_priority.NONE) ||
(check.number(req.body.subtle_notifications_per_minute_by_priority.NONE) && req.body.subtle_notifications_per_minute_by_priority.NONE > 255)) {
return setError("Subtle NONE notification count required and should not exceed 255");
}
return;

Expand Down
3 changes: 2 additions & 1 deletion app/v1/policy/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ function setupModuleConfig (isProduction, useLongUuids = false) {
function setupConsumerFriendlyMessages (isProduction) {
const getMessages = flame.flow({
messageStatuses: setupSqlCommand.bind(null, messagesSql.getMessages.status(isProduction)),
messageGroups: setupSqlCommand.bind(null, messagesSql.getMessages.group(isProduction, false, true))
messageGroups: setupSqlCommand.bind(null, messagesSql.getMessages.group(isProduction, false, true)),
highestMessageGroupId: setupSqlCommand.bind(null, messagesSql.getMessages.highestGroupId(isProduction, false))
}, {method: 'parallel'});

const makeMessages = [
Expand Down
Loading

0 comments on commit 05576a8

Please sign in to comment.