Skip to content

Commit 6fbc21d

Browse files
committed
Fixed content publish query
1 parent ccaa6a1 commit 6fbc21d

File tree

6 files changed

+15
-21
lines changed

6 files changed

+15
-21
lines changed

src/DragonFly.API.Client/ClientAPI/ClientContentService.ContentItem.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// MIT License
44

55
using System.Net.Http.Json;
6-
using DragonFly.API;
76
using DragonFly.Query;
87

98
namespace DragonFly.API.Client;
@@ -80,19 +79,19 @@ public async Task<QueryResult<ContentItem>> QueryAsync(ContentQuery queryParamet
8079

8180
public async Task<IBackgroundTaskInfo> PublishQueryAsync(ContentQuery query)
8281
{
83-
var response = await Client.PostAsJsonAsync($"api/content/publish", query);
82+
var response = await Client.PostAsJsonAsync($"api/content/publish", query, ApiJsonSerializerDefault.Options);
8483

8584
response.EnsureSuccessStatusCode();
8685

87-
return await response.Content.ReadFromJsonAsync<BackgroundTaskInfo>();
86+
return await response.Content.ReadFromJsonAsync(ApiJsonSerializerContext.Default.BackgroundTaskInfo) ?? throw new ArgumentNullException();
8887
}
8988

9089
public async Task<IBackgroundTaskInfo> UnpublishQueryAsync(ContentQuery query)
9190
{
92-
var response = await Client.PostAsJsonAsync($"api/content/unpublish", query);
91+
var response = await Client.PostAsJsonAsync($"api/content/unpublish", query, ApiJsonSerializerDefault.Options);
9392

9493
response.EnsureSuccessStatusCode();
9594

96-
return await response.Content.ReadFromJsonAsync<BackgroundTaskInfo>();
95+
return await response.Content.ReadFromJsonAsync(ApiJsonSerializerContext.Default.BackgroundTaskInfo) ?? throw new ArgumentNullException();
9796
}
9897
}

src/DragonFly.API.Client/ClientAPI/ClientContentService.ContentSchema.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task<ContentSchema> GetSchemaAsync(string name)
3434

3535
public async Task CreateAsync(ContentSchema entity)
3636
{
37-
var response = await Client.PostAsJsonAsync($"api/schema", entity.ToRest());
37+
var response = await Client.PostAsJsonAsync($"api/schema", entity.ToRest(), ApiJsonSerializerContext.Default.RestContentSchema);
3838

3939
var result = await response.Content.ReadFromJsonAsync(ApiJsonSerializerContext.Default.ResourceCreated);
4040

src/DragonFly.API.Core/Json/ApiJsonSerializerContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace DragonFly.API;
2727
[JsonSerializable(typeof(StructureQuery))]
2828
[JsonSerializable(typeof(WebHookQuery))]
2929
[JsonSerializable(typeof(IBackgroundTaskInfo))]
30+
[JsonSerializable(typeof(BackgroundTaskInfo))]
3031
[JsonSerializable(typeof(IEnumerable<IBackgroundTaskInfo>))]
3132

3233
//AssetMetadata

src/DragonFly.AspNetCore/Extensions/DragonFlyBuilderExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static IDragonFlyBuilder AddDragonFly(this IServiceCollection services)
6161

6262
//builder.Services.AddSingleton<IAuthorizationPolicyProvider, PermissionPolicyProvider>();
6363

64-
builder.Services.AddSignalR();
64+
builder.Services.AddSignalR();
6565

6666
return builder;
6767
}

src/DragonFly.BlockField.Core/Json/BlockFieldSerializerContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ namespace DragonFly.BlockField;
1313
[JsonSerializable(typeof(Document))]
1414

1515
//Blocks
16+
[JsonSerializable(typeof(IEnumerable<Block>))]
17+
1618
[JsonSerializable(typeof(AlertBlock))]
1719
[JsonSerializable(typeof(AssetBlock))]
1820
[JsonSerializable(typeof(CardsBlock))]

src/DragonFly.Core/Modules/ContentItems/Models/Queries/ContentQuery.cs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,35 @@ public ContentQuery(string schema)
1717

1818
public ContentQuery()
1919
{
20-
Schema = string.Empty;
21-
Fields = new List<FieldQuery>();
22-
OrderFields = new List<FieldOrder>();
23-
24-
Take = 25;
25-
Published = true;
26-
27-
IncludeListFieldsOnly = false;
2820
}
2921

3022
/// <summary>
3123
/// Schema
3224
/// </summary>
33-
public string Schema { get; set; }
25+
public string Schema { get; set; } = string.Empty;
3426

3527
/// <summary>
3628
/// Fields
3729
/// </summary>
38-
public IList<FieldQuery> Fields { get; set; }
30+
public IList<FieldQuery> Fields { get; set; } = new List<FieldQuery>();
3931

4032
/// <summary>
4133
/// OrderFields
4234
/// </summary>
43-
public IList<FieldOrder> OrderFields { get; set; }
35+
public IList<FieldOrder> OrderFields { get; set; } = new List<FieldOrder>();
4436

4537
/// <summary>
4638
/// IncludeListFieldsOnly
4739
/// </summary>
48-
public bool IncludeListFieldsOnly { get; set; }
40+
public bool IncludeListFieldsOnly { get; set; } = false;
4941

5042
/// <summary>
5143
/// UsedAsset
5244
/// </summary>
53-
public Guid? UsedAsset { get; set; }
45+
public Guid? UsedAsset { get; set; } = null;
5446

5547
/// <summary>
5648
/// Published
5749
/// </summary>
58-
public bool Published { get; set; }
50+
public bool Published { get; set; } = true;
5951
}

0 commit comments

Comments
 (0)