mirror of
https://github.com/NicolasConstant/BirdsiteLive
synced 2025-06-05 21:49:16 +02:00
added user is gone exception
This commit is contained in:
@@ -11,7 +11,6 @@ using BirdsiteLive.ActivityPub.Models;
|
||||
using BirdsiteLive.Common.Settings;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Org.BouncyCastle.Bcpg;
|
||||
|
||||
namespace BirdsiteLive.Domain
|
||||
{
|
||||
@@ -45,6 +44,12 @@ namespace BirdsiteLive.Domain
|
||||
var httpClient = _httpClientFactory.CreateClient();
|
||||
httpClient.DefaultRequestHeaders.Add("Accept", "application/activity+json");
|
||||
var result = await httpClient.GetAsync(objectId);
|
||||
|
||||
if (result.StatusCode == HttpStatusCode.Gone)
|
||||
throw new UserIsGoneException();
|
||||
|
||||
result.EnsureSuccessStatusCode();
|
||||
|
||||
var content = await result.Content.ReadAsStringAsync();
|
||||
|
||||
var actor = JsonConvert.DeserializeObject<Actor>(content);
|
||||
|
@@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace BirdsiteLive.Domain
|
||||
{
|
||||
public class UserIsGoneException : Exception
|
||||
{
|
||||
}
|
||||
}
|
@@ -185,7 +185,8 @@ namespace BirdsiteLive.Controllers
|
||||
case "Follow":
|
||||
{
|
||||
var succeeded = await _userService.FollowRequestedAsync(signature, r.Method, r.Path,
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers), activity as ActivityFollow, body);
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers),
|
||||
activity as ActivityFollow, body);
|
||||
if (succeeded) return Accepted();
|
||||
else return Unauthorized();
|
||||
}
|
||||
@@ -193,15 +194,18 @@ namespace BirdsiteLive.Controllers
|
||||
if (activity is ActivityUndoFollow)
|
||||
{
|
||||
var succeeded = await _userService.UndoFollowRequestedAsync(signature, r.Method, r.Path,
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers), activity as ActivityUndoFollow, body);
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers),
|
||||
activity as ActivityUndoFollow, body);
|
||||
if (succeeded) return Accepted();
|
||||
else return Unauthorized();
|
||||
}
|
||||
|
||||
return Accepted();
|
||||
case "Delete":
|
||||
{
|
||||
var succeeded = await _userService.DeleteRequestedAsync(signature, r.Method, r.Path,
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers), activity as ActivityDelete, body);
|
||||
r.QueryString.ToString(), HeaderHandler.RequestHeaders(r.Headers),
|
||||
activity as ActivityDelete, body);
|
||||
if (succeeded) return Accepted();
|
||||
else return Unauthorized();
|
||||
}
|
||||
@@ -210,6 +214,10 @@ namespace BirdsiteLive.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (UserIsGoneException)
|
||||
{
|
||||
return Accepted();
|
||||
}
|
||||
catch (UserNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
|
Reference in New Issue
Block a user