started working on RT
This commit is contained in:
parent
03414613dd
commit
49efcd1f97
4 changed files with 18 additions and 8 deletions
|
@ -60,13 +60,9 @@ namespace BirdsiteLive.Domain
|
||||||
|
|
||||||
// Replace RT by a link
|
// Replace RT by a link
|
||||||
var content = extractedTags.content;
|
var content = extractedTags.content;
|
||||||
if (content.Contains("{RT}") && tweet.IsRetweet)
|
if (tweet.IsRetweet)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(tweet.RetweetUrl))
|
content = "RT: " + content;
|
||||||
content = content.Replace("{RT}",
|
|
||||||
$@"<a href=""{tweet.RetweetUrl}"" rel=""nofollow noopener noreferrer"" target=""_blank"">RT</a>");
|
|
||||||
else
|
|
||||||
content = content.Replace("{RT}", "RT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string inReplyTo = null;
|
string inReplyTo = null;
|
||||||
|
|
|
@ -13,7 +13,15 @@ namespace BirdsiteLive.Twitter.Extractors
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TweetExtractor : ITweetExtractor
|
public class TweetExtractor : ITweetExtractor
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private readonly ITwitterTweetsService _twitterTweetsService;
|
||||||
|
|
||||||
|
public TweetExtractor(ITwitterTweetsService twitterTweetsService)
|
||||||
|
{
|
||||||
|
_twitterTweetsService = twitterTweetsService;
|
||||||
|
}
|
||||||
|
|
||||||
public ExtractedTweet Extract(JsonElement tweet)
|
public ExtractedTweet Extract(JsonElement tweet)
|
||||||
{
|
{
|
||||||
bool IsRetweet = false;
|
bool IsRetweet = false;
|
||||||
|
@ -33,6 +41,11 @@ namespace BirdsiteLive.Twitter.Extractors
|
||||||
if (first.GetProperty("type").GetString() == "retweeted")
|
if (first.GetProperty("type").GetString() == "retweeted")
|
||||||
{
|
{
|
||||||
IsRetweet = true;
|
IsRetweet = true;
|
||||||
|
var statusId = Int64.Parse(first.GetProperty("id").GetString());
|
||||||
|
var extracted = _twitterTweetsService.GetTweet(statusId);
|
||||||
|
extracted.IsRetweet = true;
|
||||||
|
return extracted;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (first.GetProperty("type").GetString() == "replied_to")
|
if (first.GetProperty("type").GetString() == "replied_to")
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,5 +15,6 @@ namespace BirdsiteLive.Twitter.Models
|
||||||
public bool IsThread { get; set; }
|
public bool IsThread { get; set; }
|
||||||
public bool IsRetweet { get; set; }
|
public bool IsRetweet { get; set; }
|
||||||
public string RetweetUrl { get; set; }
|
public string RetweetUrl { get; set; }
|
||||||
|
public string OriginalAuthor { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -50,7 +50,7 @@ namespace BirdsiteLive.Twitter
|
||||||
{
|
{
|
||||||
await _twitterAuthenticationInitializer.EnsureAuthenticationIsInitialized();
|
await _twitterAuthenticationInitializer.EnsureAuthenticationIsInitialized();
|
||||||
JsonDocument tweet;
|
JsonDocument tweet;
|
||||||
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.twitter.com/2/tweets?ids=" + statusId))
|
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.twitter.com/2/tweets?ids=" + statusId + "&tweet.fields=id,created_at,text,author_id,in_reply_to_user_id,referenced_tweets,attachments,withheld,geo,entities,public_metrics,possibly_sensitive,source,lang,context_annotations,conversation_id,reply_settings&user.fields=name,username"))
|
||||||
{
|
{
|
||||||
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + _twitterAuthenticationInitializer.Token);
|
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + _twitterAuthenticationInitializer.Token);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue