Return review with message ID stripped when querying by ID

This commit is contained in:
powermaker450 2024-08-27 01:47:06 -04:00
parent a17b7595c1
commit a720a9a0a2
2 changed files with 11 additions and 2 deletions

View file

@ -5,7 +5,7 @@ import {
userRating,
UserSideReview,
} from "../types";
import { appendId, checkFile } from "./functions";
import { appendId, checkFile, stripId } from "./functions";
export class ReviewData {
public data: ServerSideReview[];
@ -44,7 +44,7 @@ export class ReviewData {
public getReviewById(id: string): ServerSideReview | {} {
for (const review of this.data) {
if (review.id === id) {
return review;
return stripId(review);
}
}

View file

@ -35,3 +35,12 @@ export function appendId(userReview: UserSideReview): ServerSideReview {
id: generateId(),
};
}
export function stripId(serverReview: ServerSideReview): UserSideReview {
return {
rating: serverReview.rating,
username: serverReview.username,
title: serverReview.title,
content: serverReview.content
};
}