Merge pull request #42 from NicolasConstant/develop

0.5.0 PR
This commit is contained in:
Nicolas Constant 2021-01-12 01:54:14 +01:00 committed by GitHub
commit 75b9dd1030
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 6 deletions

View file

@ -16,11 +16,11 @@ You can find an official (and temporary) instance here: [beta.birdsite.live](htt
## Installation
Please follow [those instructions](https://github.com/NicolasConstant/BirdsiteLive/blob/master/INSTALLATION.md)
I'm providing a [Docker build](https://hub.docker.com/r/nicolasconstant/birdsitelive), to install it on your own server, please follow [those instructions](https://github.com/NicolasConstant/BirdsiteLive/blob/master/INSTALLATION.md).
## License
This project is licensed under the AGPLv3 License - see [LICENSE](https://github.com/NicolasConstant/BirdsiteLive/blob/master/LICENSE) for details
This project is licensed under the AGPLv3 License - see [LICENSE](https://github.com/NicolasConstant/BirdsiteLive/blob/master/LICENSE) for details.
## Contact

File diff suppressed because one or more lines are too long

View file

@ -10,6 +10,7 @@ using BirdsiteLive.ActivityPub.Converters;
using BirdsiteLive.Common.Settings;
using BirdsiteLive.Cryptography;
using BirdsiteLive.Domain.BusinessUseCases;
using BirdsiteLive.Domain.Tools;
using BirdsiteLive.Twitter.Models;
using Tweetinvi.Core.Exceptions;
using Tweetinvi.Models;
@ -31,15 +32,17 @@ namespace BirdsiteLive.Domain
private readonly InstanceSettings _instanceSettings;
private readonly ICryptoService _cryptoService;
private readonly IActivityPubService _activityPubService;
private readonly IStatusExtractor _statusExtractor;
#region Ctor
public UserService(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IProcessFollowUser processFollowUser, IProcessUndoFollowUser processUndoFollowUser)
public UserService(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IProcessFollowUser processFollowUser, IProcessUndoFollowUser processUndoFollowUser, IStatusExtractor statusExtractor)
{
_instanceSettings = instanceSettings;
_cryptoService = cryptoService;
_activityPubService = activityPubService;
_processFollowUser = processFollowUser;
_processUndoFollowUser = processUndoFollowUser;
_statusExtractor = statusExtractor;
//_host = $"https://{instanceSettings.Domain.Replace("https://",string.Empty).Replace("http://", string.Empty).TrimEnd('/')}";
}
#endregion
@ -49,6 +52,14 @@ namespace BirdsiteLive.Domain
var actorUrl = UrlFactory.GetActorUrl(_instanceSettings.Domain, twitterUser.Acct);
var acct = twitterUser.Acct.ToLowerInvariant();
// Extract links, mentions, etc
var description = twitterUser.Description;
if (!string.IsNullOrWhiteSpace(description))
{
var extracted = _statusExtractor.ExtractTags(description);
description = extracted.content;
}
var user = new Actor
{
id = actorUrl,
@ -57,7 +68,7 @@ namespace BirdsiteLive.Domain
preferredUsername = acct,
name = twitterUser.Name,
inbox = $"{actorUrl}/inbox",
summary = twitterUser.Description,
summary = description,
url = actorUrl,
publicKey = new PublicKey()
{

View file

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UserSecretsId>d21486de-a812-47eb-a419-05682bb68856</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<Version>0.4.0</Version>
<Version>0.5.0</Version>
</PropertyGroup>
<ItemGroup>

View file

@ -109,7 +109,7 @@ namespace BirdsiteLive.Controllers
}
}
return View("Tweet", statusId);
return Redirect($"https://twitter.com/{id}/status/{statusId}");
}
[Route("/users/{id}/inbox")]

View file

@ -314,5 +314,26 @@ namespace BirdsiteLive.Domain.Tests.Tools
Assert.IsTrue(result.content.Contains(@"<a href=""https://domain.name/tags/dada"" class=""mention hashtag"" rel=""tag"">#<span>dada</span></a>"));
#endregion
}
[TestMethod]
public void Extract_Emoji_Test()
{
#region Stubs
var message = $"😤@mynickname 😎😍🤗🤩😘";
//var message = $"tests@mynickname";
#endregion
var service = new StatusExtractor(_settings);
var result = service.ExtractTags(message);
#region Validations
Assert.AreEqual(1, result.tags.Length);
Assert.IsTrue(result.content.Contains(
@"😤 <span class=""h-card""><a href=""https://domain.name/@mynickname"" class=""u-url mention"">@<span>mynickname</span></a></span>"));
Assert.IsTrue(result.content.Contains(@"😎 😍 🤗 🤩 😘"));
#endregion
}
}
}