Split creators out of identity
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using Hutopy.Domain.Constants;
|
||||
using Hutopy.Infrastructure.Identity;
|
||||
using Hutopy.Infrastructure.Identity.OwnedEntities;
|
||||
using Hutopy.Web.Common;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Hutopy.Web.Features.Messages.Data;
|
||||
@@ -38,10 +37,14 @@ internal class TestDataSeeder(
|
||||
_users.Add(await CreateUserAsync("admin", Roles.Administrator));
|
||||
_users.Add(await CreateUserAsync("userA"));
|
||||
_users.Add(await CreateUserAsync("userB"));
|
||||
|
||||
|
||||
foreach (var creator in _creators)
|
||||
{
|
||||
_users.Add(await CreateCreatorAsync(creator));
|
||||
var creatorUser = await CreateUserAsync(creator.Name, Roles.Creator);
|
||||
|
||||
creator.Id = creatorUser.Id;
|
||||
|
||||
await contentContext.Creators.AddAsync(creator);
|
||||
|
||||
var contents = GenerateContent(creator, 100);
|
||||
foreach (var content in contents)
|
||||
@@ -59,7 +62,7 @@ internal class TestDataSeeder(
|
||||
}
|
||||
}
|
||||
|
||||
private List<Content> GenerateContent(ApplicationUser user, int contentCount)
|
||||
private List<Content> GenerateContent(Creator creator, int contentCount)
|
||||
{
|
||||
var currentDate = DateTimeOffset.UtcNow;
|
||||
|
||||
@@ -70,10 +73,10 @@ internal class TestDataSeeder(
|
||||
var content = new Content
|
||||
{
|
||||
Id = GuidHelper.GenerateUuidV7(),
|
||||
CreatedBy = Guid.Parse(user.Id),
|
||||
CreatedBy = creator.Id,
|
||||
CreatedAt = currentDate,
|
||||
Title = $"Title {user.UserName}-{c}",
|
||||
Description = $"Description {user.UserName}-{c}"
|
||||
Title = $"Title {creator.Name}-{c}",
|
||||
Description = $"Description {creator.Name}-{c}"
|
||||
};
|
||||
|
||||
contentContext.Contents.Add(content);
|
||||
@@ -103,9 +106,9 @@ internal class TestDataSeeder(
|
||||
Id = GuidHelper.GenerateUuidV7(),
|
||||
SubjectId = content.Id,
|
||||
CreatedAt = currentDate,
|
||||
CreatedBy = Guid.Parse(author.Id),
|
||||
CreatedBy = author.Id,
|
||||
CreatedByName = author.Alias ?? $"{author.FirstName} {author.LastName}",
|
||||
CreatedByPortraitUrl = author.StoredDataUrls.ProfilePictureUrl,
|
||||
CreatedByPortraitUrl = author.PortraitUrl,
|
||||
Value = $"Message #{m} on {content.Title}"
|
||||
};
|
||||
|
||||
@@ -133,9 +136,9 @@ internal class TestDataSeeder(
|
||||
Id = GuidHelper.GenerateUuidV7(),
|
||||
SubjectId = content.Id,
|
||||
ParentId = parent.Id,
|
||||
CreatedBy = Guid.Parse(author.Id),
|
||||
CreatedBy = author.Id,
|
||||
CreatedByName = author.Alias ?? $"{author.FirstName} {author.LastName}",
|
||||
CreatedByPortraitUrl = author.StoredDataUrls.ProfilePictureUrl,
|
||||
CreatedByPortraitUrl = author.PortraitUrl,
|
||||
CreatedAt = currentDate,
|
||||
Value = $"Reply {r} to {parent.Value} on {content.Title}"
|
||||
};
|
||||
@@ -167,49 +170,38 @@ internal class TestDataSeeder(
|
||||
return user;
|
||||
}
|
||||
|
||||
private async Task<ApplicationUser> CreateCreatorAsync(ApplicationUser creator)
|
||||
{
|
||||
await userManager.CreateAsync(creator, DefaultPassword);
|
||||
await userManager.AddToRolesAsync(creator, new[] { Roles.Creator });
|
||||
return creator;
|
||||
}
|
||||
|
||||
|
||||
private readonly List<ApplicationUser> _users =
|
||||
[
|
||||
];
|
||||
|
||||
|
||||
private readonly static ApplicationUser Hutopy = new()
|
||||
private readonly static Creator HutopyCreator = new()
|
||||
{
|
||||
UserName = "hutopy@test",
|
||||
Email = "hutopy@test",
|
||||
EmailConfirmed = true,
|
||||
CreatorAlias = "hutopy",
|
||||
FirstName = "FirstName of a Brand/Creator",
|
||||
LastName = "LastName of a Brand/Creator",
|
||||
About = "Page officielle",
|
||||
Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!",
|
||||
ProfileColors = new ProfileColors
|
||||
Name = "hutopy",
|
||||
About = new()
|
||||
{
|
||||
BannerTop = "A30E79", BannerBottom = "6B0065", Accent = "23393B", Menu = "53B93B",
|
||||
Title = "Page officielle",
|
||||
Description = "Site officiel pour Hutopy. Venez-nous-y retrouver avec tous vos fans!",
|
||||
},
|
||||
ProfileColors = new()
|
||||
{
|
||||
BannerTop = "#A30E79", BannerBottom = "#6B0065", Accent = "#23393B", Menu = "#53B93B",
|
||||
},
|
||||
SocialNetworks =
|
||||
new SocialNetworks
|
||||
new()
|
||||
{
|
||||
XUrl = "https://twitter.com/Hutopyinc",
|
||||
FacebookUrl = "https://www.facebook.com/Hutopy",
|
||||
InstagramUrl = "https://www.instagram.com/hutopy.inc/"
|
||||
},
|
||||
StoredDataUrls = new StoredDataUrls
|
||||
StoredDataUrls = new()
|
||||
{
|
||||
BannerPictureUrl = "/images/usersmedia/HutopyProfile/banners/banner01.png",
|
||||
ProfilePictureUrl = "/images/usersmedia/HutopyProfile/profilepictures/profileHutopyProfile01.png"
|
||||
}
|
||||
};
|
||||
|
||||
private readonly ApplicationUser[] _creators =
|
||||
private readonly Creator[] _creators =
|
||||
[
|
||||
Hutopy
|
||||
HutopyCreator
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user