Allow ProcessNoteAsync to succeed even if inReplyTo resolution fails
This commit is contained in:
parent
cb3caf4f26
commit
3f333b0c5d
2 changed files with 15 additions and 4 deletions
|
@ -20,8 +20,16 @@ public class ActivityFetcherService(HttpClient client, HttpRequestService httpRq
|
|||
public async Task<IEnumerable<ASObject>> FetchActivityAsync(string url, User actor, UserKeypair keypair) {
|
||||
var request = httpRqSvc.GetSigned(url, ["application/activity+json"], actor, keypair);
|
||||
var response = await client.SendAsync(request);
|
||||
var input = await response.Content.ReadAsStringAsync();
|
||||
var json = JsonConvert.DeserializeObject<JObject?>(input, JsonSerializerSettings);
|
||||
|
||||
if (!response.IsSuccessStatusCode) return [];
|
||||
if (response.Content.Headers.ContentType?.MediaType is
|
||||
not "application/activity+json"
|
||||
and not "application/ld+json"
|
||||
and not "application/json")
|
||||
return [];
|
||||
|
||||
var input = await response.Content.ReadAsStringAsync();
|
||||
var json = JsonConvert.DeserializeObject<JObject?>(input, JsonSerializerSettings);
|
||||
|
||||
var res = LdHelpers.Expand(json) ?? throw new GracefulException("Failed to expand JSON-LD object");
|
||||
return res.Select(p => p.ToObject<ASObject>(new JsonSerializer { Converters = { new ASObjectConverter() } }) ??
|
||||
|
|
|
@ -13,8 +13,11 @@ public class InboxQueue {
|
|||
return new JobQueue<InboxJob>("inbox", InboxQueueProcessorDelegateAsync, 4, redis, prefix);
|
||||
}
|
||||
|
||||
private static async Task InboxQueueProcessorDelegateAsync(InboxJob job, IServiceProvider scope,
|
||||
CancellationToken token) {
|
||||
private static async Task InboxQueueProcessorDelegateAsync(
|
||||
InboxJob job,
|
||||
IServiceProvider scope,
|
||||
CancellationToken token
|
||||
) {
|
||||
var expanded = LdHelpers.Expand(JToken.Parse(job.Body));
|
||||
if (expanded == null) throw new Exception("Failed to expand ASObject");
|
||||
var obj = ASObject.Deserialize(expanded);
|
||||
|
|
Loading…
Add table
Reference in a new issue