@if ((await AuthorizationService.AuthorizeAsync(User, post, new ReadPermission())).Succeeded)
{
-
Details
+
Details
}
else
{
diff --git a/src/Yavsc.Org/Yavsc.Org.csproj b/src/Yavsc.Org/Yavsc.Org.csproj
index aeb94a8e..6dbceb4a 100644
--- a/src/Yavsc.Org/Yavsc.Org.csproj
+++ b/src/Yavsc.Org/Yavsc.Org.csproj
@@ -9,7 +9,7 @@
https://github.com/pazof/yavsc
1.1.0.0
1.1.0.0
-
1.1.0-beta.1+49.Branch.release-1.0.8-rc3.Sha.5274d7bdf5d14406748a2063b5ae15191aac4359
+
1.1.0-beta.1+148.Branch.release-1.0.8-rc4.Sha.6b161b0fb509fec0ce467aa94f1a450b202af2f0
1.1.0-beta.1
@@ -54,4 +54,4 @@
-
+
\ No newline at end of file
diff --git a/src/Yavsc.Server/Helpers/PayloadHelpers.cs b/src/Yavsc.Server/Helpers/PayloadHelpers.cs
new file mode 100644
index 00000000..cd359bb4
--- /dev/null
+++ b/src/Yavsc.Server/Helpers/PayloadHelpers.cs
@@ -0,0 +1,22 @@
+using Yavsc.Models.Blog;
+
+public static class PayloadHelpers
+{
+ public static object GetPayload(this BlogPost post)
+ {
+ return new
+ {
+ post.Id,
+ post.Title,
+ post.Article,
+ post.DateCreated,
+ post.UserCreated,
+ post.DateModified,
+ post.UserModified,
+ post.AuthorId,
+ ACL = post.GetACL(),
+ Tags = post.GetTags(),
+ post.IsPublished
+ };
+ }
+}
diff --git a/src/Yavsc.Server/Models/Blog/BlogPost.cs b/src/Yavsc.Server/Models/Blog/BlogPost.cs
index 5a2dc58d..e5fd615d 100644
--- a/src/Yavsc.Server/Models/Blog/BlogPost.cs
+++ b/src/Yavsc.Server/Models/Blog/BlogPost.cs
@@ -85,7 +85,7 @@ namespace Yavsc.Models.Blog
public string[] GetTags()
{
- return Tags.Select(t => t.Tag.Name).ToArray();
+ return Tags?.Select(t => t.Tag.Name).ToArray() ?? Array.Empty();
}
[InverseProperty("Post")]
@@ -106,6 +106,7 @@ namespace Yavsc.Models.Blog
[NotMapped]
public bool IsPublished { get; set; }
+ [JsonIgnore]
///
/// Explicit interface implementation of
/// . The underlying
diff --git a/src/Yavsc.Server/Models/Blog/BlogTag.cs b/src/Yavsc.Server/Models/Blog/BlogTag.cs
index 69d428de..1f15a081 100644
--- a/src/Yavsc.Server/Models/Blog/BlogTag.cs
+++ b/src/Yavsc.Server/Models/Blog/BlogTag.cs
@@ -1,14 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;
+using System.Text.Json.Serialization;
using Yavsc.Models.Relationship;
namespace Yavsc.Models.Blog
{
public partial class BlogTag
{
+ [JsonIgnore]
[ForeignKey("PostId")]
public virtual BlogPost Post { get; set; }
public long PostId { get; set; }
+ [JsonIgnore]
[ForeignKey("TagId")]
public virtual Tag Tag{ get; set; }
public long TagId { get; set; }
diff --git a/src/Yavsc.Server/Models/Blog/Comment.cs b/src/Yavsc.Server/Models/Blog/Comment.cs
index acb5e003..4d39d0c2 100644
--- a/src/Yavsc.Server/Models/Blog/Comment.cs
+++ b/src/Yavsc.Server/Models/Blog/Comment.cs
@@ -13,15 +13,17 @@ namespace Yavsc.Models.Blog
[YaStringLength(1024)]
public string Article { get; set; }
-
- [ForeignKeyAttribute(nameof(ReceiverId))][JsonIgnore]
+
+ [JsonIgnore]
+ [ForeignKeyAttribute(nameof(ReceiverId))]
public virtual BlogPost Post { get; set; }
[Required]
public long ReceiverId { get; set; }
public bool Visible { get; set; }
- [ForeignKeyAttribute("AuthorId")][JsonIgnore]
+ [ForeignKeyAttribute("AuthorId")]
+ [JsonIgnore]
public virtual ApplicationUser Author {
get; set;
}
diff --git a/src/Yavsc.Server/Yavsc.Server.csproj b/src/Yavsc.Server/Yavsc.Server.csproj
index 7adb3a78..839e476a 100644
--- a/src/Yavsc.Server/Yavsc.Server.csproj
+++ b/src/Yavsc.Server/Yavsc.Server.csproj
@@ -9,7 +9,7 @@
true
1.1.0.0
1.1.0.0
- 1.1.0-beta.1+49.Branch.release-1.0.8-rc3.Sha.5274d7bdf5d14406748a2063b5ae15191aac4359
+ 1.1.0-beta.1+148.Branch.release-1.0.8-rc4.Sha.6b161b0fb509fec0ce467aa94f1a450b202af2f0
1.1.0-beta.1
@@ -43,4 +43,4 @@
-
+
\ No newline at end of file
diff --git a/src/Yavsc.Tests.Shared/BlogHelpers.cs b/src/Yavsc.Tests.Shared/BlogHelpers.cs
new file mode 100644
index 00000000..ef5a7688
--- /dev/null
+++ b/src/Yavsc.Tests.Shared/BlogHelpers.cs
@@ -0,0 +1,31 @@
+
+namespace Yavsc.Blogs.Tests.Fixtures;
+using static Yavsc.Constants;
+
+public static class BlogHelpers
+{
+ public static string ApiUrl(this IBackendFixture fixture, string apiSubPath)
+ {
+ var secured = fixture.Addresses.FirstOrDefault(a => a.StartsWith("https://"));
+ if (secured is null)
+ {
+ var unsecured = fixture.Addresses.FirstOrDefault(a => a.StartsWith("http://"));
+ if (unsecured is null)
+ {
+ throw new InvalidOperationException("No backend address found");
+ }
+ return $"{unsecured}/{APIPrefix}/{apiSubPath}";
+ }
+ return $"{secured}/{APIPrefix}/{apiSubPath}";
+ }
+
+ public static string BlogAclUrl(this IBackendFixture fixture)
+ => fixture.ApiUrl(BlogAclPath);
+
+ public static string BlogSpotUrl(this IBackendFixture fixture)
+ => fixture.ApiUrl(BlogSpotPath);
+
+ public static string PublishUrl(this IBackendFixture fixture, long id)
+ => fixture.ApiUrl(BlogSpotPath) +"/" + id + "/publish";
+
+}
diff --git a/src/Yavsc.Tests.Shared/IBackendFixture.cs b/src/Yavsc.Tests.Shared/IBackendFixture.cs
new file mode 100644
index 00000000..4e2f009d
--- /dev/null
+++ b/src/Yavsc.Tests.Shared/IBackendFixture.cs
@@ -0,0 +1,13 @@
+
+public interface IBackendFixture
+{
+ ///
+ /// The addresses the fixture bound to.
+ ///
+ IReadOnlyList Addresses { get; }
+
+ ///
+ /// The service provider for the fixture host.
+ ///
+ IServiceProvider Services { get; }
+}
diff --git a/src/Yavsc.Tests.Shared/WebHostFixture.cs b/src/Yavsc.Tests.Shared/WebHostFixture.cs
index 417d29d8..95b23082 100644
--- a/src/Yavsc.Tests.Shared/WebHostFixture.cs
+++ b/src/Yavsc.Tests.Shared/WebHostFixture.cs
@@ -30,7 +30,7 @@ namespace Yavsc.Tests.Shared;
/// mapping are the responsibility of the subclass, through
/// .
///
-public abstract class WebHostFixture : IDisposable
+public abstract class WebHostFixture : IDisposable, IBackendFixture
{
private static readonly Lazy _selfSignedCertificate =
new Lazy(CreateSelfSignedCertificate);
diff --git a/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj b/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
index 7f2f382a..6e7a4c5a 100644
--- a/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
+++ b/src/Yavsc.Tests.Shared/Yavsc.Tests.Shared.csproj
@@ -14,7 +14,7 @@
-->
1.1.0.0
1.1.0.0
- 1.1.0-beta.1+49.Branch.release-1.0.8-rc3.Sha.5274d7bdf5d14406748a2063b5ae15191aac4359
+ 1.1.0-beta.1+148.Branch.release-1.0.8-rc4.Sha.6b161b0fb509fec0ce467aa94f1a450b202af2f0
1.1.0-beta.1
@@ -23,4 +23,7 @@
+
+
+
diff --git a/src/cli/cli.csproj b/src/cli/cli.csproj
index 237ccdd8..49aa64b1 100644
--- a/src/cli/cli.csproj
+++ b/src/cli/cli.csproj
@@ -7,7 +7,7 @@
true
1.1.0.0
1.1.0.0
- 1.1.0-beta.1+49.Branch.release-1.0.8-rc3.Sha.5274d7bdf5d14406748a2063b5ae15191aac4359
+ 1.1.0-beta.1+148.Branch.release-1.0.8-rc4.Sha.6b161b0fb509fec0ce467aa94f1a450b202af2f0
1.1.0-beta.1