0.11.13 : add post link
This commit is contained in:
@@ -183,6 +183,7 @@ export default factories.createCoreController(
|
||||
{ author: { id: friendIds } }, // Posts de mes amis
|
||||
{ author: { id: followIds } }, // Posts des contacts que je suis
|
||||
{ author: { id: parseInt(userId) }, relation: "owner" }, // Mes propres posts
|
||||
{ author: { id: parseInt(userId) }, relation: "link" }, // Posts linkés (events partagés)
|
||||
{ contextType: "group", contextId: groupIds }, // Posts de mes groupes
|
||||
{ contextType: "group", contextId: friendsGroupIds }, // Posts des groupes de mes amis
|
||||
{ contextType: "system" }, // Posts système
|
||||
@@ -273,6 +274,8 @@ export default factories.createCoreController(
|
||||
contactFollow: isContactFollow,
|
||||
member: isMember,
|
||||
blocked: isBlocked,
|
||||
contextType,
|
||||
contextId,
|
||||
...(group && { group }), // Ajouter group seulement s'il existe
|
||||
};
|
||||
});
|
||||
@@ -727,7 +730,8 @@ export default factories.createCoreController(
|
||||
return ctx.unauthorized("You must be logged in to link events");
|
||||
}
|
||||
|
||||
const { contextType, contextId, relation } = ctx.request.body;
|
||||
const { contextType, contextId, relation, content, title } =
|
||||
ctx.request.body;
|
||||
|
||||
if (!contextType || contextId === undefined || !relation) {
|
||||
return ctx.badRequest(
|
||||
@@ -735,6 +739,10 @@ export default factories.createCoreController(
|
||||
);
|
||||
}
|
||||
|
||||
if (!content || !title) {
|
||||
return ctx.badRequest("content and title are required");
|
||||
}
|
||||
|
||||
try {
|
||||
// Check if link already exists
|
||||
const existingLink = await strapi.db
|
||||
@@ -752,10 +760,21 @@ export default factories.createCoreController(
|
||||
return ctx.badRequest("This event is already linked");
|
||||
}
|
||||
|
||||
// Create the post
|
||||
const post = await strapi.db.query("api::post.post").create({
|
||||
data: {
|
||||
content,
|
||||
title,
|
||||
category: "event",
|
||||
},
|
||||
});
|
||||
|
||||
// Create the postOwnership linked to the post
|
||||
const postOwnership = await strapi.db
|
||||
.query("api::post-ownership.post-ownership")
|
||||
.create({
|
||||
data: {
|
||||
post: post.id,
|
||||
author: user.id,
|
||||
contextType,
|
||||
contextId,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"name": "Apache 2.0",
|
||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
},
|
||||
"x-generation-date": "2025-10-29T23:50:11.045Z"
|
||||
"x-generation-date": "2025-10-31T17:03:14.573Z"
|
||||
},
|
||||
"x-strapi-config": {
|
||||
"plugins": [
|
||||
|
||||
Reference in New Issue
Block a user