[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 visibility = StatusEntity.DecodeVisibility(request.Visibility);
|
||||||
var reply = request.ReplyId != null
|
var reply = request.ReplyId != null
|
||||||
? await db.Notes.Where(p => p.Id == request.ReplyId).EnsureVisibleFor(user).FirstOrDefaultAsync() ??
|
? await db.Notes.Where(p => p.Id == request.ReplyId)
|
||||||
throw GracefulException.BadRequest("Reply target is nonexistent or inaccessible")
|
.IncludeCommonProperties()
|
||||||
|
.EnsureVisibleFor(user)
|
||||||
|
.FirstOrDefaultAsync()
|
||||||
|
?? throw GracefulException.BadRequest("Reply target is nonexistent or inaccessible")
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
var attachments = request.MediaIds != null
|
var attachments = request.MediaIds != null
|
||||||
|
|
|
@ -69,7 +69,11 @@ public class NoteService(
|
||||||
Text = text,
|
Text = text,
|
||||||
Cw = cw,
|
Cw = cw,
|
||||||
Reply = reply,
|
Reply = reply,
|
||||||
|
ReplyUserId = reply?.UserId,
|
||||||
|
ReplyUserHost = reply?.UserHost,
|
||||||
Renote = renote,
|
Renote = renote,
|
||||||
|
RenoteUserId = renote?.UserId,
|
||||||
|
RenoteUserHost = renote?.UserHost,
|
||||||
UserId = user.Id,
|
UserId = user.Id,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
UserHost = null,
|
UserHost = null,
|
||||||
|
@ -182,9 +186,14 @@ public class NoteService(
|
||||||
CreatedAt = createdAt,
|
CreatedAt = createdAt,
|
||||||
UserHost = user.Host,
|
UserHost = user.Host,
|
||||||
Visibility = note.GetVisibility(actor),
|
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 })
|
if (dbNote.Text is { Length: > 100000 })
|
||||||
throw GracefulException.UnprocessableEntity("Content cannot be longer than 100.000 characters");
|
throw GracefulException.UnprocessableEntity("Content cannot be longer than 100.000 characters");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue