22 lines
728 B
C#
22 lines
728 B
C#
using PrivaPub.Models.Post;
|
|||
|
|
|
||
|
|
namespace PrivaPub.Federation.Objects
|
||
|
|
{
|
||
|
|
public static class Addressing
|
||
|
|
{
|
||
|
|
public const string Public = "https://www.w3.org/ns/activitystreams#Public";
|
||
|
|
|
||
|
|
public static bool IsPublic(string address) => address is Public or "as:Public" or "Public";
|
||
|
|
|
||
|
|
public static PostVisibility Classify(IReadOnlyCollection<string> to, IReadOnlyCollection<string> cc, string authorFollowers)
|
||
|
|
{
|
||
|
|
if (to.Any(IsPublic))
|
||
|
|
return PostVisibility.Public;
|
||
|
|
if (cc.Any(IsPublic))
|
||
|
|
return PostVisibility.Unlisted;
|
||
|
|
if (!string.IsNullOrEmpty(authorFollowers) && (to.Contains(authorFollowers) || cc.Contains(authorFollowers)))
|
||
|
|
return PostVisibility.FollowersOnly;
|
||
|
|
return PostVisibility.Direct;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|