From 453cfffecf0146d38b06a7c9c483b02d081203ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Thu, 21 Mar 2019 15:09:51 +0100
Subject: [PATCH] Implement voting-functions in websocket service

---
 .../websockets/ws-comment-service.service.ts  | 20 ++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/app/services/websockets/ws-comment-service.service.ts b/src/app/services/websockets/ws-comment-service.service.ts
index 76d59cbf9..c2ecd60f0 100644
--- a/src/app/services/websockets/ws-comment-service.service.ts
+++ b/src/app/services/websockets/ws-comment-service.service.ts
@@ -4,8 +4,8 @@ import { RxStompService } from '@stomp/ng2-stompjs';
 import { CreateComment } from '../../models/messages/create-comment';
 import { PatchComment } from '../../models/messages/patch-comment';
 import { TSMap } from 'typescript-map';
-import { Vote } from '../../models/vote';
 import { UpVote } from '../../models/messages/up-vote';
+import { DownVote } from '../../models/messages/down-vote';
 
 
 @Injectable({
@@ -53,6 +53,24 @@ export class WsCommentServiceService {
 
   voteUp(comment: Comment): void {
     const message = new UpVote(comment.userId, comment.id);
+    this.rxStompService.publish({
+      destination: `/queue/comment.command.patch`,
+      body: JSON.stringify(message),
+      headers: {
+        'content-type': 'application/json'
+      }
+    });
+  }
+
+  voteDown(comment: Comment): void {
+    const message = new DownVote(comment.userId, comment.id);
+    this.rxStompService.publish({
+      destination: `/queue/comment.command.patch`,
+      body: JSON.stringify(message),
+      headers: {
+        'content-type': 'application/json'
+      }
+    });
   }
 
   private patchComment(comment: Comment, changes: TSMap<string, any>): void {
-- 
GitLab