Return review with message ID stripped when querying by ID
This commit is contained in:
parent
a17b7595c1
commit
a720a9a0a2
|
@ -5,7 +5,7 @@ import {
|
||||||
userRating,
|
userRating,
|
||||||
UserSideReview,
|
UserSideReview,
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import { appendId, checkFile } from "./functions";
|
import { appendId, checkFile, stripId } from "./functions";
|
||||||
|
|
||||||
export class ReviewData {
|
export class ReviewData {
|
||||||
public data: ServerSideReview[];
|
public data: ServerSideReview[];
|
||||||
|
@ -44,7 +44,7 @@ export class ReviewData {
|
||||||
public getReviewById(id: string): ServerSideReview | {} {
|
public getReviewById(id: string): ServerSideReview | {} {
|
||||||
for (const review of this.data) {
|
for (const review of this.data) {
|
||||||
if (review.id === id) {
|
if (review.id === id) {
|
||||||
return review;
|
return stripId(review);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,3 +35,12 @@ export function appendId(userReview: UserSideReview): ServerSideReview {
|
||||||
id: generateId(),
|
id: generateId(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function stripId(serverReview: ServerSideReview): UserSideReview {
|
||||||
|
return {
|
||||||
|
rating: serverReview.rating,
|
||||||
|
username: serverReview.username,
|
||||||
|
title: serverReview.title,
|
||||||
|
content: serverReview.content
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue