a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/federation] Automatically approve QuoteRequest activities

Kopper c65c20f5 edf73a73

+31 -3
+1 -1
Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs
··· 669 669 670 670 public static IQueryable<InteractionStamp> IncludeCommonProperties(this IQueryable<InteractionStamp> query) 671 671 { 672 - return query.Include(p => p.Note.User) 672 + return query.Include(p => p.Note) 673 673 .Include(p => p.TargetNote.User); 674 674 } 675 675
+28 -1
Iceshrimp.Backend/Core/Federation/ActivityPub/ActivityHandlerService.cs
··· 29 29 EmojiService emojiSvc, 30 30 EventService eventSvc, 31 31 RelayService relaySvc, 32 - ReportService reportSvc 32 + ReportService reportSvc, 33 + StampService stampSvc 33 34 ) : IScopedService 34 35 { 35 36 public async Task PerformActivityAsync(ASActivity activity, string? inboxUserId, string? authenticatedUserId) ··· 88 89 ASUnfollow unfollow => HandleUnfollowAsync(unfollow, resolvedActor), 89 90 ASUpdate update => HandleUpdateAsync(update, resolvedActor), 90 91 ASFlag flag => HandleFlagAsync(flag, resolvedActor), 92 + ASQuoteRequest quoteRequest => HandleQuoteRequestAsync(quoteRequest, resolvedActor), 91 93 92 94 // Separated for readability 93 95 _ => throw GracefulException.UnprocessableEntity($"Activity type {activity.Type} is unknown") ··· 558 560 throw GracefulException.UnprocessableEntity("Refusing to process ASFlag: note author mismatch"); 559 561 560 562 await reportSvc.CreateReportAsync(resolvedActor, userMatch, noteMatches, [], flag.Content ?? ""); 563 + } 564 + 565 + private async Task HandleQuoteRequestAsync(ASQuoteRequest quoteRequest, User quoter) 566 + { 567 + if (quoter.IsLocalUser) 568 + throw GracefulException.UnprocessableEntity("Refusing to process locally originating quote request via AP"); 569 + 570 + if (quoteRequest.Object?.Id == null) 571 + throw GracefulException.UnprocessableEntity("Object is null"); 572 + 573 + var target = await noteSvc.ResolveNoteAsync(quoteRequest.Object.Id); 574 + if (target == null) 575 + throw GracefulException.UnprocessableEntity("Refusing to process quote request for missing note"); 576 + 577 + if (!target.User.IsLocalUser) 578 + throw GracefulException.UnprocessableEntity("Refusing to process quote request for remote note"); 579 + 580 + if (quoteRequest.Instrument.Id == null) 581 + throw GracefulException.UnprocessableEntity("Instrument is null"); 582 + 583 + var quote = await noteSvc.ResolveNoteAsync(quoteRequest.Instrument.Id, quoteRequest.Instrument as ASNote); 584 + if (quote == null) 585 + throw GracefulException.UnprocessableEntity("Refusing to process quote request for unresolved quote"); 586 + 587 + await stampSvc.AcceptQuoteAsync(target, quote, quoteRequest); 561 588 } 562 589 563 590 private async Task UnfollowAsync(ASActor followeeActor, User follower)
+1 -1
Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASActivity.cs
··· 251 251 [JR] 252 252 [J($"{Constants.ActivityStreamsNs}#instrument")] 253 253 [JC(typeof(ASLinkConverter))] 254 - public required ASNote Instrument { get; set; } 254 + public required ASObjectBase Instrument { get; set; } 255 255 }
+1
Iceshrimp.Backend/Core/Federation/ActivityStreams/Types/ASObject.cs
··· 56 56 ASActivity.Types.Block => token.ToObject<ASBlock>(), 57 57 ASActivity.Types.Move => token.ToObject<ASMove>(), 58 58 ASActivity.Types.Flag => token.ToObject<ASFlag>(), 59 + ASActivity.Types.QuoteRequest => token.ToObject<ASQuoteRequest>(), 59 60 _ => token.ToObject<ASObject>() 60 61 }; 61 62 case JTokenType.Array: