Account contact can be primary

This commit is contained in:
LittleSheep 2025-06-08 19:42:52 +08:00
parent 144b7fcfc2
commit de64f64c0e
5 changed files with 3450 additions and 1 deletions

View File

@ -376,7 +376,8 @@ public class AccountService(
var contact = new AccountContact
{
Type = type,
Content = content
Content = content,
AccountId = account.Id,
};
db.AccountContacts.Add(contact);

View File

@ -66,6 +66,7 @@ public class MagicSpellService(
.Where(c => c.Account.Id == spell.AccountId)
.Where(c => c.Type == AccountContactType.Email)
.Where(c => c.VerifiedAt != null || bypassVerify)
.OrderByDescending(c => c.IsPrimary)
.Include(c => c.Account)
.FirstOrDefaultAsync();
if (contact is null) throw new ArgumentException("Account has no contact method that can use");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class AccountContactCanBePrimary : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "is_primary",
table: "account_contacts",
type: "boolean",
nullable: false,
defaultValue: false);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "is_primary",
table: "account_contacts");
}
}
}

View File

@ -167,6 +167,10 @@ namespace DysonNetwork.Sphere.Migrations
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<bool>("IsPrimary")
.HasColumnType("boolean")
.HasColumnName("is_primary");
b.Property<int>("Type")
.HasColumnType("integer")
.HasColumnName("type");