Skip to content

Commit

Permalink
Merge pull request #76 from supermomonga/mstdn
Browse files Browse the repository at this point in the history
Mstdn
  • Loading branch information
supermomonga committed Sep 28, 2017
2 parents ae06597 + 31649ba commit 0ba7813
Show file tree
Hide file tree
Showing 17 changed files with 1,267 additions and 0 deletions.
28 changes: 28 additions & 0 deletions MoEmbed.Core.Tests/Models/Metadata/MastodonMetadataTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Xunit;

namespace MoEmbed.Models.Metadata
{
public class MastodonMetadataTest
{
[Theory]
[InlineData("pawoo.net", 44073070L, " ")]
[InlineData("pawoo.net", 44074120L, "やるき\r\nげ ん き\r\nび ょ う き")]
public async Task DescriptionTest(string host, long id, string expected)
{
var d = await new MastodonMetadata()
{
Host = host,
StatusId = id
}.FetchAsync(new RequestContext(
new MetadataService(),
new ConsumerRequest(new Uri($"https://{host}/@u/{id}"))));

expected = Regex.Replace(expected, @"\r\n", Environment.NewLine);

Assert.Equal(expected, d.Description);
}
}
}
2 changes: 2 additions & 0 deletions MoEmbed.Core.Tests/README.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ dotnet user-secrets set AWSSecretKey yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
dotnet user-secrets set AmazonAssociateTag zzzzzzzz-nn

dotnet user-secrets set ImgurClientId **********

dotnet user-secrets set MastodonInstancesSecretToken ********************************************************************
```
2 changes: 2 additions & 0 deletions MoEmbed.Core/MetadataServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void AddMetadataProviders(this IServiceCollection services)
services.Add(new ServiceDescriptor(typeof(IMetadataProvider), typeof(NicovideoMetadataProvider), ServiceLifetime.Singleton));
services.Add(new ServiceDescriptor(typeof(IMetadataProvider), typeof(DroplrMetadataProvider), ServiceLifetime.Singleton));
services.Add(new ServiceDescriptor(typeof(IMetadataProvider), typeof(AnitvMetadataProvider), ServiceLifetime.Singleton));
services.Add(new ServiceDescriptor(typeof(IMetadataProvider), typeof(MastodonMetadataProvider), ServiceLifetime.Singleton));

foreach (var t in OEmbedProxyMetadataProvider.CreateKnownHandlerTypes())
{
Expand All @@ -46,6 +47,7 @@ public static void ConfigureMetadataProviderOptions(this IServiceCollection serv
{
services.Configure<AmazonMetadataOptions>(configuration);
services.Configure<ImgurMetadataOptions>(configuration);
services.Configure<MastodonMetadataOptions>(configuration);
}
}
}

0 comments on commit 0ba7813

Please sign in to comment.