This commit is contained in:
parent
7122a89fb4
commit
47378451b3
4 changed files with 43 additions and 28 deletions
|
@ -4,6 +4,7 @@ using Iceshrimp.Backend.Core.Database;
|
|||
using Iceshrimp.Backend.Core.Database.Tables;
|
||||
using Iceshrimp.Backend.Core.Extensions;
|
||||
using Iceshrimp.Backend.Core.Helpers.LibMfm.Conversion;
|
||||
using Iceshrimp.Backend.Core.Services;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
|
@ -13,7 +14,8 @@ public class UserRenderer(
|
|||
IOptions<Config.InstanceSection> config,
|
||||
IOptionsSnapshot<Config.SecuritySection> security,
|
||||
MfmConverter mfmConverter,
|
||||
DatabaseContext db
|
||||
DatabaseContext db,
|
||||
FlagService flags
|
||||
) : IScopedService
|
||||
{
|
||||
private readonly string _transparent = $"https://{config.Value.WebDomain}/assets/transparent.png";
|
||||
|
@ -75,7 +77,7 @@ public class UserRenderer(
|
|||
IsDiscoverable = user.IsExplorable,
|
||||
Fields = fields?.ToList() ?? [],
|
||||
Emoji = profileEmoji,
|
||||
Role = user.IsAdmin ? "admin" : user.IsModerator ? "moderator" : null
|
||||
Pleroma = flags.IsPleroma.Value ? user.Pleroma : null
|
||||
};
|
||||
|
||||
if (localUser is null && security.Value.PublicPreview == Enums.PublicPreview.RestrictedNoMedia) //TODO
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
||||
using Iceshrimp.Shared.Helpers;
|
||||
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
||||
|
||||
|
@ -5,31 +6,31 @@ namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
|||
|
||||
public class AccountEntity : IIdentifiable
|
||||
{
|
||||
[J("username")] public required string Username { get; set; }
|
||||
[J("acct")] public required string Acct { get; set; }
|
||||
[J("fqn")] public required string FullyQualifiedName { get; set; }
|
||||
[J("display_name")] public required string DisplayName { get; set; }
|
||||
[J("locked")] public required bool IsLocked { get; set; }
|
||||
[J("created_at")] public required string CreatedAt { get; set; }
|
||||
[J("followers_count")] public required long FollowersCount { get; set; }
|
||||
[J("following_count")] public required long FollowingCount { get; set; }
|
||||
[J("statuses_count")] public required long StatusesCount { get; set; }
|
||||
[J("note")] public required string Note { get; set; }
|
||||
[J("url")] public required string Url { get; set; }
|
||||
[J("uri")] public required string Uri { get; set; }
|
||||
[J("avatar")] public required string AvatarUrl { get; set; }
|
||||
[J("avatar_static")] public required string AvatarStaticUrl { get; set; }
|
||||
[J("header")] public required string HeaderUrl { get; set; }
|
||||
[J("header_static")] public required string HeaderStaticUrl { get; set; }
|
||||
[J("moved")] public required AccountEntity? MovedToAccount { get; set; }
|
||||
[J("bot")] public required bool IsBot { get; set; }
|
||||
[J("discoverable")] public required bool IsDiscoverable { get; set; }
|
||||
[J("fields")] public required List<Field> Fields { get; set; }
|
||||
[J("source")] public AccountSource? Source { get; set; }
|
||||
[J("emojis")] public required List<EmojiEntity> Emoji { get; set; }
|
||||
[J("id")] public required string Id { get; set; }
|
||||
[J("last_status_at")] public string? LastStatusAt { get; set; }
|
||||
[J("role")] public string? Role { get; set; }
|
||||
[J("username")] public required string Username { get; set; }
|
||||
[J("acct")] public required string Acct { get; set; }
|
||||
[J("fqn")] public required string FullyQualifiedName { get; set; }
|
||||
[J("display_name")] public required string DisplayName { get; set; }
|
||||
[J("locked")] public required bool IsLocked { get; set; }
|
||||
[J("created_at")] public required string CreatedAt { get; set; }
|
||||
[J("followers_count")] public required long FollowersCount { get; set; }
|
||||
[J("following_count")] public required long FollowingCount { get; set; }
|
||||
[J("statuses_count")] public required long StatusesCount { get; set; }
|
||||
[J("note")] public required string Note { get; set; }
|
||||
[J("url")] public required string Url { get; set; }
|
||||
[J("uri")] public required string Uri { get; set; }
|
||||
[J("avatar")] public required string AvatarUrl { get; set; }
|
||||
[J("avatar_static")] public required string AvatarStaticUrl { get; set; }
|
||||
[J("header")] public required string HeaderUrl { get; set; }
|
||||
[J("header_static")] public required string HeaderStaticUrl { get; set; }
|
||||
[J("moved")] public required AccountEntity? MovedToAccount { get; set; }
|
||||
[J("bot")] public required bool IsBot { get; set; }
|
||||
[J("discoverable")] public required bool IsDiscoverable { get; set; }
|
||||
[J("fields")] public required List<Field> Fields { get; set; }
|
||||
[J("source")] public AccountSource? Source { get; set; }
|
||||
[J("emojis")] public required List<EmojiEntity> Emoji { get; set; }
|
||||
[J("id")] public required string Id { get; set; }
|
||||
[J("last_status_at")] public string? LastStatusAt { get; set; }
|
||||
[J("pleroma")] public required PleromaStatusExtensions? Pleroma { get; set; }
|
||||
|
||||
[J("avatar_description")] public required string AvatarDescription { get; set; }
|
||||
[J("header_description")] public required string HeaderDescription { get; set; }
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities;
|
||||
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
||||
|
||||
namespace Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
||||
|
||||
public class PleromaUserExtensions
|
||||
{
|
||||
[J("is_admin")] public required bool IsAdmin { get; set; }
|
||||
[J("is_moderator")] public required bool IsModerator { get; set; }
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using EntityFrameworkCore.Projectables;
|
||||
using Iceshrimp.Backend.Controllers.Pleroma.Schemas.Entities;
|
||||
using Iceshrimp.Backend.Core.Configuration;
|
||||
using Iceshrimp.Backend.Core.Helpers;
|
||||
using Iceshrimp.Shared.Helpers;
|
||||
|
@ -626,7 +627,8 @@ public class User : IIdentifiable
|
|||
? $"https://{webDomain}{PublicUrlPath}"
|
||||
: throw new Exception("Cannot access PublicUrl for remote user");
|
||||
|
||||
[Projectable] public string PublicUrlPath => $"/@{Username}";
|
||||
[Projectable] public string PublicUrlPath => $"/@{Username}";
|
||||
public PleromaStatusExtensions? Pleroma { get; set; }
|
||||
|
||||
public string GetIdenticonUrl(string webDomain) => $"https://{webDomain}{IdenticonUrlPath}";
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue