✨ Customizable chat nick
This commit is contained in:
@@ -676,6 +676,34 @@ public class ChatRoomController(
|
||||
return Ok(await crs.LoadMemberAccount(member));
|
||||
}
|
||||
|
||||
public class ChatMemberProfileRequest
|
||||
{
|
||||
[MaxLength(1024)] public string? Nick { get; set; }
|
||||
}
|
||||
|
||||
[HttpPatch("{roomId:guid}/members/me/profile")]
|
||||
[Authorize]
|
||||
public async Task<ActionResult<SnChatMember>> UpdateRoomIdentity(Guid roomId, [FromBody] ChatMemberProfileRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not DyAccount currentUser)
|
||||
return Unauthorized();
|
||||
if (currentUser.PerkLevel < 2)
|
||||
return StatusCode(403, "Perk level 2 is required to customize chat profile.");
|
||||
|
||||
var member = await db.ChatMembers
|
||||
.Where(m => m.AccountId == Guid.Parse(currentUser.Id) && m.ChatRoomId == roomId)
|
||||
.Where(m => m.JoinedAt != null && m.LeaveAt == null)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (member == null)
|
||||
return NotFound();
|
||||
|
||||
member.Nick = request.Nick;
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
return Ok(await crs.LoadMemberAccount(member));
|
||||
}
|
||||
|
||||
[HttpGet("{roomId:guid}/members/online")]
|
||||
public async Task<ActionResult<OnlineMembersResponse>> GetOnlineUsersCount(Guid roomId)
|
||||
{
|
||||
|
||||
@@ -364,13 +364,12 @@ public class RealmController(
|
||||
public async Task<ActionResult<SnRealmMember>> UpdateCurrentIdentity(string slug, [FromBody] RealmMemberProfileRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not SnAccount currentUser) return Unauthorized();
|
||||
if (currentUser.PerkLevel < 2)
|
||||
return StatusCode(403, "Perk level 2 is required to customize realm profile.");
|
||||
|
||||
var realm = await rs.GetBySlug(slug);
|
||||
if (realm is null) return NotFound();
|
||||
|
||||
if (realm.BoostLevel < 1)
|
||||
return StatusCode(403, "Realm boost level 1 is required to customize realm profile.");
|
||||
|
||||
var member = await rs.GetActiveMember(realm.Id, currentUser.Id);
|
||||
if (member is null) return NotFound();
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ Rules:
|
||||
|
||||
- only active joined members have realm identity
|
||||
- members can update their own realm `nick` and `bio`
|
||||
- custom realm profile requires realm boost level `>= 1`
|
||||
- custom realm profile requires user perk level `>= 2`
|
||||
- identity is realm-scoped and does not modify the account profile globally
|
||||
|
||||
## Realm Labels
|
||||
@@ -95,7 +95,7 @@ Boost thresholds:
|
||||
|
||||
Boost unlocks:
|
||||
|
||||
- level 1: custom realm profile and labels
|
||||
- level 1: labels
|
||||
- level 2: promotions above normal member
|
||||
- level 3: highest label capacity tier in v1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user