commit
670c88a16c
5 changed files with 53 additions and 22 deletions
|
@ -23,5 +23,6 @@ namespace BirdsiteLive.ActivityPub
|
||||||
public Image icon { get; set; }
|
public Image icon { get; set; }
|
||||||
public Image image { get; set; }
|
public Image image { get; set; }
|
||||||
public EndPoints endpoints { get; set; }
|
public EndPoints endpoints { get; set; }
|
||||||
|
public UserAttachment[] attachment { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
src/BirdsiteLive.ActivityPub/Models/UserAttachment.cs
Normal file
9
src/BirdsiteLive.ActivityPub/Models/UserAttachment.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
namespace BirdsiteLive.ActivityPub
|
||||||
|
{
|
||||||
|
public class UserAttachment
|
||||||
|
{
|
||||||
|
public string type { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
public string value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,6 +75,15 @@ namespace BirdsiteLive.Domain
|
||||||
mediaType = "image/jpeg",
|
mediaType = "image/jpeg",
|
||||||
url = twitterUser.ProfileBannerURL
|
url = twitterUser.ProfileBannerURL
|
||||||
},
|
},
|
||||||
|
attachment = new []
|
||||||
|
{
|
||||||
|
new UserAttachment
|
||||||
|
{
|
||||||
|
type = "PropertyValue",
|
||||||
|
name = "Official",
|
||||||
|
value = $"<a href=\"https://twitter.com/{acct}\" rel=\"me nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"ellipsis\">twitter.com/{acct}</span></a>"
|
||||||
|
}
|
||||||
|
},
|
||||||
endpoints = new EndPoints
|
endpoints = new EndPoints
|
||||||
{
|
{
|
||||||
sharedInbox = $"https://{_instanceSettings.Domain}/inbox"
|
sharedInbox = $"https://{_instanceSettings.Domain}/inbox"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<UserSecretsId>d21486de-a812-47eb-a419-05682bb68856</UserSecretsId>
|
<UserSecretsId>d21486de-a812-47eb-a419-05682bb68856</UserSecretsId>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
<Version>0.3.3</Version>
|
<Version>0.4.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -39,8 +39,12 @@ namespace BirdsiteLive.Controllers
|
||||||
[Route("/users")]
|
[Route("/users")]
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
var r = Request.Headers["Accept"].First();
|
var acceptHeaders = Request.Headers["Accept"];
|
||||||
if (r.Contains("application/activity+json")) return NotFound();
|
if (acceptHeaders.Any())
|
||||||
|
{
|
||||||
|
var r = acceptHeaders.First();
|
||||||
|
if (r.Contains("application/activity+json")) return NotFound();
|
||||||
|
}
|
||||||
return View("UserNotFound");
|
return View("UserNotFound");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +52,20 @@ namespace BirdsiteLive.Controllers
|
||||||
[Route("/users/{id}")]
|
[Route("/users/{id}")]
|
||||||
public IActionResult Index(string id)
|
public IActionResult Index(string id)
|
||||||
{
|
{
|
||||||
id = id.Trim(new[] {' ', '@'}).ToLowerInvariant();
|
id = id.Trim(new[] { ' ', '@' }).ToLowerInvariant();
|
||||||
var user = _twitterService.GetUser(id);
|
var user = _twitterService.GetUser(id);
|
||||||
|
|
||||||
var r = Request.Headers["Accept"].First();
|
var acceptHeaders = Request.Headers["Accept"];
|
||||||
if (r.Contains("application/activity+json"))
|
if (acceptHeaders.Any())
|
||||||
{
|
{
|
||||||
if (user == null) return NotFound();
|
var r = acceptHeaders.First();
|
||||||
var apUser = _userService.GetUser(user);
|
if (r.Contains("application/activity+json"))
|
||||||
var jsonApUser = JsonConvert.SerializeObject(apUser);
|
{
|
||||||
return Content(jsonApUser, "application/activity+json; charset=utf-8");
|
if (user == null) return NotFound();
|
||||||
|
var apUser = _userService.GetUser(user);
|
||||||
|
var jsonApUser = JsonConvert.SerializeObject(apUser);
|
||||||
|
return Content(jsonApUser, "application/activity+json; charset=utf-8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user == null) return View("UserNotFound");
|
if (user == null) return View("UserNotFound");
|
||||||
|
@ -79,22 +87,26 @@ namespace BirdsiteLive.Controllers
|
||||||
[Route("/users/{id}/statuses/{statusId}")]
|
[Route("/users/{id}/statuses/{statusId}")]
|
||||||
public IActionResult Tweet(string id, string statusId)
|
public IActionResult Tweet(string id, string statusId)
|
||||||
{
|
{
|
||||||
var r = Request.Headers["Accept"].First();
|
var acceptHeaders = Request.Headers["Accept"];
|
||||||
if (r.Contains("application/activity+json"))
|
if (acceptHeaders.Any())
|
||||||
{
|
{
|
||||||
if (!long.TryParse(statusId, out var parsedStatusId))
|
var r = acceptHeaders.First();
|
||||||
return NotFound();
|
if (r.Contains("application/activity+json"))
|
||||||
|
{
|
||||||
|
if (!long.TryParse(statusId, out var parsedStatusId))
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
var tweet = _twitterService.GetTweet(parsedStatusId);
|
var tweet = _twitterService.GetTweet(parsedStatusId);
|
||||||
if (tweet == null)
|
if (tweet == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|
||||||
//var user = _twitterService.GetUser(id);
|
//var user = _twitterService.GetUser(id);
|
||||||
//if (user == null) return NotFound();
|
//if (user == null) return NotFound();
|
||||||
|
|
||||||
var status = _statusService.GetStatus(id, tweet);
|
var status = _statusService.GetStatus(id, tweet);
|
||||||
var jsonApUser = JsonConvert.SerializeObject(status);
|
var jsonApUser = JsonConvert.SerializeObject(status);
|
||||||
return Content(jsonApUser, "application/activity+json; charset=utf-8");
|
return Content(jsonApUser, "application/activity+json; charset=utf-8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("Tweet", statusId);
|
return View("Tweet", statusId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue