mirror of
https://github.com/g3rv4/FakeRelay.git
synced 2024-11-21 23:03:07 +01:00
Avoid sending Announce to instances about their own statuses
This commit is contained in:
parent
f3ec35c802
commit
1a7eae9471
7
src/FakeRelay.Core/Extensions.cs
Normal file
7
src/FakeRelay.Core/Extensions.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace FakeRelay.Core;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static bool StartsWithCI(this string s, string prefix) =>
|
||||
s.StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
@ -4,8 +4,14 @@ namespace FakeRelay.Core.Helpers;
|
||||
|
||||
public static class MastodonHelper
|
||||
{
|
||||
public static Task<string> EnqueueStatusToFetchAsync(string targetHost, string statusUrl) =>
|
||||
SendMessageToInboxAsync(targetHost, $@"{{
|
||||
public static async Task<string> EnqueueStatusToFetchAsync(string targetHost, string statusUrl)
|
||||
{
|
||||
if (statusUrl.StartsWithCI($"https://{targetHost}") || statusUrl.StartsWithCI($"http://{targetHost}"))
|
||||
{
|
||||
return "Status ignored, it's local";
|
||||
}
|
||||
|
||||
return await SendMessageToInboxAsync(targetHost, $@"{{
|
||||
""@context"": ""https://www.w3.org/ns/activitystreams"",
|
||||
""actor"": ""https://{Config.Instance.Host}/actor"",
|
||||
""id"": ""https://{Config.Instance.Host}/activities/{Guid.NewGuid()}"",
|
||||
@ -15,6 +21,7 @@ public static class MastodonHelper
|
||||
],
|
||||
""type"": ""Announce""
|
||||
}}");
|
||||
}
|
||||
|
||||
public static async Task<string> SendMessageToInboxAsync(string targetHost, string content)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user