[backend/razor] Extract identicon url generation into User.IdenticonUrlPath property
This commit is contained in:
parent
7e55d4609b
commit
e9ce3f3fa3
3 changed files with 6 additions and 5 deletions
|
@ -491,8 +491,9 @@ public class User : IEntity
|
|||
[NotMapped] public bool? PrecomputedIsRequested { get; set; }
|
||||
[NotMapped] public bool? PrecomputedIsRequestedBy { get; set; }
|
||||
|
||||
[Projectable] public bool IsLocalUser => Host == null;
|
||||
[Projectable] public bool IsRemoteUser => Host != null;
|
||||
[Projectable] public bool IsLocalUser => Host == null;
|
||||
[Projectable] public bool IsRemoteUser => Host != null;
|
||||
[Projectable] public string IdenticonUrlPath => $"/identicon/{Id}";
|
||||
|
||||
[Key]
|
||||
[Column("id")]
|
||||
|
@ -622,7 +623,7 @@ public class User : IEntity
|
|||
? $"https://{webDomain}/@{Username}"
|
||||
: throw new Exception("Cannot access PublicUrl for remote user");
|
||||
|
||||
public string GetIdenticonUrl(string webDomain) => $"https://{webDomain}/identicon/{Id}";
|
||||
public string GetIdenticonUrl(string webDomain) => $"https://{webDomain}{IdenticonUrlPath}";
|
||||
}
|
||||
|
||||
public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User>
|
||||
|
|
|
@ -19,7 +19,7 @@ else
|
|||
var acct = "@" + note.User.Username + (note.User.IsLocalUser ? "" : "@" + note.User.Host);
|
||||
var displayName = note.User.DisplayName;
|
||||
var username = note.User.Username;
|
||||
var avatarUrl = note.User.AvatarUrl == null || !Model.ShowMedia ? $"/identicon/{note.User.Id}" : note.User.AvatarUrl;
|
||||
var avatarUrl = note.User.AvatarUrl == null || !Model.ShowMedia ? note.User.IdenticonUrlPath : note.User.AvatarUrl;
|
||||
|
||||
<div class="user">
|
||||
<img src="@avatarUrl" class="avatar" alt="User avatar"/>
|
||||
|
|
|
@ -23,7 +23,7 @@ else
|
|||
{
|
||||
<meta name="og:description" content="@bio">
|
||||
}
|
||||
<meta name="og:image" content="@(Model.User.AvatarUrl ?? $"/identicon/{Model.User.Id}")">
|
||||
<meta name="og:image" content="@(Model.User.AvatarUrl ?? Model.User.IdenticonUrlPath)">
|
||||
}
|
||||
|
||||
<div class="user">
|
||||
|
|
Loading…
Add table
Reference in a new issue