Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Commands/SyncCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
}

public abstract class SyncCommand<TSettings>(DotNetConfig.Config config, IGraphQueryClient client, IGitHubAppAuthenticator authenticator, IHttpClientFactory httpFactory)
: GitHubAsyncCommand<TSettings>(config) where TSettings : SyncSettings, ISponsorableSettings

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.

Check warning on line 101 in src/Commands/SyncCommand.cs

View workflow job for this annotation

GitHub Actions / build

Parameter 'Config config' is captured into the state of the enclosing type and its value is also passed to the base constructor. The value might be captured by the base class as well.
{
public static class ErrorCodes
{
Expand Down Expand Up @@ -330,16 +330,16 @@
}

using var http = httpFactory.CreateClient();
var (status, jwt) = await Status().StartAsync(Sync.Synchronizing(manifest.Sponsorable), async ctx => await SponsorManifest.FetchAsync(manifest, token, http));
if (status == SponsorManifest.Status.NotSponsoring)
var (status, jwt) = await Status().StartAsync(Sync.Synchronizing(manifest.Sponsorable), async ctx => await SponsorManifestFetcher.FetchAsync(manifest, token, http));
if (status == SponsorManifestFetcher.Status.NotSponsoring)
{
var links = string.Join(", ", manifest.Audience.Select(x => $"[link]{x}[/]"));
MarkupLine(Sync.ConsiderSponsoring(manifest.Sponsorable.PadRight(maxlength), links));
result = ErrorCodes.NotSponsoring;
continue;
}

if (status == SponsorManifest.Status.Success)
if (status == SponsorManifestFetcher.Status.Success)
{
File.WriteAllText(Path.Combine(ghDir, manifest.Sponsorable + ".jwt"), jwt, Encoding.UTF8);
var roles = new JsonWebTokenHandler
Expand Down Expand Up @@ -373,14 +373,14 @@
return;

using var http = httpFactory.CreateClient();
var (status, jwt) = await SponsorManifest.FetchAsync(manifest, token, http);
if (status == SponsorManifest.Status.NotSponsoring)
var (status, jwt) = await SponsorManifestFetcher.FetchAsync(manifest, token, http);
if (status == SponsorManifestFetcher.Status.NotSponsoring)
{
var links = string.Join(", ", manifest.Audience.Select(x => $"[link]{x}[/]"));
MarkupLine(Sync.ConsiderSponsoring(manifest.Sponsorable.PadRight(maxlength), links));
result = ErrorCodes.NotSponsoring;
}
else if (status == SponsorManifest.Status.Success)
else if (status == SponsorManifestFetcher.Status.Success)
{
File.WriteAllText(Path.Combine(ghDir, manifest.Sponsorable + ".jwt"), jwt);
var roles = new JsonWebTokenHandler()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Devlooped.Sponsors;
/// <summary>
/// Allows synchronizing client sponsor manifests.
/// </summary>
public class SponsorManifest
public class SponsorManifestFetcher
{
/// <summary>
/// Status of a manifest refresh operation.
Expand All @@ -30,10 +30,10 @@ public enum Status
/// <summary>
/// Refreshes the sponsor manifest for the given sponsorable account.
/// </summary>
/// <param name="accessToken">The access token to use for fetching the manifest, must be an OAuth token issued by GitHub for the sponsorable app..</param>
/// <param name="accessToken">The access token to use for fetching the manifest, must be an OAuth token issued by GitHub for the sponsorable app, representing the sponsoring user.</param>
/// <param name="manifest">The SponsorLink manifest provided by the sponsorable account.</param>
/// <param name="jwt">The sponsor manifest token, if sponsoring.</param>
/// <returns>The status of the manifest synchronization.</returns>
/// <returns>The status of the manifest synchronization and the optional JWT of the authenticated user if validation succeeded.</returns>
public static async Task<(Status, string?)> FetchAsync(SponsorableManifest manifest, string accessToken, HttpClient? http = default)
{
var disposeHttp = http == null;
Expand Down
Loading