Restrict web-socket connections to the initiating user
This commit is contained in:
committed by
Aditya Chandel
parent
3ab52de171
commit
628a6c7bcf
@@ -1,9 +1,8 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {RxStompService} from './shared/websocket/rx-stomp.service';
|
||||
import {Message} from '@stomp/stompjs';
|
||||
import {BookService} from './book/service/book.service';
|
||||
import {NotificationEventService} from './shared/websocket/notification-event.service';
|
||||
import {parseLogNotification, parseTaskMessage, TaskMessage} from './shared/websocket/model/log-notification.model';
|
||||
import {parseLogNotification, parseTaskMessage} from './shared/websocket/model/log-notification.model';
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {Toast} from 'primeng/toast';
|
||||
import {RouterOutlet} from '@angular/router';
|
||||
@@ -11,7 +10,7 @@ import {AuthInitializationService} from './auth-initialization-service';
|
||||
import {AppConfigService} from './core/service/app-config.service';
|
||||
import {MetadataBatchProgressNotification} from './core/model/metadata-batch-progress.model';
|
||||
import {MetadataProgressService} from './core/service/metadata-progress-service';
|
||||
import {BookdropFileService, BookdropFileNotification} from './bookdrop/bookdrop-file.service';
|
||||
import {BookdropFileNotification, BookdropFileService} from './bookdrop/bookdrop-file.service';
|
||||
import {TaskEventService} from './shared/websocket/task-event.service';
|
||||
|
||||
@Component({
|
||||
@@ -34,45 +33,33 @@ export class AppComponent implements OnInit {
|
||||
private appConfigService = inject(AppConfigService);
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.authInit.initialized$.subscribe(ready => {
|
||||
this.loading = !ready;
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-add').subscribe((message: Message) => {
|
||||
this.bookService.handleNewlyCreatedBook(JSON.parse(message.body));
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/books-remove').subscribe((message: Message) => {
|
||||
this.bookService.handleRemovedBookIds(JSON.parse(message.body));
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-metadata-update').subscribe((message: Message) => {
|
||||
this.bookService.handleBookUpdate(JSON.parse(message.body));
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-metadata-batch-update').subscribe((message: Message) => {
|
||||
const updatedBooks = JSON.parse(message.body);
|
||||
this.bookService.handleMultipleBookUpdates(updatedBooks);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/book-metadata-batch-progress').subscribe((message: Message) => {
|
||||
const progress = JSON.parse(message.body) as MetadataBatchProgressNotification;
|
||||
this.metadataProgressService.handleIncomingProgress(progress);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/log').subscribe((message: Message) => {
|
||||
const logNotification = parseLogNotification(message.body);
|
||||
this.rxStompService.watch('/user/queue/book-add').subscribe(msg =>
|
||||
this.bookService.handleNewlyCreatedBook(JSON.parse(msg.body))
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/books-remove').subscribe(msg =>
|
||||
this.bookService.handleRemovedBookIds(JSON.parse(msg.body))
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/book-metadata-update').subscribe(msg =>
|
||||
this.bookService.handleBookUpdate(JSON.parse(msg.body))
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/book-metadata-batch-update').subscribe(msg =>
|
||||
this.bookService.handleMultipleBookUpdates(JSON.parse(msg.body))
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/book-metadata-batch-progress').subscribe(msg =>
|
||||
this.metadataProgressService.handleIncomingProgress(JSON.parse(msg.body) as MetadataBatchProgressNotification)
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/log').subscribe(msg => {
|
||||
const logNotification = parseLogNotification(msg.body);
|
||||
this.notificationEventService.handleNewNotification(logNotification);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/task').subscribe((message: Message) => {
|
||||
const taskMessage: TaskMessage = parseTaskMessage(message.body);
|
||||
this.taskEventService.handleTaskMessage(taskMessage);
|
||||
});
|
||||
|
||||
this.rxStompService.watch('/topic/bookdrop-file').subscribe((message: Message) => {
|
||||
const notification = JSON.parse(message.body) as BookdropFileNotification;
|
||||
this.rxStompService.watch('/user/queue/task').subscribe(msg =>
|
||||
this.taskEventService.handleTaskMessage(parseTaskMessage(msg.body))
|
||||
);
|
||||
this.rxStompService.watch('/user/queue/bookdrop-file').subscribe(msg => {
|
||||
const notification = JSON.parse(msg.body) as BookdropFileNotification;
|
||||
this.bookdropFileService.handleIncomingFile(notification);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user