Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] - เมื่อ Edit Post แล้ว objectiveTag/emergencyEventTag บันทึกค่าไม่ถูกต้อง #359

Merged
merged 2 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api-spanboon/src/api/controllers/AllocateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class AllocateController {
} else {
return res.status(400).send(ResponseUtil.getErrorResponse('Cannot Calculate Allocate', undefined));
}
} catch (error) {
} catch (error: any) {
return res.status(400).send(ResponseUtil.getErrorResponse('Calculate Allocate Error', error.message));
}
}
Expand Down Expand Up @@ -322,7 +322,7 @@ export class AllocateController {
} else {
return res.status(200).send(ResponseUtil.getSuccessResponse('Successfully Calculate Allocate', {}));
}
} catch (error) {
} catch (error: any) {
return res.status(400).send(ResponseUtil.getErrorResponse('Calculate Allocate Error', error.message));
}
}
Expand Down
2 changes: 0 additions & 2 deletions api-spanboon/src/api/controllers/EmergencyEventController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ObjectID } from 'mongodb';
import { ObjectUtil, ResponseUtil } from '../../utils/Utils';
import { EmergencyEvent } from '../models/EmergencyEvent';
import { HashTagService } from '../services/HashTagService';
import { HashTag } from '../models/HashTag';
import { FindHashTagRequest } from './requests/FindHashTagRequest';
import { UserFollow } from '../models/UserFollow';
import { UserEngagement } from '../models/UserEngagement';
Expand All @@ -36,7 +35,6 @@ import { EmergencyLastestProcessor } from '../processors/emergency/EmergencyLast
import { EmergencyShareProcessor } from '../processors/emergency/EmergencyShareProcessor';
import { EmergencyPostLikedProcessor } from '../processors/emergency/EmergencyPostLikedProcessor';
import { DateTimeUtil } from '../../utils/DateTimeUtil';
import { SearchFilter } from './requests/SearchFilterRequest';

@JsonController('/emergency')
export class EmergencyEventController {
Expand Down
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