aaaaaa
continuous-integration/drone/push Build is passing Details

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2023-03-22 18:58:06 +01:00
parent 47560fe88b
commit 8598d0e87b
Signed by: sam
GPG Key ID: 4D8B07C18F31ACBD
7 changed files with 41 additions and 11 deletions

View File

@ -1,12 +1,30 @@
using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Newtonsoft.Json;
namespace BirdsiteLive.ActivityPub
{
public class Activity
{
[Newtonsoft.Json.JsonIgnore]
public static readonly object[] DefaultContext = new object[] {
"https://www.w3.org/ns/activitystreams",
"https://w3id.org/security/v1",
new Dictionary<string, string>
{
{ "Emoji", "toot:Emoji" },
{ "Hashtag", "as:Hashtag" },
{ "PropertyValue", "schema:PropertyValue" },
{ "value", "schema:value" },
{ "sensitive", "as:sensitive" },
{ "schema", "http://schema.org#" },
{ "toot", "https://joinmastodon.org/ns#" }
}
};
[JsonProperty("@context")]
public object context { get; set; }
public object context { get; set; } = DefaultContext;
public string id { get; set; }
public string type { get; set; }
public string actor { get; set; }

View File

@ -9,7 +9,7 @@ namespace BirdsiteLive.ActivityPub
//[JsonPropertyName("@context")]
[JsonProperty("@context")]
[JsonConverter(typeof(ContextArrayConverter))]
public string[] context { get; set; } = new[] { "https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1" };
public object[] context { get; set; } = Activity.DefaultContext;
public string id { get; set; }
public string type { get; set; }
public string followers { get; set; }

View File

@ -7,7 +7,7 @@ namespace BirdsiteLive.ActivityPub.Models
{
[JsonProperty("@context")]
[JsonConverter(typeof(ContextArrayConverter))]
public string context { get; set; } = "https://www.w3.org/ns/activitystreams";
public object[] context { get; set; } = Activity.DefaultContext;
public string id { get; set; }
public string type { get; set; } = "OrderedCollection";

View File

@ -7,7 +7,7 @@ namespace BirdsiteLive.ActivityPub.Models
{
[JsonProperty("@context")]
[JsonConverter(typeof(ContextArrayConverter))]
public string[] context { get; set; } = new[] { "https://www.w3.org/ns/activitystreams" };
public object[] context { get; set; } = Activity.DefaultContext;
public string id { get; set; }
public string announceId { get; set; }

View File

@ -88,7 +88,7 @@ namespace BirdsiteLive.Domain
var signature = _cryptoService.SignAndGetSignatureHeader(date, actorUrl, targetHost, digest, usedInbox);
var client = _httpClientFactory.CreateClient();
var client = _httpClientFactory.CreateClient("BirdsiteLIVE");
client.Timeout = TimeSpan.FromSeconds(2);
var httpRequestMessage = new HttpRequestMessage
{

View File

@ -104,7 +104,7 @@ namespace BirdsiteLive.Domain
mediaType = "image/jpeg",
url = twitterUser.ProfileBannerURL
},
attachment = new []
attachment = new[]
{
new UserAttachment
{
@ -112,6 +112,12 @@ namespace BirdsiteLive.Domain
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>"
},
new UserAttachment
{
type = "PropertyValue",
name = "Disclaimer",
value = "This is an automatically created and managed mirror profile from Twitter. While it reflects exactly the content of the original account, it doesn't provide support for interactions and replies. It is an equivalent view from other 3rd party Twitter client apps and uses the same technical means to provide it."
},
},
endpoints = new EndPoints

View File

@ -51,10 +51,16 @@ namespace BirdsiteLive
services.AddControllersWithViews();
services.AddHttpClient("BirdsiteLIVE", httpClient => {
httpClient.DefaultRequestHeaders.Add("User-Agent", $"BirdsiteLIVE/${Program.VERSION}; +https://{Configuration["Instance:Domain"]}");
});
}
services.AddHttpClient("BirdsiteLIVE", httpClient =>
{
ProductInfoHeaderValue product = new("BirdsiteLIVE", $"fishe");
ProductInfoHeaderValue comment = new($"(+https://{Configuration["Instance:Domain"]})");
httpClient.DefaultRequestHeaders.UserAgent.Add(product);
httpClient.DefaultRequestHeaders.UserAgent.Add(comment);
});
services.AddHttpClient();
}
public void ConfigureContainer(ServiceRegistry services)
{