Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetBlob to return byte[] #114

Merged
merged 1 commit into from
Dec 2, 2024
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
2 changes: 1 addition & 1 deletion src/FishyFlip/Lexicon/Com/Atproto/Sync/ATProtoSync.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal ATProtoSync(ATProtocol atp)
/// <param name="did"></param>
/// <param name="cid"></param>
/// <param name="cancellationToken"></param>
public Task<Result<Success?>> GetBlobAsync (FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default)
public Task<Result<byte[]?>> GetBlobAsync (FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default)
{
return atp.GetBlobAsync(did, cid, cancellationToken);
}
Expand Down
6 changes: 3 additions & 3 deletions src/FishyFlip/Lexicon/Com/Atproto/Sync/SyncEndpoints.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static class SyncEndpoints
/// <param name="did"></param>
/// <param name="cid"></param>
/// <param name="cancellationToken"></param>
/// <returns>Result of <see cref="Success?"/></returns>
public static Task<Result<Success?>> GetBlobAsync (this FishyFlip.ATProtocol atp, FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default)
/// <returns>Result of <see cref="byte[]?"/></returns>
public static Task<Result<byte[]?>> GetBlobAsync (this FishyFlip.ATProtocol atp, FishyFlip.Models.ATDid did, string cid, CancellationToken cancellationToken = default)
{
var endpointUrl = GetBlob.ToString();
endpointUrl += "?";
Expand All @@ -58,7 +58,7 @@ public static class SyncEndpoints
queryStrings.Add("cid=" + cid);

endpointUrl += string.Join("&", queryStrings);
return atp.Client.Get<Success>(endpointUrl, atp.Options.SourceGenerationContext.Success!, atp.Options.JsonSerializerOptions, cancellationToken, atp.Options.Logger);
return atp.Client.GetBlob(endpointUrl, SourceGenerationContext.Default.Options, cancellationToken, atp.Options.Logger);
}


Expand Down
10 changes: 10 additions & 0 deletions tools/FFSourceGen/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,11 @@ private async Task GenerateEndpointGroupAsync(IGrouping<string, ClassGeneration>
sb.AppendLine(
$" return atp.Client.GetCarAsync(endpointUrl, atp.Options.JsonSerializerOptions, cancellationToken, atp.Options.Logger, onDecoded);");
}
else if (outputProperty == "byte[]")
{
sb.AppendLine(
$" return atp.Client.GetBlob(endpointUrl, SourceGenerationContext.Default.Options, cancellationToken, atp.Options.Logger);");
}
else
{
sb.AppendLine(
Expand Down Expand Up @@ -1371,6 +1376,11 @@ private string PropertyNameToCSharpSafeValue(string propertyName)

private string FetchOutputProperties(ClassGeneration classGeneration)
{
if (classGeneration.Definition.Output?.Encoding == "*/*")
{
return "byte[]";
}

if (classGeneration.Definition.Output?.Schema is null)
{
return "Success";
Expand Down