[backend/masto-client] Set acct field in note mention correctly

This commit is contained in:
Laura Hausmann 2024-02-12 05:30:02 +01:00
parent 158a4e05ad
commit 6c955262ee
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 4 additions and 3 deletions

View file

@ -80,7 +80,7 @@ public class NoteRenderer(
.Select(u => new Mention {
Id = u.Id,
Username = u.Username,
Acct = u.Acct,
Acct = u.AcctWithPrefix,
Url = u.UserProfile != null
? u.UserProfile.Url ?? u.Uri ?? $"https://{config.Value.WebDomain}/@{u.Username}"
: u.Uri ?? $"https://{config.Value.WebDomain}/@{u.Username}"

View file

@ -149,7 +149,8 @@ public class User : IEntity {
[StringLength(512)]
public string? Host { get; set; }
[NotMapped] [Projectable] public string Acct => "acct:" + Username + (Host != null ? "@" + Host : "");
[NotMapped] [Projectable] public string Acct => Username + (Host != null ? "@" + Host : "");
[NotMapped] [Projectable] public string AcctWithPrefix => "acct:" + Acct;
/// <summary>
/// The inbox URL of the User. It will be null if the origin of the user is local.

View file

@ -130,7 +130,7 @@ public class UserService(
logger.LogDebug("Updating user with uri {uri}", uri);
var actor = await fetchSvc.FetchActorAsync(user.Uri);
actor.Normalize(uri, user.Acct);
actor.Normalize(uri, user.AcctWithPrefix);
user.UserProfile ??= await db.UserProfiles.FirstOrDefaultAsync(p => p.User == user);
user.UserProfile ??= new UserProfile { User = user };