Skip to content

Commit

Permalink
Merge pull request #108 from 0xBADDCAFE/main
Browse files Browse the repository at this point in the history
Trivial fix
  • Loading branch information
supermomonga committed Jul 7, 2023
2 parents f5ff267 + 6edda41 commit 1849fe9
Show file tree
Hide file tree
Showing 19 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion MoEmbed.Core.Tests/Models/Metadata/TwitterMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class TwitterExperimentalMetadataTest
[Theory]
[InlineData(
463440424141459456L,
"US Department of the Interior",
"US Department of the Interior (@Interior)",
"https://pbs.twimg.com/profile_images/432081479/DOI_LOGO_normal.jpg",
"Sunsets don't get much better than this one over @GrandTetonNPS. #nature #sunset http://t.co/YuKy2rcjyU"
)]
Expand Down
14 changes: 12 additions & 2 deletions MoEmbed.Core/Models/Metadata/TwitterExperimentalMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MoEmbed.Models.TweetExperimental;
using MoEmbed.Models.TwitterExperimental;

using Portable.Xaml.Markup;

Expand Down Expand Up @@ -46,6 +46,16 @@ public override async Task<EmbedData> FetchAsync(RequestContext context)
req.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var res = await context.Service.HttpClient.SendAsync(req).ConfigureAwait(false);

if (res.StatusCode == System.Net.HttpStatusCode.NotFound)
{
return new EmbedData()
{
Url = Url,
Title = "Not found",
Description = "Sorry, we can't create an embed for that. It may have been deleted or made private. Please try again.",
};
}

res.EnsureSuccessStatusCode();

var tweet = JsonSerializer.Deserialize<Tweet>(res.Content.ReadAsStream(), new JsonSerializerOptions { Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping });
Expand All @@ -65,7 +75,7 @@ public override async Task<EmbedData> FetchAsync(RequestContext context)
Location = Url,
RestrictionPolicy = RestrictionPolicies.Safe
},
Title = tweet.User.Name,
Title = $"{tweet.User.Name} (@{tweet.User.ScreenName})",
Description = tweet.Text,
Medias = tweet.MediaDetails?.Select(ToMedia).ToList() ?? new(),
RestrictionPolicy = tweet.PossiblySensitive ? RestrictionPolicies.Restricted : RestrictionPolicies.Safe,
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/BackgroundColor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class BackgroundColor

Check warning on line 5 in MoEmbed.Core/Models/TwitterExperimental/BackgroundColor.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'BackgroundColor'
{
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/EditControl.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class EditControl

Check warning on line 6 in MoEmbed.Core/Models/TwitterExperimental/EditControl.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'EditControl'
{
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/Entities.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Entities

Check warning on line 6 in MoEmbed.Core/Models/TwitterExperimental/Entities.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'Entities'
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class ExtMediaAvailability
{
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/Hashtag.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Hashtag
{
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/Large.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Large
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Media.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Media
{
Expand Down
2 changes: 1 addition & 1 deletion MoEmbed.Core/Models/TwitterExperimental/MediaDetail.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class MediaDetail
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Medium.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Medium
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/OriginalInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class OriginalInfo
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Photo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Photo
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Sizes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Sizes
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Small.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Small
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Thumb.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Thumb
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/Tweet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class Tweet
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/User.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class User
{
Expand Down
3 changes: 1 addition & 2 deletions MoEmbed.Core/Models/TwitterExperimental/UserMention.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

// Tweet myDeserializedClass = JsonConvert.DeserializeObject<Tweet>(myJsonResponse);
namespace MoEmbed.Models.TweetExperimental
namespace MoEmbed.Models.TwitterExperimental
{
public class UserMention
{
Expand Down

0 comments on commit 1849fe9

Please sign in to comment.