Enforce 256-character limit on chat messages with validation in ChatBoxComponent and schema updates.

This commit is contained in:
akastijn 2026-08-08 23:45:42 +02:00
parent bdda71229d
commit b61b117f41
3 changed files with 11 additions and 1 deletions

View File

@ -20,6 +20,7 @@
[(ngModel)]="chatText" [(ngModel)]="chatText"
(keyup.enter)="sendMessage()" (keyup.enter)="sendMessage()"
placeholder="Type a message..." placeholder="Type a message..."
maxlength="256"
/> />
<button (click)="sendMessage()">Send</button> <button (click)="sendMessage()">Send</button>
</div> </div>

View File

@ -39,7 +39,15 @@ export class ChatBoxComponent {
sendMessage() { sendMessage() {
const message = this.chatText.trim(); const message = this.chatText.trim();
if (!message) return; if (!message) {
return;
}
if (message.length > 256) {
this.matSnackBar.open('Message too long, it can only be 256 characters', 'Dismiss', {
duration: 3000
});
return;
}
const selectedChannel = this.chatService.selectedChannel(); const selectedChannel = this.chatService.selectedChannel();
const uuid = this.authService.getUuid(); const uuid = this.authService.getUuid();

View File

@ -42,3 +42,4 @@ components:
message: message:
type: string type: string
description: The message to send description: The message to send
maxLength: 256