mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
Refactor moderation notifications: replace NotifyAsync with KickPlayerAsync for player kicks in InGameModerationController and AdminController; update NotificationService to streamline moderation kick payloads.
This commit is contained in:
@@ -136,12 +136,9 @@ public class InGameModerationController(
|
||||
foreach (var target in ids)
|
||||
{
|
||||
logger.LogInformation("[mod] instant-kick by {Caller}: target={Target}", caller, target);
|
||||
// Push a SignalR ModerationKick notification — the watch's
|
||||
// PlayerReporting.OnModerationKick handler boots the player
|
||||
// back to their dorm.
|
||||
await notifications.NotifyAsync(
|
||||
target,
|
||||
Models.Notification.PushNotificationId.ModerationKick);
|
||||
// Push the ModerationKick shape the 2020.12 client expects:
|
||||
// Msg.Reason must be a ModerationBlockDetail object.
|
||||
await notifications.KickPlayerAsync(target, "Instant kick by moderator.");
|
||||
}
|
||||
return Ok(new { success = true, error = "" });
|
||||
}
|
||||
|
||||
@@ -159,8 +159,8 @@ public class AdminController(
|
||||
await LogAsync("ban_player", "player", id, body.Reason ?? "");
|
||||
await db.SaveChangesAsync();
|
||||
|
||||
await notifications.NotifyAsync(id, PushNotificationId.ModerationKick,
|
||||
new { Reason = body.Reason ?? "", Until = player.BannedUntil });
|
||||
await notifications.KickPlayerAsync(id, body.Reason ?? "You have been banned.");
|
||||
playerPresence.Clear(id);
|
||||
|
||||
return Ok(new { player.Id, player.BannedUntil });
|
||||
}
|
||||
@@ -1269,7 +1269,7 @@ public class AdminController(
|
||||
{
|
||||
var r = playerPresence.GetRoom(pid);
|
||||
if (r is null || r.RoomId != id || r.RoomInstanceId != instanceId) continue;
|
||||
await notifications.NotifyAsync(pid, PushNotificationId.ModerationKick, new { Reason = reason });
|
||||
await notifications.KickPlayerAsync(pid, reason);
|
||||
playerPresence.Clear(pid);
|
||||
kicked.Add(pid);
|
||||
}
|
||||
@@ -1616,8 +1616,11 @@ public class AdminController(
|
||||
[HttpPost("players/{id:long}/kick")]
|
||||
public async Task<ActionResult> KickPlayer(long id, [FromBody] KickRequest? body)
|
||||
{
|
||||
await notifications.NotifyAsync(id, PushNotificationId.ModerationKick,
|
||||
new { Reason = body?.Reason ?? "" });
|
||||
var reason = string.IsNullOrWhiteSpace(body?.Reason)
|
||||
? "Kicked by an admin."
|
||||
: body!.Reason!.Trim();
|
||||
await notifications.KickPlayerAsync(id, reason);
|
||||
playerPresence.Clear(id);
|
||||
await LogAsync("kick_player", "player", id, body?.Reason ?? "");
|
||||
await db.SaveChangesAsync();
|
||||
return Ok(new { kicked = id });
|
||||
|
||||
Reference in New Issue
Block a user