From 60853c4ba1795cfd4a16b2e3183ec476d6ffd69a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Thu, 15 Mar 2018 13:08:25 +0100
Subject: [PATCH] Add addToHistory method which sends user data and current
 date to api

---
 src/app/room.service.ts | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/app/room.service.ts b/src/app/room.service.ts
index 2a1f4926a..31582ab76 100644
--- a/src/app/room.service.ts
+++ b/src/app/room.service.ts
@@ -14,7 +14,9 @@ const httpOptions = {
 export class RoomService extends ErrorHandlingService {
   private apiBaseUrl = 'https://arsnova-staging.mni.thm.de/api';
   private roomsUrl = '/room';
+  private userUrl = '/user';
   private findRoomsUrl = '/find';
+  private joinDate = new Date(Date.now());
 
   constructor(private http: HttpClient,
               private authService: AuthenticationService) {
@@ -58,6 +60,11 @@ export class RoomService extends ErrorHandlingService {
     );
   }
 
+  addToHistory(roomId: string): void {
+    const connectionUrl = `${ this.apiBaseUrl }${ this.userUrl }/${this.authService.getUser().userId}/roomHistory`;
+    this.http.post(connectionUrl, { roomId: roomId, lastVisit: this.joinDate.getTime() }, httpOptions).subscribe(r => console.log(r));
+  }
+
   getRoomById(id: string): Observable<Room> {
     const connectionUrl = `${ this.apiBaseUrl }${ this.roomsUrl }/${id}`;
     return this.http.get<Room>(connectionUrl).pipe(
-- 
GitLab