Skip to content

Commit

Permalink
[API] เพิ่มให้ซ่อน story ใน /main/content/search #385
Browse files Browse the repository at this point in the history
  • Loading branch information
junsudas committed Dec 8, 2021
1 parent 24c1576 commit 792426e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion api-spanboon/src/api/controllers/MainPageController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ export class MainPageController {
* HTTP/1.1 500 Internal Server Error
*/
@Post('/content/search')
public async searchContentAll(@Body({ validate: true }) data: ContentSearchRequest, @Res() res: any, @Req() req: any): Promise<SearchContentResponse> {
public async searchContentAll(@Body({ validate: true }) data: ContentSearchRequest, @QueryParam('isHideStory') isHideStory: boolean, @Res() res: any, @Req() req: any): Promise<SearchContentResponse> {
try {
const uId = req.headers.userid;
let search: any = {};
Expand Down Expand Up @@ -1211,6 +1211,18 @@ export class MainPageController {
}
}

searchResults.map((dataMap) => {
const story = dataMap.post.story;

if (isHideStory === true) {
if (story !== null && story !== undefined) {
dataMap.post.story = {};
} else {
dataMap.post.story = null;
}
}
});

search = searchResults;

if (search !== null && search !== undefined && Object.keys(search).length > 0) {
Expand Down

0 comments on commit 792426e

Please sign in to comment.