Browse Source

added shared inbox

master
Nicolas Constant 2 years ago
parent
commit
1724d3a902
No known key found for this signature in database GPG Key ID: 1E9F677FB01A5688
4 changed files with 23 additions and 9 deletions
  1. +3
    -1
      src/BirdsiteLive.ActivityPub/Models/Actor.cs
  2. +7
    -0
      src/BirdsiteLive.ActivityPub/Models/EndPoints.cs
  3. +12
    -7
      src/BirdsiteLive.Domain/UserService.cs
  4. +1
    -1
      src/BirdsiteLive/Controllers/InboxController.cs

+ 3
- 1
src/BirdsiteLive.ActivityPub/Models/Actor.cs View File

@ -1,4 +1,5 @@
using BirdsiteLive.ActivityPub.Converters;
using System.Net;
using BirdsiteLive.ActivityPub.Converters;
using Newtonsoft.Json;
namespace BirdsiteLive.ActivityPub
@ -19,5 +20,6 @@ namespace BirdsiteLive.ActivityPub
public PublicKey publicKey { get; set; }
public Image icon { get; set; }
public Image image { get; set; }
public EndPoints endpoints { get; set; }
}
}

+ 7
- 0
src/BirdsiteLive.ActivityPub/Models/EndPoints.cs View File

@ -0,0 +1,7 @@
namespace BirdsiteLive.ActivityPub
{
public class EndPoints
{
public string sharedInbox { get; set; }
}
}

+ 12
- 7
src/BirdsiteLive.Domain/UserService.cs View File

@ -27,18 +27,19 @@ namespace BirdsiteLive.Domain
private readonly IProcessFollowUser _processFollowUser;
private readonly IProcessUndoFollowUser _processUndoFollowUser;
private readonly InstanceSettings _instanceSettings;
private readonly ICryptoService _cryptoService;
private readonly IActivityPubService _activityPubService;
private readonly string _host;
#region Ctor
public UserService(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IProcessFollowUser processFollowUser, IProcessUndoFollowUser processUndoFollowUser)
{
_instanceSettings = instanceSettings;
_cryptoService = cryptoService;
_activityPubService = activityPubService;
_processFollowUser = processFollowUser;
_processUndoFollowUser = processUndoFollowUser;
_host = $"https://{instanceSettings.Domain.Replace("https://",string.Empty).Replace("http://", string.Empty).TrimEnd('/')}";
//_host = $"https://{instanceSettings.Domain.Replace("https://",string.Empty).Replace("http://", string.Empty).TrimEnd('/')}";
}
#endregion
@ -46,17 +47,17 @@ namespace BirdsiteLive.Domain
{
var user = new Actor
{
id = $"{_host}/users/{twitterUser.Acct}",
id = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}",
type = "Person",
preferredUsername = twitterUser.Acct,
name = twitterUser.Name,
inbox = $"{_host}/users/{twitterUser.Acct}/inbox",
inbox = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}/inbox",
summary = twitterUser.Description,
url = $"{_host}/@{twitterUser.Acct}",
url = $"https://{_instanceSettings.Domain}/@{twitterUser.Acct}",
publicKey = new PublicKey()
{
id = $"{_host}/users/{twitterUser.Acct}#main-key",
owner = $"{_host}/users/{twitterUser.Acct}",
id = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}#main-key",
owner = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}",
publicKeyPem = _cryptoService.GetUserPem(twitterUser.Acct)
},
icon = new Image
@ -68,6 +69,10 @@ namespace BirdsiteLive.Domain
{
mediaType = "image/jpeg",
url = twitterUser.ProfileBannerURL
},
endpoints = new EndPoints
{
sharedInbox = $"{_instanceSettings.Domain}/inbox"
}
};
return user;


+ 1
- 1
src/BirdsiteLive/Controllers/InboxController.cs View File

@ -19,7 +19,7 @@ namespace BirdsiteLive.Controllers
using (var reader = new StreamReader(Request.Body))
{
var body = await reader.ReadToEndAsync();
//System.IO.File.WriteAllText($@"C:\apdebug\inbox\{Guid.NewGuid()}.json", body);
}


Loading…
Cancel
Save