dev: option to follow old app names in get_app

This commit is contained in:
KernelDeimos
2024-12-19 10:44:00 -05:00
parent 0ccb3b2eed
commit c775a2e860
2 changed files with 18 additions and 1 deletions

View File

@@ -299,6 +299,20 @@ async function refresh_associations_cache(){
const log = services.get('log-service').create('get_app');
let app = [];
// This condition should be updated if the code below is re-ordered.
if ( options.follow_old_names && ! options.uid && options.name ) {
const svc_oldAppName = services.get('old-app-name');
const old_name = await svc_oldAppName.check_app_name(options.name);
if ( old_name ) {
options.uid = old_name.app_uid;
// The following line is technically pointless, but may avoid a bug
// if the if...else chain below is re-ordered.
delete options.name;
}
}
if(options.uid){
// try cache first
app[0] = kv.get(`apps:uid:${options.uid}`);

View File

@@ -341,7 +341,10 @@ router.all('*', async function(req, res, next) {
// /app/
else if(path.startsWith('/app/')){
app_name = path.replace('/app/', '');
const app = await get_app({name: app_name});
const app = await get_app({
follow_old_names: true,
name: app_name,
});
if(app){