From eb5224e22af14de214256f5a4c5d0881ff4a1b9d Mon Sep 17 00:00:00 2001 From: Chris Hubbard Date: Wed, 28 Feb 2024 15:19:47 -0500 Subject: [PATCH] Fix AppDetails API for Share Link to Installer File feature * When the Scriptoria instance was moved from one AWS account to another we had to change the bucket name to be able to copy the files. We updated all the urls in the databases when we did the migration. However, the play-listing-manifest.json still have the old bucket name in the path. This is used by the Share Link to Installer File feature to get metadata about the app (title, description). * Change the hostname in the url stored in the JSON file to have the same hostname of the artifact retrieved from the database. --- .../Controllers/ProductsController.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/OptimaJet.DWKit.StarterApplication/Controllers/ProductsController.cs b/source/OptimaJet.DWKit.StarterApplication/Controllers/ProductsController.cs index 51469d5e6..16eac01c2 100644 --- a/source/OptimaJet.DWKit.StarterApplication/Controllers/ProductsController.cs +++ b/source/OptimaJet.DWKit.StarterApplication/Controllers/ProductsController.cs @@ -1,6 +1,5 @@ - using System; +using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Threading.Tasks; using JsonApiDotNetCore.Services; @@ -8,7 +7,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OptimaJet.DWKit.StarterApplication.Models; using OptimaJet.DWKit.StarterApplication.Services; using OptimaJet.DWKit.StarterApplication.Utility; @@ -143,7 +141,12 @@ public async Task GetPublishedAppDetails(string package) var manifestJson = await WebClient.DownloadStringTaskAsync(manifestArtifact.Url); var manifest = JsonConvert.DeserializeObject(manifestJson); - var url = manifest.url; + + // The bucket in the URL stored in the manifest can change over time. The URL from + // the artifact query is updated when buckets change. Update the hostname stored + // in the manifest file based on the hostname from the artifact query. + var manifestUri = new Uri(manifestArtifact.Url); + var url = new UriBuilder(new Uri(manifest.url)) { Host = manifestUri.Host }.Uri.ToString(); var titles = new Dictionary(manifest.languages.Count); var descriptions = new Dictionary(manifest.languages.Count); foreach(string language in manifest.languages) @@ -151,6 +154,7 @@ public async Task GetPublishedAppDetails(string package) var title = ""; var titleSearch = $"{language}/title.txt"; var titlePath = manifest.files.Where(s => s.Contains(titleSearch)).FirstOrDefault(); + if (!string.IsNullOrEmpty(titlePath)) { title = await WebClient.DownloadStringTaskAsync(url + titlePath); } titles.Add(language, title.Trim());