Skip to content

Commit

Permalink
update Gebura.RefreshApp
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabing010102 committed Oct 16, 2023
1 parent 5edec64 commit 5fe2df0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Librarian.Sephirah/Services/Gebura/RefreshApp.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Grpc.Core;
using Librarian.Common.Utils;
using Microsoft.AspNetCore.Authorization;
using Microsoft.EntityFrameworkCore;
using TuiHub.Protos.Librarian.Sephirah.V1;

namespace Librarian.Sephirah.Services
Expand All @@ -15,11 +16,16 @@ public override Task<RefreshAppResponse> RefreshApp(RefreshAppRequest request, S
throw new RpcException(new Status(StatusCode.PermissionDenied, "Access Deined."));
// get request param
var appId = request.AppId.Id;
var app = _dbContext.Apps.Single(x => x.Id == appId);
if (app.Source == TuiHub.Protos.Librarian.V1.AppSource.Internal)
throw new RpcException(new Status(StatusCode.InvalidArgument, "Cannot refresh internal app."));
var app = _dbContext.Apps.Include(x => x.ChildApps)
.Single(x => x.Id == appId);
if (app.Source != TuiHub.Protos.Librarian.V1.AppSource.Internal)
throw new RpcException(new Status(StatusCode.InvalidArgument, "Cannot refresh not internal app."));
// refresh app
_pullMetadataService.AddPullApp(appId);
foreach (var childApp in app.ChildApps)
if (childApp.Source == TuiHub.Protos.Librarian.V1.AppSource.Steam ||
childApp.Source == TuiHub.Protos.Librarian.V1.AppSource.Vndb ||
childApp.Source == TuiHub.Protos.Librarian.V1.AppSource.Bangumi)
_pullMetadataService.AddPullApp(childApp.Id);
return Task.FromResult(new RefreshAppResponse { });
}
}
Expand Down

0 comments on commit 5fe2df0

Please sign in to comment.