diff --git a/src/app/services/http/comment.service.ts b/src/app/services/http/comment.service.ts index dc9ba3e65a444adc44a0dda60b8eabf1ca769041..d614d25006c2c735e3f80922ed9b6ba50023d764 100644 --- a/src/app/services/http/comment.service.ts +++ b/src/app/services/http/comment.service.ts @@ -22,14 +22,16 @@ export class CommentService extends BaseHttpService { } getComment(comment: Comment): Observable<Comment> { - return this.http.get<Comment>(`${ this.apiUrl.base }${ this.apiUrl.comment }/~${comment.id}`, httpOptions).pipe( + const connectionUrl = `${ this.apiUrl.base }${ this.apiUrl.comment }/~${comment.id}`; + return this.http.get<Comment>(connectionUrl, httpOptions).pipe( tap (_ => ''), catchError(this.handleError<Comment>('addComment')) ); } addComment(comment: Comment): Observable<Comment> { - return this.http.post<Comment>(this.apiUrl.base + this.apiUrl.comment + '/', + const connectionUrl = this.apiUrl.base + this.apiUrl.comment + '/'; + return this.http.post<Comment>(connectionUrl, { roomId: comment.roomId, subject: comment.subject, body: comment.body, read: comment.read, creationTimestamp: comment.creationTimestamp }, httpOptions).pipe( @@ -39,16 +41,16 @@ export class CommentService extends BaseHttpService { } deleteComment(comment: Comment): Observable<Comment> { - const url = `${this.apiUrl.base + this.apiUrl.comment }/${comment.id}`; - return this.http.delete<Comment>(url, httpOptions).pipe( + const connectionUrl = `${this.apiUrl.base + this.apiUrl.comment }/${comment.id}`; + return this.http.delete<Comment>(connectionUrl, httpOptions).pipe( tap (_ => ''), catchError(this.handleError<Comment>('deleteComment')) ); } getComments(roomId: string): Observable<Comment[]> { - const url = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find; - return this.http.post<Comment[]>(url, { + const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find; + return this.http.post<Comment[]>(connectionUrl, { properties: { roomId: roomId }, externalFilters: {} }, httpOptions).pipe( @@ -58,15 +60,16 @@ export class CommentService extends BaseHttpService { } searchComments(roomId: string, userId: string): Observable<Comment[]> { - const url = `${this.apiUrl.base}/?roomId=${roomId}&userId=${userId}`; - return this.http.get<Comment[]>(url).pipe( + const connectionUrl = `${this.apiUrl.base}/?roomId=${roomId}&userId=${userId}`; + return this.http.get<Comment[]>(connectionUrl).pipe( tap (_ => ''), catchError(this.handleError<Comment[]>('getComments', [])) ); } updateComment(comment: Comment): Observable<any> { - return this.http.put(this.apiUrl + this.apiUrl.comment + '/' + comment.id, comment, httpOptions).pipe( + const connectionUrl = this.apiUrl + this.apiUrl.comment + '/' + comment.id; + return this.http.put(connectionUrl, comment, httpOptions).pipe( tap(_ => ''), catchError(this.handleError<any>('updateComment')) ); diff --git a/src/app/services/http/room.service.ts b/src/app/services/http/room.service.ts index 9ce32ba12e58c2505c6af7dd0fe37b82f321d9df..b2597c32a1c6af02a7bcda6c65d91d6b31303dfd 100644 --- a/src/app/services/http/room.service.ts +++ b/src/app/services/http/room.service.ts @@ -26,8 +26,8 @@ export class RoomService extends BaseHttpService { } getCreatorRooms(): Observable<Room[]> { - const url = this.apiUrl.base + this.apiUrl.rooms + this.apiUrl.findRooms; - return this.http.post<Room[]>(url, { + const connectionUrl = this.apiUrl.base + this.apiUrl.rooms + this.apiUrl.findRooms; + return this.http.post<Room[]>(connectionUrl, { properties: { ownerId: this.authService.getUser().id }, externalFilters: {} }).pipe( @@ -37,8 +37,8 @@ export class RoomService extends BaseHttpService { } getParticipantRooms(): Observable<Room[]> { - const url = this.apiUrl.base + this.apiUrl.rooms + this.apiUrl.findRooms; - return this.http.post<Room[]>(url, { + const connectionUrl = this.apiUrl.base + this.apiUrl.rooms + this.apiUrl.findRooms; + return this.http.post<Room[]>(connectionUrl, { properties: {}, externalFilters: { inHistoryOfUserId: this.authService.getUser().id } }).pipe( @@ -56,7 +56,7 @@ export class RoomService extends BaseHttpService { } getRoom(id: string): Observable<Room> { - const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/~${ id }`; + const connectionUrl = `${ this.apiUrl.base + this.apiUrl.rooms }/~${ id }`; return this.http.get<Room>(connectionUrl).pipe( catchError(this.handleError<Room>(`getRoom id=${ id }`)) );