give actor the followers collection
This commit is contained in:
parent
a965b013e3
commit
c86847a146
|
@ -12,11 +12,13 @@ namespace BirdsiteLive.ActivityPub
|
|||
public string[] context { get; set; } = new[] { "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1" };
|
||||
public string id { get; set; }
|
||||
public string type { get; set; }
|
||||
public string followers { get; set; }
|
||||
public string preferredUsername { get; set; }
|
||||
public string name { get; set; }
|
||||
public string summary { get; set; }
|
||||
public string url { get; set; }
|
||||
public string inbox { get; set; }
|
||||
public bool? discoverable { get; set; } = true;
|
||||
public PublicKey publicKey { get; set; }
|
||||
public Image icon { get; set; }
|
||||
public Image image { get; set; }
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
using BirdsiteLive.ActivityPub.Converters;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BirdsiteLive.ActivityPub.Models
|
||||
{
|
||||
public class Followers
|
||||
{
|
||||
[JsonProperty("@context")]
|
||||
[JsonConverter(typeof(ContextArrayConverter))]
|
||||
public string context { get; set; } = "https://www.w3.org/ns/activitystreams";
|
||||
|
||||
public string id { get; set; }
|
||||
public string type { get; set; } = "OrderedCollection";
|
||||
}
|
||||
}
|
|
@ -48,7 +48,8 @@ namespace BirdsiteLive.Domain
|
|||
var user = new Actor
|
||||
{
|
||||
id = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}",
|
||||
type = "Person",
|
||||
type = "Service", //Person Service
|
||||
followers = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}/followers",
|
||||
preferredUsername = twitterUser.Acct,
|
||||
name = twitterUser.Name,
|
||||
inbox = $"https://{_instanceSettings.Domain}/users/{twitterUser.Acct}/inbox",
|
||||
|
|
|
@ -3,9 +3,11 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.ActivityPub;
|
||||
using BirdsiteLive.ActivityPub.Models;
|
||||
using BirdsiteLive.Common.Settings;
|
||||
using BirdsiteLive.Domain;
|
||||
using BirdsiteLive.Models;
|
||||
|
@ -56,7 +58,7 @@ namespace BirdsiteLive.Controllers
|
|||
Acct = user.Acct,
|
||||
Url = user.Url,
|
||||
ProfileImageUrl = user.ProfileImageUrl,
|
||||
|
||||
|
||||
InstanceHandle = $"@{user.Acct}@{_instanceSettings.Domain}"
|
||||
};
|
||||
return View(displayableUser);
|
||||
|
@ -95,7 +97,7 @@ namespace BirdsiteLive.Controllers
|
|||
using (var reader = new StreamReader(Request.Body))
|
||||
{
|
||||
var body = await reader.ReadToEndAsync();
|
||||
System.IO.File.WriteAllText($@"C:\apdebug\{Guid.NewGuid()}.json", body);
|
||||
//System.IO.File.WriteAllText($@"C:\apdebug\{Guid.NewGuid()}.json", body);
|
||||
|
||||
var activity = ApDeserializer.ProcessActivity(body);
|
||||
// Do something
|
||||
|
@ -130,6 +132,21 @@ namespace BirdsiteLive.Controllers
|
|||
return Accepted();
|
||||
}
|
||||
|
||||
[Route("/users/{id}/followers")]
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Followers(string id)
|
||||
{
|
||||
var r = Request.Headers["Accept"].First();
|
||||
if (!r.Contains("application/activity+json")) return NotFound();
|
||||
|
||||
var followers = new Followers
|
||||
{
|
||||
id = $"https://{_instanceSettings.Domain}/users/{id}/followers"
|
||||
};
|
||||
var jsonApUser = JsonConvert.SerializeObject(followers);
|
||||
return Content(jsonApUser, "application/activity+json; charset=utf-8");
|
||||
}
|
||||
|
||||
private Dictionary<string, string> RequestHeaders(IHeaderDictionary header)
|
||||
{
|
||||
return header.ToDictionary<KeyValuePair<string, StringValues>, string, string>(h => h.Key.ToLowerInvariant(), h => h.Value);
|
||||
|
|
Loading…
Reference in New Issue