mirror of
https://github.com/g3rv4/FakeRelay.git
synced 2025-08-15 23:47:48 +02:00
Avoid sending Announce to instances about their own statuses
This commit is contained in:
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 class MastodonHelper
|
||||||
{
|
{
|
||||||
public static Task<string> EnqueueStatusToFetchAsync(string targetHost, string statusUrl) =>
|
public static async Task<string> EnqueueStatusToFetchAsync(string targetHost, string statusUrl)
|
||||||
SendMessageToInboxAsync(targetHost, $@"{{
|
{
|
||||||
|
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"",
|
""@context"": ""https://www.w3.org/ns/activitystreams"",
|
||||||
""actor"": ""https://{Config.Instance.Host}/actor"",
|
""actor"": ""https://{Config.Instance.Host}/actor"",
|
||||||
""id"": ""https://{Config.Instance.Host}/activities/{Guid.NewGuid()}"",
|
""id"": ""https://{Config.Instance.Host}/activities/{Guid.NewGuid()}"",
|
||||||
@ -15,6 +21,7 @@ public static class MastodonHelper
|
|||||||
],
|
],
|
||||||
""type"": ""Announce""
|
""type"": ""Announce""
|
||||||
}}");
|
}}");
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> SendMessageToInboxAsync(string targetHost, string content)
|
public static async Task<string> SendMessageToInboxAsync(string targetHost, string content)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user