[backend/federation] Handle invalid activities in InboxValidationMiddleware more gracefully
This commit is contained in:
parent
8ebef17938
commit
58e9d343ac
1 changed files with 23 additions and 1 deletions
|
@ -60,7 +60,29 @@ public class InboxValidationMiddleware(
|
||||||
|
|
||||||
var body = await new StreamReader(request.Body).ReadToEndAsync(ct);
|
var body = await new StreamReader(request.Body).ReadToEndAsync(ct);
|
||||||
request.Body.Seek(0, SeekOrigin.Begin);
|
request.Body.Seek(0, SeekOrigin.Begin);
|
||||||
var expanded = LdHelpers.Expand(JToken.Parse(body));
|
|
||||||
|
JToken parsed;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parsed = JToken.Parse(body);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.LogDebug("Failed to parse ASObject ({error}), skipping", e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JArray? expanded;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
expanded = LdHelpers.Expand(parsed);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.LogDebug("Failed to expand ASObject ({error}), skipping", e.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (expanded == null)
|
if (expanded == null)
|
||||||
throw new Exception("Failed to expand ASObject");
|
throw new Exception("Failed to expand ASObject");
|
||||||
var obj = ASObject.Deserialize(expanded);
|
var obj = ASObject.Deserialize(expanded);
|
||||||
|
|
Loading…
Add table
Reference in a new issue