QT tweaks
This commit is contained in:
parent
01acc03dca
commit
26e5036870
4 changed files with 55 additions and 10 deletions
|
@ -327,8 +327,16 @@ namespace BirdsiteLive.Twitter
|
|||
string 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/");
|
||||
Uri test = new Uri(quoteTweetLink);
|
||||
string quoteTweetAcct = test.Segments[1].Replace("/", "");
|
||||
string quoteTweetId = test.Segments[3];
|
||||
|
||||
quoteTweetLink = quoteTweetLink.Replace("https://twitter.com/", $"https://{_instanceSettings.Domain}/@");
|
||||
quoteTweetLink = quoteTweetLink.Replace("/status/", "/");
|
||||
|
||||
//MessageContent.Replace($"https://twitter.com/i/web/status/{}", "");
|
||||
MessageContent = MessageContent.Replace($"https://twitter.com/{quoteTweetAcct}/status/{quoteTweetId}", "");
|
||||
|
||||
MessageContent = MessageContent + "\n\n" + quoteTweetLink;
|
||||
}
|
||||
|
||||
|
|
|
@ -202,15 +202,16 @@ namespace BirdsiteLive.Controllers
|
|||
id = parsedStatusId,
|
||||
content = status.apObject.content,
|
||||
created_at = status.published,
|
||||
uri = $"https://{_instanceSettings.Domain}/users/{tweet.Author.Acct}/statuses/{tweet.Id}",
|
||||
url = $"https://{_instanceSettings.Domain}/@{tweet.Author.Acct}/{tweet.Id}",
|
||||
uri = $"https://{_instanceSettings.Domain}/users/{tweet.Author.Acct.ToLower()}/statuses/{tweet.Id}",
|
||||
url = $"https://{_instanceSettings.Domain}/@{tweet.Author.Acct.ToLower()}/{tweet.Id}",
|
||||
account = new MastodonUserApi()
|
||||
{
|
||||
Id = user.Id,
|
||||
id = user.Id,
|
||||
username = user.Acct,
|
||||
acct = user.Acct,
|
||||
display_name = user.Name,
|
||||
Note = user.Description,
|
||||
note = user.Description,
|
||||
url = $"https://{_instanceSettings.Domain}/@{tweet.Author.Acct.ToLower()}",
|
||||
avatar = user.ProfileImageUrl,
|
||||
avatar_static = user.ProfileImageUrl,
|
||||
header = user.ProfileBannerURL,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BirdsiteLive.Models;
|
||||
|
||||
|
@ -20,18 +21,26 @@ public class MastodonPostApi
|
|||
public string content { get; set; }
|
||||
public MastodonUserApi account { get; set; }
|
||||
public MastodonAppApi application { get; } = new MastodonAppApi();
|
||||
|
||||
public List<MastodonAppApi> media_attachments { get; set; } = new List<MastodonAppApi>();
|
||||
public List<MastodonAppApi> mentions { get; set; } = new List<MastodonAppApi>();
|
||||
public List<MastodonAppApi> tags { get; set; } = new List<MastodonAppApi>();
|
||||
public List<MastodonAppApi> emojis { get; set; } = new List<MastodonAppApi>();
|
||||
public string card { get; set; }
|
||||
public string poll { get; set; }
|
||||
public string reblog { get; set; }
|
||||
}
|
||||
public class MastodonUserApi
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long id { get; set; }
|
||||
public string username { get; set; }
|
||||
public string acct { get; set; }
|
||||
public string display_name { get; set; }
|
||||
public bool locked { get; set; } = false;
|
||||
public bool bot { get; set; } = true;
|
||||
public bool group { get; set; } = false;
|
||||
public string Note { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string note { get; set; }
|
||||
public string url { get; set; }
|
||||
public string avatar { get; set; }
|
||||
public string avatar_static { get; set; }
|
||||
public string header { get; set; }
|
||||
|
@ -39,6 +48,9 @@ public class MastodonUserApi
|
|||
public int followers_count { get; set; } = 0;
|
||||
public int following_count { get; set; } = 0;
|
||||
public int statuses_count { get; set; } = 0;
|
||||
|
||||
public List<MastodonAppApi> fields { get; set; } = new List<MastodonAppApi>();
|
||||
public List<MastodonAppApi> emojis { get; set; } = new List<MastodonAppApi>();
|
||||
}
|
||||
|
||||
public class MastodonAppApi
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace BirdsiteLive.ActivityPub.Tests
|
|||
public class TweetTests
|
||||
{
|
||||
private ITwitterTweetsService _tweetService;
|
||||
|
||||
[TestInitialize]
|
||||
public async Task TestInit()
|
||||
{
|
||||
|
@ -39,6 +40,7 @@ namespace BirdsiteLive.ActivityPub.Tests
|
|||
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public async Task SimpleTextTweet()
|
||||
{
|
||||
|
@ -107,10 +109,32 @@ 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.\n\nhttps://domain.name/@kadhim/1610706613207285773");
|
||||
Assert.AreEqual(tweet.Author.Acct, "RyanSAdams");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task QTandTextContainsLink()
|
||||
{
|
||||
var tweet = await _tweetService.GetTweetAsync(1668932525522305026);
|
||||
|
||||
Assert.AreEqual(tweet.MessageContent, @"https://domain.name/@WeekInEthNews/1668684659855880193");
|
||||
Assert.AreEqual(tweet.Author.Acct, "WeekInEthNews");
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
[TestMethod]
|
||||
public async Task QTandTextContainsWebLink()
|
||||
{
|
||||
var tweet = await _tweetService.GetTweetAsync(1668969663340871682);
|
||||
|
||||
Assert.AreEqual(tweet.MessageContent, @"Friends, our Real World Risk Workshop (now transformed into summer school) #RWRI (18th ed.) takes place July 10-21 (remote).
|
||||
We have a few scholarships left but more importantly we are looking for a guest speaker on AI-LLM-Robotics for a 45 Q&A with us.
|
||||
|
||||
http://www.realworldrisk.com https://twitter.com/i/web/status/1668969663340871682");
|
||||
Assert.AreEqual(tweet.Author.Acct, "nntaleb");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SimpleThread()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue