20 lines
No EOL
662 B
C#
20 lines
No EOL
662 B
C#
using Iceshrimp.Backend.Core.Services;
|
|
|
|
namespace Iceshrimp.Backend.Core.Policies;
|
|
|
|
public class UserAgeRejectPolicy(bool enabled, TimeSpan age) : IRejectPolicy
|
|
{
|
|
public string Name => nameof(UserAgeRejectPolicy);
|
|
public bool Enabled => enabled;
|
|
|
|
public bool ShouldReject(NoteService.NoteCreationData data) => DateTime.Now - data.User.CreatedAt < age;
|
|
}
|
|
|
|
public class UserAgeRejectPolicyConfiguration : IPolicyConfiguration<UserAgeRejectPolicy>
|
|
{
|
|
public UserAgeRejectPolicy Apply() => new(Enabled, Age);
|
|
IPolicy IPolicyConfiguration.Apply() => Apply();
|
|
|
|
public bool Enabled { get; set; }
|
|
public TimeSpan Age { get; set; } = TimeSpan.Zero;
|
|
} |