attempt to add quote tweets to bird.makeup
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
parent
8598d0e87b
commit
17bac21fd2
6 changed files with 26 additions and 18 deletions
|
@ -17,6 +17,7 @@ namespace BirdsiteLive.ActivityPub
|
|||
{ "PropertyValue", "schema:PropertyValue" },
|
||||
{ "value", "schema:value" },
|
||||
{ "sensitive", "as:sensitive" },
|
||||
{ "quoteUrl", "as:quoteUrl" },
|
||||
|
||||
{ "schema", "http://schema.org#" },
|
||||
{ "toot", "https://joinmastodon.org/ns#" }
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace BirdsiteLive.ActivityPub.Models
|
|||
//public Dictionary<string,string> contentMap { get; set; }
|
||||
public Attachment[] attachment { get; set; }
|
||||
public Tag[] tag { get; set; }
|
||||
//public Dictionary<string, string> replies;
|
||||
//public Dictionary<string, string> replies;
|
||||
|
||||
public string quoteUrl { get; set; }
|
||||
}
|
||||
}
|
|
@ -88,7 +88,8 @@ namespace BirdsiteLive.Domain
|
|||
summary = summary,
|
||||
content = $"<p>{content}</p>",
|
||||
attachment = Convert(tweet.Media),
|
||||
tag = extractedTags.tags
|
||||
tag = extractedTags.tags,
|
||||
quoteUrl = tweet.QuoteTweetUrl
|
||||
};
|
||||
|
||||
return note;
|
||||
|
|
|
@ -17,5 +17,6 @@ namespace BirdsiteLive.Twitter.Models
|
|||
public string RetweetUrl { get; set; }
|
||||
public long RetweetId { get; set; }
|
||||
public TwitterUser OriginalAuthor { get; set; }
|
||||
public string QuoteTweetUrl { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.Common.Settings;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.DAL.Models;
|
||||
using BirdsiteLive.Statistics.Domain;
|
||||
using BirdsiteLive.Twitter.Models;
|
||||
using BirdsiteLive.Twitter.Tools;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.RegularExpressions;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.DAL.Models;
|
||||
|
||||
namespace BirdsiteLive.Twitter
|
||||
{
|
||||
|
@ -307,15 +307,16 @@ namespace BirdsiteLive.Twitter
|
|||
.GetProperty("tweet_results").GetProperty("result").GetProperty("legacy")
|
||||
.GetProperty("is_quote_status").GetBoolean();
|
||||
|
||||
if (isQuoteTweet)
|
||||
string quoteTweetLink = "";
|
||||
if (isQuoteTweet)
|
||||
{
|
||||
|
||||
string quoteTweetLink = tweet.GetProperty("content").GetProperty("itemContent")
|
||||
quoteTweetLink = tweet.GetProperty("content").GetProperty("itemContent")
|
||||
.GetProperty("tweet_results").GetProperty("result").GetProperty("legacy")
|
||||
.GetProperty("quoted_status_permalink").GetProperty("expanded").GetString();
|
||||
quoteTweetLink = quoteTweetLink.Replace("https://twitter.com/", $"https://{_instanceSettings.Domain}/users/");
|
||||
quoteTweetLink = quoteTweetLink.Replace("/status/", "/statuses/");
|
||||
MessageContent = MessageContent + "\n\n" + quoteTweetLink;
|
||||
MessageContent += $@"<span class=""quote-inline""><br><br>RT: <a href=""{quoteTweetLink}"">{quoteTweetLink}</a></span>";
|
||||
}
|
||||
var extractedTweet = new ExtractedTweet
|
||||
{
|
||||
|
@ -332,8 +333,10 @@ namespace BirdsiteLive.Twitter
|
|||
RetweetId = retweetId,
|
||||
OriginalAuthor = OriginalAuthor,
|
||||
};
|
||||
|
||||
return extractedTweet;
|
||||
|
||||
if (isQuoteTweet) extractedTweet.QuoteTweetUrl = quoteTweetLink;
|
||||
|
||||
return extractedTweet;
|
||||
|
||||
}
|
||||
private string GetMediaType(string mediaType, string mediaUrl)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using BirdsiteLive.Common.Settings;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.Statistics.Domain;
|
||||
using BirdsiteLive.Twitter;
|
||||
using BirdsiteLive.Twitter.Tools;
|
||||
using BirdsiteLive.Statistics.Domain;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using BirdsiteLive.DAL.Contracts;
|
||||
using BirdsiteLive.Common.Settings;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace BirdsiteLive.ActivityPub.Tests
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ namespace BirdsiteLive.ActivityPub.Tests
|
|||
{
|
||||
var tweet = await _tweetService.GetTweetAsync(1610807139089383427);
|
||||
|
||||
Assert.AreEqual(tweet.MessageContent, "When you gave them your keys you gave them your coins.\n\nhttps://domain.name/users/kadhim/statuses/1610706613207285773");
|
||||
Assert.AreEqual(tweet.MessageContent, "When you gave them your keys you gave them your coins.<span class=\"quote-inline\"><br><br>RT: <a href=\"https://domain.name/users/kadhim/statuses/1610706613207285773\">https://domain.name/users/kadhim/statuses/1610706613207285773</a></span>");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
Reference in a new issue