Skip to content

Commit

Permalink
Fix AppDetails API for Share Link to Installer File feature
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
chrisvire committed Feb 29, 2024
1 parent 7ba297c commit eb5224e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
 using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using JsonApiDotNetCore.Services;
using Microsoft.AspNetCore.Authentication.JwtBearer;
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;
Expand Down Expand Up @@ -143,14 +141,20 @@ public async Task<IActionResult> GetPublishedAppDetails(string package)
var manifestJson = await WebClient.DownloadStringTaskAsync(manifestArtifact.Url);

var manifest = JsonConvert.DeserializeObject<ManifestResponse>(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<string,string>(manifest.languages.Count);
var descriptions = new Dictionary<string,string>(manifest.languages.Count);
foreach(string language in manifest.languages)
{
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());

Expand Down

0 comments on commit eb5224e

Please sign in to comment.