✨ Post embed
This commit is contained in:
2137
DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs
generated
Normal file
2137
DysonNetwork.Sphere/Migrations/20250907142032_AddPostEmbedView.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
|||||||
|
using DysonNetwork.Sphere.Post;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DysonNetwork.Sphere.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddPostEmbedView : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<PostEmbedView>(
|
||||||
|
name: "embed_view",
|
||||||
|
table: "posts",
|
||||||
|
type: "jsonb",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "embed_view",
|
||||||
|
table: "posts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -6,6 +6,7 @@ using DysonNetwork.Shared.Data;
|
|||||||
using DysonNetwork.Sphere;
|
using DysonNetwork.Sphere;
|
||||||
using DysonNetwork.Sphere.Chat;
|
using DysonNetwork.Sphere.Chat;
|
||||||
using DysonNetwork.Sphere.Poll;
|
using DysonNetwork.Sphere.Poll;
|
||||||
|
using DysonNetwork.Sphere.Post;
|
||||||
using DysonNetwork.Sphere.WebReader;
|
using DysonNetwork.Sphere.WebReader;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
@@ -557,6 +558,10 @@ namespace DysonNetwork.Sphere.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("edited_at");
|
.HasColumnName("edited_at");
|
||||||
|
|
||||||
|
b.Property<PostEmbedView>("EmbedView")
|
||||||
|
.HasColumnType("jsonb")
|
||||||
|
.HasColumnName("embed_view");
|
||||||
|
|
||||||
b.Property<bool>("ForwardedGone")
|
b.Property<bool>("ForwardedGone")
|
||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasColumnName("forwarded_gone");
|
.HasColumnName("forwarded_gone");
|
||||||
|
@@ -46,6 +46,7 @@ public class Post : ModelBase, IIdentifiedResource, IActivity
|
|||||||
public PostPinMode? PinMode { get; set; }
|
public PostPinMode? PinMode { get; set; }
|
||||||
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Meta { get; set; }
|
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Meta { get; set; }
|
||||||
[Column(TypeName = "jsonb")] public List<ContentSensitiveMark>? SensitiveMarks { get; set; } = [];
|
[Column(TypeName = "jsonb")] public List<ContentSensitiveMark>? SensitiveMarks { get; set; } = [];
|
||||||
|
[Column(TypeName = "jsonb")] public PostEmbedView? EmbedView { get; set; }
|
||||||
|
|
||||||
public int ViewsUnique { get; set; }
|
public int ViewsUnique { get; set; }
|
||||||
public int ViewsTotal { get; set; }
|
public int ViewsTotal { get; set; }
|
||||||
@@ -181,4 +182,21 @@ public class PostAward : ModelBase
|
|||||||
public Guid PostId { get; set; }
|
public Guid PostId { get; set; }
|
||||||
[JsonIgnore] public Post Post { get; set; } = null!;
|
[JsonIgnore] public Post Post { get; set; } = null!;
|
||||||
public Guid AccountId { get; set; }
|
public Guid AccountId { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This model is used to tell the client to render a WebView / iframe
|
||||||
|
/// Usually external website and web pages
|
||||||
|
/// Used as a JSON column
|
||||||
|
/// </summary>
|
||||||
|
public class PostEmbedView
|
||||||
|
{
|
||||||
|
public string Uri { get; set; } = null!;
|
||||||
|
public double? AspectRatio { get; set; }
|
||||||
|
public PostEmbedViewRenderer Renderer { get; set; } = PostEmbedViewRenderer.WebView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum PostEmbedViewRenderer
|
||||||
|
{
|
||||||
|
WebView
|
||||||
|
}
|
||||||
|
@@ -388,6 +388,7 @@ public class PostController(
|
|||||||
public string? Content { get; set; }
|
public string? Content { get; set; }
|
||||||
public PostVisibility? Visibility { get; set; } = PostVisibility.Public;
|
public PostVisibility? Visibility { get; set; } = PostVisibility.Public;
|
||||||
public PostType? Type { get; set; }
|
public PostType? Type { get; set; }
|
||||||
|
public PostEmbedView? EmbedView { get; set; }
|
||||||
[MaxLength(16)] public List<string>? Tags { get; set; }
|
[MaxLength(16)] public List<string>? Tags { get; set; }
|
||||||
[MaxLength(8)] public List<string>? Categories { get; set; }
|
[MaxLength(8)] public List<string>? Categories { get; set; }
|
||||||
[MaxLength(32)] public List<string>? Attachments { get; set; }
|
[MaxLength(32)] public List<string>? Attachments { get; set; }
|
||||||
@@ -441,6 +442,7 @@ public class PostController(
|
|||||||
PublishedAt = request.PublishedAt,
|
PublishedAt = request.PublishedAt,
|
||||||
Type = request.Type ?? PostType.Moment,
|
Type = request.Type ?? PostType.Moment,
|
||||||
Meta = request.Meta,
|
Meta = request.Meta,
|
||||||
|
EmbedView = request.EmbedView,
|
||||||
Publisher = publisher,
|
Publisher = publisher,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -779,6 +781,9 @@ public class PostController(
|
|||||||
if (request.Visibility is not null) post.Visibility = request.Visibility.Value;
|
if (request.Visibility is not null) post.Visibility = request.Visibility.Value;
|
||||||
if (request.Type is not null) post.Type = request.Type.Value;
|
if (request.Type is not null) post.Type = request.Type.Value;
|
||||||
if (request.Meta is not null) post.Meta = request.Meta;
|
if (request.Meta is not null) post.Meta = request.Meta;
|
||||||
|
|
||||||
|
// The same, this field can be null, so update it anyway.
|
||||||
|
post.EmbedView = request.EmbedView;
|
||||||
|
|
||||||
// All the fields are updated when the request contains the specific fields
|
// All the fields are updated when the request contains the specific fields
|
||||||
// But the Poll can be null, so it will be updated whatever it included in requests or not
|
// But the Poll can be null, so it will be updated whatever it included in requests or not
|
||||||
|
Reference in New Issue
Block a user