Fix on save post params
This commit is contained in:
@@ -242,7 +242,8 @@ export default factories.createCoreController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("✅ User authenticated:", user.id);
|
console.log("✅ User authenticated:", user.id);
|
||||||
const postId = parseInt(ctx.params.id);
|
const postId = parseInt(String(ctx.params.id));
|
||||||
|
const authorId = parseInt(String(ctx.query.authorId));
|
||||||
|
|
||||||
if (isNaN(postId)) {
|
if (isNaN(postId)) {
|
||||||
return ctx.badRequest("Invalid post ID");
|
return ctx.badRequest("Invalid post ID");
|
||||||
@@ -260,7 +261,7 @@ export default factories.createCoreController(
|
|||||||
.findOne({
|
.findOne({
|
||||||
where: {
|
where: {
|
||||||
post: postId,
|
post: postId,
|
||||||
author: user.id,
|
author: authorId,
|
||||||
contextType: "user",
|
contextType: "user",
|
||||||
contextId: user.id,
|
contextId: user.id,
|
||||||
relation: "saved",
|
relation: "saved",
|
||||||
@@ -278,7 +279,7 @@ export default factories.createCoreController(
|
|||||||
.create({
|
.create({
|
||||||
data: {
|
data: {
|
||||||
post: postId,
|
post: postId,
|
||||||
author: user.id,
|
author: authorId,
|
||||||
contextType: "user",
|
contextType: "user",
|
||||||
contextId: user.id,
|
contextId: user.id,
|
||||||
relation: "saved",
|
relation: "saved",
|
||||||
@@ -292,7 +293,7 @@ export default factories.createCoreController(
|
|||||||
.query("api::post-ownership.post-ownership")
|
.query("api::post-ownership.post-ownership")
|
||||||
.count({
|
.count({
|
||||||
where: {
|
where: {
|
||||||
author: user.id,
|
author: authorId,
|
||||||
contextType: "user",
|
contextType: "user",
|
||||||
contextId: user.id,
|
contextId: user.id,
|
||||||
relation: "saved",
|
relation: "saved",
|
||||||
@@ -317,7 +318,7 @@ export default factories.createCoreController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("✅ User authenticated:", user.id);
|
console.log("✅ User authenticated:", user.id);
|
||||||
const postId = parseInt(ctx.params.id);
|
const postId = parseInt(String(ctx.params.id));
|
||||||
|
|
||||||
if (isNaN(postId)) {
|
if (isNaN(postId)) {
|
||||||
return ctx.badRequest("Invalid post ID");
|
return ctx.badRequest("Invalid post ID");
|
||||||
@@ -335,7 +336,6 @@ export default factories.createCoreController(
|
|||||||
.findOne({
|
.findOne({
|
||||||
where: {
|
where: {
|
||||||
post: postId,
|
post: postId,
|
||||||
author: user.id,
|
|
||||||
contextType: "user",
|
contextType: "user",
|
||||||
contextId: user.id,
|
contextId: user.id,
|
||||||
relation: "saved",
|
relation: "saved",
|
||||||
@@ -384,7 +384,7 @@ export default factories.createCoreController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("✅ User authenticated:", user.id);
|
console.log("✅ User authenticated:", user.id);
|
||||||
const postId = parseInt(ctx.params.id);
|
const postId = parseInt(String(ctx.params.id));
|
||||||
|
|
||||||
if (isNaN(postId)) {
|
if (isNaN(postId)) {
|
||||||
return ctx.badRequest("Invalid post ID");
|
return ctx.badRequest("Invalid post ID");
|
||||||
@@ -447,7 +447,7 @@ export default factories.createCoreController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log("✅ User authenticated:", user.id);
|
console.log("✅ User authenticated:", user.id);
|
||||||
const postId = parseInt(ctx.params.id);
|
const postId = parseInt(String(ctx.params.id));
|
||||||
|
|
||||||
if (isNaN(postId)) {
|
if (isNaN(postId)) {
|
||||||
return ctx.badRequest("Invalid post ID");
|
return ctx.badRequest("Invalid post ID");
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
"name": "Apache 2.0",
|
"name": "Apache 2.0",
|
||||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
},
|
},
|
||||||
"x-generation-date": "2025-09-30T20:21:49.088Z"
|
"x-generation-date": "2025-09-30T22:08:05.498Z"
|
||||||
},
|
},
|
||||||
"x-strapi-config": {
|
"x-strapi-config": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
Reference in New Issue
Block a user