Skip to content

Commit

Permalink
[API] - เมื่อ Edit Post แล้ว objectiveTag/emergencyEventTag บันทึกค่า…
Browse files Browse the repository at this point in the history
…ไม่ถูกต้อง (#358)
  • Loading branch information
junsudas committed Sep 30, 2021
1 parent 2800ecf commit eebb3b2
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions api-spanboon/src/api/controllers/PagePostController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1514,19 +1514,6 @@ export class PagePostController {
// find gallery update ordering
const gallery: PostsGallery[] = await this.postGalleryService.find({ where: { _id: new ObjectID(data.id) } });
if (gallery.length > 0) {
// const isContain = gallery.find(object => {
// console.log('object.fileId ',object.fileId)
// console.log('data.fileId ',data.fileId)
// console.log('>>> ',new ObjectID(object.fileId) === new ObjectID(data.fileId) ? 'true' : 'false')
// return (object.fileId === new ObjectID(data.fileId)) && (object.ordering !== data.asset.ordering)
// });
// if(isContain){
// continue;
// } else {
// console.log('isContain ',data)
// }
// console.log(isContain);

const updateImageQuery = { _id: new ObjectID(data.id) };
const newImageValue = {
$set: {
Expand Down Expand Up @@ -1672,7 +1659,14 @@ export class PagePostController {
return res.status(400).send(ResponseUtil.getErrorResponse('Objective was not found.', undefined));
}

objectiveTag = obj.hashTag;
let objHashTag = undefined;
try {
objHashTag = await this.hashTagService.findOne({ _id: obj.hashTag });
} catch (error) {
console.log('find objective hashTag error: ', error);
}

objectiveTag = objHashTag === undefined ? '' : objHashTag.name;
}

// emergencyEvent
Expand All @@ -1686,7 +1680,14 @@ export class PagePostController {
return res.status(400).send(ResponseUtil.getErrorResponse('Emergency Event was not found.', undefined));
}

emergencyEventTag = emerEvent.hashTag;
let emerHashTag = undefined;
try {
emerHashTag = await this.hashTagService.findOne({ _id: emerEvent.hashTag });
} catch (error) {
console.log('find emergency hashTag error: ', error);
}

emergencyEventTag = emerHashTag === undefined ? '' : emerHashTag.name;
}

// need
Expand Down

0 comments on commit eebb3b2

Please sign in to comment.