Skip to content

Commit

Permalink
fix(server): fixes posting with picture
Browse files Browse the repository at this point in the history
fixing #103
  • Loading branch information
roman-ojha committed Jun 9, 2022
1 parent caaf1a6 commit a590889
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const PostButton = () => {
// we can be able to pass the other form of data like this
const res = await Api.post(data);
const resData = await res.data;
console.log(resData);
if (res.status === 200 && resData.success) {
toastSuccess(resData.msg);
dispatch(userPostResponseData({ ...resData.data, date: new Date() }));
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/PostBox/PostBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ const PostBox = (props) => {
: [],
});

console.log(props);

return (
<>
<article className="HomePage_Feed_Content_Container">
Expand Down
9 changes: 6 additions & 3 deletions controllers/storage.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ export default {
try {
const rootUser = req.rootUser;
// console.log(rootUser);
const { caption, file } = req.body;
// console.log(caption,file);
const caption: string | undefined = req.body.caption;
const file = req.file;
// console.log();
if (!caption && !file) {
// if user doesn't fill the any filed
return res.status(400).json(<ResponseObject>{
success: false,
msg: "Please fill the required field",
});
} else if (caption && !file) {
} else if (!file) {
// if user only fill content field
// const caption = req.body.caption;
const postID = crypto.randomBytes(16).toString("hex");
Expand Down Expand Up @@ -99,9 +100,11 @@ export default {
},
likes: {
No: 0,
by: [],
},
comments: {
No: 0,
by: [],
},
};
const userStoryDetail = {
Expand Down
Binary file removed db/Images/6ff8dd8726b1e1c08ad948a664a67693.jpg
Binary file not shown.
Binary file removed db/Images/ffaa1829b324c8b9e577aec12bf519bf.jpg
Binary file not shown.
8 changes: 0 additions & 8 deletions models/userDetail_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,6 @@ userDetailSchema.methods.uploadPost = async function (
userStoryDetail: object
) {
try {
// this.posts.push(postData);
// if (userStoryDetail !== undefined) {
// this.stories = userStoryDetail;
// }
// this.postNo++;
// await this.save();
console.log(postData);
let resPost: UpdateResult;
if (userStoryDetail !== undefined) {
resPost = await UserDetail.updateOne(
Expand All @@ -279,7 +272,6 @@ userDetailSchema.methods.uploadPost = async function (
}
);
} else {
console.log("Without Stories");
resPost = await UserDetail.updateOne(
{
id: this.id,
Expand Down
3 changes: 1 addition & 2 deletions routes/storageRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import authenticate from "../middleware/auth/authUsingRedis.js";

router.post(
"/u/post",
authenticate,
upload.single("image"),
[authenticate, upload.single("image")],
storageController.post
);

Expand Down

0 comments on commit a590889

Please sign in to comment.