0.11.13 : add post link

This commit is contained in:
2025-10-31 18:03:35 +01:00
parent 00b12832a1
commit d4bef1ab07
3 changed files with 22 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "harmony-back", "name": "harmony-back",
"version": "0.11.12", "version": "0.11.13",
"private": true, "private": true,
"description": "A Strapi application", "description": "A Strapi application",
"scripts": { "scripts": {

View File

@@ -183,6 +183,7 @@ export default factories.createCoreController(
{ author: { id: friendIds } }, // Posts de mes amis { author: { id: friendIds } }, // Posts de mes amis
{ author: { id: followIds } }, // Posts des contacts que je suis { author: { id: followIds } }, // Posts des contacts que je suis
{ author: { id: parseInt(userId) }, relation: "owner" }, // Mes propres posts { 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: groupIds }, // Posts de mes groupes
{ contextType: "group", contextId: friendsGroupIds }, // Posts des groupes de mes amis { contextType: "group", contextId: friendsGroupIds }, // Posts des groupes de mes amis
{ contextType: "system" }, // Posts système { contextType: "system" }, // Posts système
@@ -273,6 +274,8 @@ export default factories.createCoreController(
contactFollow: isContactFollow, contactFollow: isContactFollow,
member: isMember, member: isMember,
blocked: isBlocked, blocked: isBlocked,
contextType,
contextId,
...(group && { group }), // Ajouter group seulement s'il existe ...(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"); 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) { if (!contextType || contextId === undefined || !relation) {
return ctx.badRequest( return ctx.badRequest(
@@ -735,6 +739,10 @@ export default factories.createCoreController(
); );
} }
if (!content || !title) {
return ctx.badRequest("content and title are required");
}
try { try {
// Check if link already exists // Check if link already exists
const existingLink = await strapi.db const existingLink = await strapi.db
@@ -752,10 +760,21 @@ export default factories.createCoreController(
return ctx.badRequest("This event is already linked"); 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 const postOwnership = await strapi.db
.query("api::post-ownership.post-ownership") .query("api::post-ownership.post-ownership")
.create({ .create({
data: { data: {
post: post.id,
author: user.id, author: user.id,
contextType, contextType,
contextId, contextId,

View File

@@ -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-10-29T23:50:11.045Z" "x-generation-date": "2025-10-31T17:03:14.573Z"
}, },
"x-strapi-config": { "x-strapi-config": {
"plugins": [ "plugins": [