[backend/database] Fixup User.alsoKnownAs
This commit is contained in:
parent
357f11d513
commit
9680921711
6 changed files with 6012 additions and 7 deletions
5963
Iceshrimp.Backend/Core/Database/Migrations/20240210151527_UserAlsoKnownAsToArray.Designer.cs
generated
Normal file
5963
Iceshrimp.Backend/Core/Database/Migrations/20240210151527_UserAlsoKnownAsToArray.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,43 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Iceshrimp.Backend.Core.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class UserAlsoKnownAsToArray : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<List<string>>(name: "alsoKnownAs_new",
|
||||
table: "user",
|
||||
type: "text[]",
|
||||
nullable: true,
|
||||
comment: "URIs the user is known as too");
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE "user" SET "alsoKnownAs_new" = string_to_array("alsoKnownAs", ',') WHERE "alsoKnownAs" IS NOT NULL;
|
||||
ALTER TABLE "user" DROP COLUMN "alsoKnownAs";
|
||||
ALTER TABLE "user" RENAME COLUMN "alsoKnownAs_new" TO "alsoKnownAs";
|
||||
""");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(name: "alsoKnownAs_new",
|
||||
table: "user",
|
||||
type: "text",
|
||||
nullable: true,
|
||||
comment: "URIs the user is known as too");
|
||||
|
||||
migrationBuilder.Sql("""
|
||||
UPDATE "user" SET "alsoKnownAs_new" = array_to_string("alsoKnownAs", ',') WHERE "alsoKnownAs" IS NOT NULL;
|
||||
ALTER TABLE "user" DROP COLUMN "alsoKnownAs";
|
||||
ALTER TABLE "user" RENAME COLUMN "alsoKnownAs_new" TO "alsoKnownAs";
|
||||
""");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3760,8 +3760,8 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
|
|||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("AlsoKnownAs")
|
||||
.HasColumnType("text")
|
||||
b.Property<List<string>>("AlsoKnownAs")
|
||||
.HasColumnType("text[]")
|
||||
.HasColumnName("alsoKnownAs")
|
||||
.HasComment("URIs the user is known as too");
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public class User : IEntity {
|
|||
/// URIs the user is known as too
|
||||
/// </summary>
|
||||
[Column("alsoKnownAs")]
|
||||
public string? AlsoKnownAs { get; set; }
|
||||
public List<string>? AlsoKnownAs { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to speak as a cat if isCat.
|
||||
|
|
|
@ -93,8 +93,7 @@ public class ASActor : ASObject {
|
|||
public ASLink? MovedTo { get; set; }
|
||||
|
||||
[J("https://www.w3.org/ns/activitystreams#alsoKnownAs")]
|
||||
[JC(typeof(ASLinkConverter))]
|
||||
public ASLink? AlsoKnownAs { get; set; }
|
||||
public List<ASLink>? AlsoKnownAs { get; set; } = [];
|
||||
|
||||
[J("http://joinmastodon.org/ns#featured")]
|
||||
[JC(typeof(ASLinkConverter))]
|
||||
|
|
|
@ -75,7 +75,7 @@ public class UserService(
|
|||
UsernameLower = actor.Username!.ToLowerInvariant(),
|
||||
Host = AcctToTuple(acct).Host,
|
||||
MovedToUri = actor.MovedTo?.Link,
|
||||
AlsoKnownAs = actor.AlsoKnownAs?.Link,
|
||||
AlsoKnownAs = actor.AlsoKnownAs?.Where(p => p.Link != null).Select(p => p.Link!).ToList(),
|
||||
IsExplorable = actor.IsDiscoverable ?? false,
|
||||
Inbox = actor.Inbox?.Link,
|
||||
SharedInbox = actor.SharedInbox?.Link ?? actor.Endpoints?.SharedInbox?.Id,
|
||||
|
@ -137,7 +137,7 @@ public class UserService(
|
|||
user.IsLocked = actor.IsLocked ?? false;
|
||||
user.IsBot = actor.IsBot;
|
||||
user.MovedToUri = actor.MovedTo?.Link;
|
||||
user.AlsoKnownAs = actor.AlsoKnownAs?.Link;
|
||||
user.AlsoKnownAs = actor.AlsoKnownAs?.Where(p => p.Link != null).Select(p => p.Link!).ToList();
|
||||
user.IsExplorable = actor.IsDiscoverable ?? false;
|
||||
user.FollowersUri = actor.Followers?.Id;
|
||||
user.IsCat = actor.IsCat ?? false;
|
||||
|
|
Loading…
Add table
Reference in a new issue