[backend/federation] Enforce federation control in ActivityFetcherService
With this there should be no remaining ways for new activities from blocked instances to make it into the database.
This commit is contained in:
parent
ead8e126f1
commit
a7898e8aa9
1 changed files with 8 additions and 1 deletions
|
@ -21,7 +21,8 @@ public class ActivityFetcherService(
|
||||||
HttpRequestService httpRqSvc,
|
HttpRequestService httpRqSvc,
|
||||||
SystemUserService systemUserSvc,
|
SystemUserService systemUserSvc,
|
||||||
DatabaseContext db,
|
DatabaseContext db,
|
||||||
ILogger<ActivityFetcherService> logger
|
ILogger<ActivityFetcherService> logger,
|
||||||
|
FederationControlService fedCtrlSvc
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
private static readonly IReadOnlyCollection<string> AcceptableActivityTypes =
|
private static readonly IReadOnlyCollection<string> AcceptableActivityTypes =
|
||||||
|
@ -78,6 +79,12 @@ public class ActivityFetcherService(
|
||||||
if (requestHost == config.Value.WebDomain || requestHost == config.Value.AccountDomain)
|
if (requestHost == config.Value.WebDomain || requestHost == config.Value.AccountDomain)
|
||||||
throw GracefulException.UnprocessableEntity("Refusing to fetch activity from local domain");
|
throw GracefulException.UnprocessableEntity("Refusing to fetch activity from local domain");
|
||||||
|
|
||||||
|
if (await fedCtrlSvc.ShouldBlockAsync(requestHost))
|
||||||
|
{
|
||||||
|
logger.LogDebug("Refusing to fetch activity from blocked instance");
|
||||||
|
return (null, new Uri(url));
|
||||||
|
}
|
||||||
|
|
||||||
var request = httpRqSvc.GetSigned(url, AcceptableActivityTypes, actor, keypair);
|
var request = httpRqSvc.GetSigned(url, AcceptableActivityTypes, actor, keypair);
|
||||||
var response = await client.SendAsync(request);
|
var response = await client.SendAsync(request);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue