[backend/services] Set denormalized note properties replyUserId and replyuserHost correctly
This commit is contained in:
parent
7fcf9a5179
commit
0d5f987a8d
2 changed files with 26 additions and 14 deletions
|
@ -153,8 +153,11 @@ public class StatusController(
|
|||
|
||||
var visibility = StatusEntity.DecodeVisibility(request.Visibility);
|
||||
var reply = request.ReplyId != null
|
||||
? await db.Notes.Where(p => p.Id == request.ReplyId).EnsureVisibleFor(user).FirstOrDefaultAsync() ??
|
||||
throw GracefulException.BadRequest("Reply target is nonexistent or inaccessible")
|
||||
? await db.Notes.Where(p => p.Id == request.ReplyId)
|
||||
.IncludeCommonProperties()
|
||||
.EnsureVisibleFor(user)
|
||||
.FirstOrDefaultAsync()
|
||||
?? throw GracefulException.BadRequest("Reply target is nonexistent or inaccessible")
|
||||
: null;
|
||||
|
||||
var attachments = request.MediaIds != null
|
||||
|
|
|
@ -69,7 +69,11 @@ public class NoteService(
|
|||
Text = text,
|
||||
Cw = cw,
|
||||
Reply = reply,
|
||||
ReplyUserId = reply?.UserId,
|
||||
ReplyUserHost = reply?.UserHost,
|
||||
Renote = renote,
|
||||
RenoteUserId = renote?.UserId,
|
||||
RenoteUserHost = renote?.UserHost,
|
||||
UserId = user.Id,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UserHost = null,
|
||||
|
@ -182,9 +186,14 @@ public class NoteService(
|
|||
CreatedAt = createdAt,
|
||||
UserHost = user.Host,
|
||||
Visibility = note.GetVisibility(actor),
|
||||
Reply = note.InReplyTo?.Id != null ? await ResolveNoteAsync(note.InReplyTo.Id) : null
|
||||
Reply = note.InReplyTo?.Id != null ? await ResolveNoteAsync(note.InReplyTo.Id) : null,
|
||||
};
|
||||
|
||||
if (dbNote.Reply != null) {
|
||||
dbNote.ReplyUserId = dbNote.Reply.UserId;
|
||||
dbNote.ReplyUserHost = dbNote.Reply.UserHost;
|
||||
}
|
||||
|
||||
if (dbNote.Text is { Length: > 100000 })
|
||||
throw GracefulException.UnprocessableEntity("Content cannot be longer than 100.000 characters");
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue