48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
namespace decePubClient.Models.Types
|
|||
|
|
{
|
||
|
|
/// <summary>Whose notifications a Web Push subscription is pushed (Mastodon's data[policy]): anyone's, those of the
|
||
|
|
/// accounts the persona follows, of its followers, or nobody's. What the persona tells itself (its poll ended, a warning
|
||
|
|
/// from the staff) passes every policy but None.</summary>
|
||
|
|
public enum PushPolicy
|
||
|
|
{
|
||
|
|
All = 0,
|
||
|
|
Followed = 1,
|
||
|
|
Follower = 2,
|
||
|
|
None = 3
|
||
|
|
}
|
||
|
|
|
||
|
|
public static class PushPolicies
|
||
|
|
{
|
||
|
|
/// <summary>The policy as Mastodon's API names it.</summary>
|
||
|
|
public static string Name(PushPolicy policy) => policy switch
|
||
|
|
{
|
||
|
|
PushPolicy.Followed => "followed",
|
||
|
|
PushPolicy.Follower => "follower",
|
||
|
|
PushPolicy.None => "none",
|
||
|
|
_ => "all"
|
||
|
|
};
|
||
|
|
|
||
|
|
/// <summary>A policy Mastodon's API named; all for anything else, as PrivaPub reads a policy left out.</summary>
|
||
|
|
public static PushPolicy Of(string name) => name switch
|
||
|
|
{
|
||
|
|
"followed" => PushPolicy.Followed,
|
||
|
|
"follower" => PushPolicy.Follower,
|
||
|
|
"none" => PushPolicy.None,
|
||
|
|
_ => PushPolicy.All
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
/// <summary>
|
||
|
|
/// The alerts a decePub subscription offers: Mastodon 4.5's names (data[alerts]) that PrivaPub notifies, then Pleroma's
|
||
|
|
/// emoji reactions. PrivaPub keeps admin.sign_up, admin.report, quoted_update, severed_relationships and annual_report
|
||
|
|
/// too, but never fires them, so they are never offered and always sent off.
|
||
|
|
/// </summary>
|
||
|
|
public static class PushAlerts
|
||
|
|
{
|
||
|
|
public static readonly string[] Offered =
|
||
|
|
[
|
||
|
|
"mention", "status", "quote", "update", "poll", "favourite", "reblog", "pleroma:emoji_reaction", "follow", "follow_request",
|
||
|
|
"moderation_warning"
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|