Files
api/MareSynchronosAPI/Data/Extensions/GroupPermissionsExtensions.cs
rootdarkarchon 9199d9c667 Mare 0.9 (#17)
* add jwt expiry

* bump api version

* start rework permissions

* ok so in theory this compiles

* update api

* update api

* update api

* update api once more

* oh apiii I hate submodules

* blabla

* we only live to suffer

* stop reading my commit messages

* nothing to see here move along

* update nuget

* some rework

---------

Co-authored-by: rootdarkarchon <root.darkarchon@outlook.com>
2023-10-17 21:36:40 +02:00

50 lines
1.6 KiB
C#

using MareSynchronos.API.Data.Enum;
namespace MareSynchronos.API.Data.Extensions;
public static class GroupPermissionsExtensions
{
public static bool IsDisableInvites(this GroupPermissions perm)
{
return perm.HasFlag(GroupPermissions.DisableInvites);
}
public static bool IsPreferDisableAnimations(this GroupPermissions perm)
{
return perm.HasFlag(GroupPermissions.PreferDisableAnimations);
}
public static bool IsPreferDisableSounds(this GroupPermissions perm)
{
return perm.HasFlag(GroupPermissions.PreferDisableSounds);
}
public static bool IsPreferDisableVFX(this GroupPermissions perm)
{
return perm.HasFlag(GroupPermissions.PreferDisableVFX);
}
public static void SetDisableInvites(this ref GroupPermissions perm, bool set)
{
if (set) perm |= GroupPermissions.DisableInvites;
else perm &= ~GroupPermissions.DisableInvites;
}
public static void SetPreferDisableAnimations(this ref GroupPermissions perm, bool set)
{
if (set) perm |= GroupPermissions.PreferDisableAnimations;
else perm &= ~GroupPermissions.PreferDisableAnimations;
}
public static void SetPreferDisableSounds(this ref GroupPermissions perm, bool set)
{
if (set) perm |= GroupPermissions.PreferDisableSounds;
else perm &= ~GroupPermissions.PreferDisableSounds;
}
public static void SetPreferDisableVFX(this ref GroupPermissions perm, bool set)
{
if (set) perm |= GroupPermissions.PreferDisableVFX;
else perm &= ~GroupPermissions.PreferDisableVFX;
}
}