[backend] Add UserProfile.Role

This commit is contained in:
pancakes 2024-11-16 19:12:54 +10:00 committed by Laura Hausmann
parent 1c587584bc
commit 14201c8489
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 16 additions and 1 deletions

View file

@ -47,6 +47,12 @@ public class UserProfileRenderer(DatabaseContext db)
Verified = p.IsVerified
});
var role = user.IsAdmin
? Role.Admin
: user.IsModerator
? Role.Moderator
: Role.None;
return new UserProfileResponse
{
Id = user.Id,
@ -56,7 +62,8 @@ public class UserProfileRenderer(DatabaseContext db)
Location = user.UserProfile?.Location,
Followers = followers,
Following = following,
Relations = relations
Relations = relations,
Role = role
};
}

View file

@ -10,6 +10,7 @@ public class UserProfileResponse
public required int? Followers { get; set; }
public required int? Following { get; set; }
public required Relations Relations { get; set; }
public required Role Role { get; set; }
}
[Flags]
@ -25,6 +26,13 @@ public enum Relations
Muting = 64
}
public enum Role
{
None = 0,
Moderator = 1,
Admin = 2
}
public class UserProfileField
{
public required string Name { get; set; }