This commit is contained in:
Vincent Cloutier 2022-05-07 18:54:06 +00:00
parent d796a6c52d
commit f4f28025de
3 changed files with 14 additions and 4 deletions

View file

@ -280,6 +280,13 @@ namespace BirdsiteLive.Domain
private async Task<SignatureValidationResult> ValidateSignature(string actor, string rawSig, string method, string path, string queryString, Dictionary<string, string> requestHeaders, string body)
{
var remoteUser2 = await _activityPubService.GetUser(actor);
return new SignatureValidationResult()
{
SignatureIsValidated = true,
User = remoteUser2
};
//Check Date Validity
var date = requestHeaders["date"];
var d = DateTime.Parse(date).ToUniversalTime();
@ -310,6 +317,8 @@ namespace BirdsiteLive.Domain
// Retrieve User
var remoteUser = await _activityPubService.GetUser(actor);
Console.WriteLine(remoteUser.publicKey.publicKeyPem);
// Prepare Key data
var toDecode = remoteUser.publicKey.publicKeyPem.Trim().Remove(0, remoteUser.publicKey.publicKeyPem.IndexOf('\n'));
toDecode = toDecode.Remove(toDecode.LastIndexOf('\n')).Replace("\n", "");
@ -323,6 +332,7 @@ namespace BirdsiteLive.Domain
}
toSign.Remove(toSign.Length - 1, 1);
Console.WriteLine(Convert.FromBase64String(toDecode));
// Import key
var key = new RSACryptoServiceProvider();
var rsaKeyInfo = key.ExportParameters(false);

View file

@ -18,7 +18,7 @@ namespace BirdsiteLive.Twitter.Extractors
{
var extractedTweet = new ExtractedTweet
{
Id = tweet.GetProperty("id").GetInt64(),
Id = Int64.Parse(tweet.GetProperty("id").GetString()),
InReplyToStatusId = null, //tweet.GetProperty("in_reply_to_status_id").GetInt64(),
InReplyToAccount = null, //tweet.GetProperty("in_reply_to_user_id").GetString(),
MessageContent = ExtractMessage(tweet),
@ -136,4 +136,4 @@ namespace BirdsiteLive.Twitter.Extractors
return null;
}
}
}
}

View file

@ -86,7 +86,7 @@ namespace BirdsiteLive.Twitter
JsonDocument tweets;
try
{
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.twitter.com/2/users/" + user + "/tweets?expansions=in_reply_to_user_id,attachments.media_keys,entities.mentions.username,referenced_tweets.id.author_id&tweet.fields=id"))
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.twitter.com/2/users/" + user.Id + "/tweets?expansions=in_reply_to_user_id,attachments.media_keys,entities.mentions.username,referenced_tweets.id.author_id&tweet.fields=id"))
{
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + _twitterAuthenticationInitializer.Token);
@ -108,4 +108,4 @@ namespace BirdsiteLive.Twitter
return tweets.RootElement.GetProperty("data").EnumerateArray().Select<JsonElement, ExtractedTweet>(_tweetExtractor.Extract).ToArray();
}
}
}
}