diff --git a/src/permission.nim b/src/permission.nim index c0fca24..d00ab1d 100644 --- a/src/permission.nim +++ b/src/permission.nim @@ -80,4 +80,17 @@ proc addDenyPermission*(perms: Permissions, perm: Permission): Permissions = if ((perms.allowPerms and uint(perm)) == uint(perm)): perms.allowPerms = perms.allowPerms and (not uint(perm)) - perms.denyPerms = perms.denyPerms or uint(perm) \ No newline at end of file + perms.denyPerms = perms.denyPerms or uint(perm) + +proc permissionsToJson*(perms: Permissions): JsonNode = + ## Convert `Permissions` to json. + let json = %* { + "id": perms.roleUserID, + "allow": perms.allowPerms, + "deny": perms.denyPerms + } + + if (perms.permissionType == PermissionType.permTypeMember): + json.add("type", %"member") + else: + json.add("type", %"role") \ No newline at end of file