Skip to content
Merged

Dev #2843

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public async Task<IActionResult> MessageUserAsync([FromBody] DirectMessageReques
return BadRequest("TargetUserId and Message are required.");
}

if (request.Message.Length > NotificationHub.MaxDirectMessageLength)
{
return BadRequest($"Messages cannot exceed {NotificationHub.MaxDirectMessageLength} characters.");
}

var senderUserId = CurrentUser.Id?.ToString() ?? "unknown";
var senderName = DisplayNameHelper.Resolve(CurrentUser);

Expand Down Expand Up @@ -98,6 +103,11 @@ public async Task<IActionResult> MessageTenantAsync([FromBody] TenantMessageRequ
return BadRequest("TargetTenantId and Message are required.");
}

if (request.Message.Length > NotificationHub.MaxDirectMessageLength)
{
return BadRequest($"Messages cannot exceed {NotificationHub.MaxDirectMessageLength} characters.");
}

if (currentTenant.Id.HasValue && currentTenant.Id.Value != request.TargetTenantId)
{
return Forbid();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class NotificationHub(
{
public const string HubRoute = "/signalr/notifications";
public const string NotificationLogsOpsGroup = "ops:notification-logs";
public const int MaxDirectMessageLength = 4000;

public override async Task OnConnectedAsync()
{
Expand Down Expand Up @@ -147,6 +148,11 @@ public async Task SendDirectMessageAsync(string targetUserId, string message)
throw new HubException("Target user and message are required.");
}

if (message.Length > MaxDirectMessageLength)
{
throw new HubException($"Messages cannot exceed {MaxDirectMessageLength} characters.");
}

var senderId = GetCurrentUserId() ?? string.Empty;
var senderName = DisplayNameHelper.Resolve(Context.User);
var timestamp = DateTime.UtcNow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
(function () {
if (globalThis.__unityRealtimeWidgetInitialized) {
return;
}

globalThis.__unityRealtimeWidgetInitialized = true;

whenReady(init);

function whenReady(callback) {
Expand Down Expand Up @@ -296,6 +302,10 @@
return;
}

if (message.length > 4000) {
return;
}

if (connection.state !== signalR.HubConnectionState.Connected) {
return;
}
Expand Down Expand Up @@ -562,6 +572,12 @@
})();

(function () {
if (globalThis.__unityRealtimeWidgetInitialized) {
return;
}

globalThis.__unityRealtimeWidgetInitialized = true;

whenReady(init);

function whenReady(callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,9 @@
* @returns
*/
let toCamelCaseInternal = function (str) {
let regexs = [
/(^[A-Z])/, // first char of string
/((\.)[A-Z])/ // first char after a dot (.)
];

regexs.forEach(
function (regex) {
let infLoopAvoider = 0;

while (regex.test(str)) {
str = str
.replace(regex, function ($1) { return $1.toLowerCase(); });

if (infLoopAvoider++ > 1000) {
break;
}
}
}
);

return str;
return str
.replace(/^[A-Z]/, match => match.toLowerCase())
.replace(/\.[A-Z]/g, match => match.toLowerCase());
}

/**
Expand Down
Loading