[backend/federation] Render Create in /notes/{id}/activity when not a renote
This commit is contained in:
parent
3e8ba289c3
commit
d22a21c7e7
2 changed files with 13 additions and 12 deletions
|
@ -52,27 +52,28 @@ public class ActivityPubController(
|
|||
|
||||
[HttpGet("/notes/{id}/activity")]
|
||||
[AuthorizedFetch]
|
||||
[OverrideResultType<ASAnnounce>]
|
||||
[OverrideResultType<ASActivity>]
|
||||
[ProducesResults(HttpStatusCode.OK)]
|
||||
[ProducesErrors(HttpStatusCode.NotFound)]
|
||||
public async Task<JObject> GetRenote(string id)
|
||||
public async Task<JObject> GetNoteActivity(string id)
|
||||
{
|
||||
var actor = HttpContext.GetActor();
|
||||
|
||||
var note = await db.Notes
|
||||
.IncludeCommonProperties()
|
||||
.EnsureVisibleFor(actor)
|
||||
.Where(p => p.Id == id && p.UserHost == null && p.IsPureRenote && p.Renote != null)
|
||||
.Where(p => p.Id == id && p.UserHost == null)
|
||||
.FirstOrDefaultAsync() ??
|
||||
throw GracefulException.NotFound("Note not found");
|
||||
|
||||
return ActivityPub.ActivityRenderer
|
||||
.RenderAnnounce(noteRenderer.RenderLite(note.Renote!),
|
||||
note.GetPublicUri(config.Value),
|
||||
userRenderer.RenderLite(note.User),
|
||||
note.Visibility,
|
||||
note.User.GetPublicUri(config.Value) + "/followers")
|
||||
.Compact();
|
||||
var noteActor = userRenderer.RenderLite(note.User);
|
||||
ASActivity activity = note is { IsPureRenote: true, Renote: not null }
|
||||
? ActivityPub.ActivityRenderer.RenderAnnounce(noteRenderer.RenderLite(note.Renote),
|
||||
note.GetPublicUri(config.Value), noteActor, note.Visibility,
|
||||
note.User.GetPublicUri(config.Value) + "/followers")
|
||||
: ActivityPub.ActivityRenderer.RenderCreate(await noteRenderer.RenderAsync(note), noteActor);
|
||||
|
||||
return activity.Compact();
|
||||
}
|
||||
|
||||
[HttpGet("/notes/{id}/replies")]
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ActivityRenderer(
|
|||
|
||||
public static ASCreate RenderCreate(ASNote obj, ASObject actor) => new()
|
||||
{
|
||||
Id = $"{obj.Id}#Create",
|
||||
Id = $"{obj.Id}/activity",
|
||||
Actor = ASActor.FromObject(actor),
|
||||
Object = obj,
|
||||
To = obj.To,
|
||||
|
|
Loading…
Add table
Reference in a new issue