0.11.17 : add shared events
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "harmony-back",
|
"name": "harmony-back",
|
||||||
"version": "0.11.16",
|
"version": "0.11.17",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "A Strapi application",
|
"description": "A Strapi application",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -243,7 +243,24 @@ export default factories.createCoreController(
|
|||||||
// Créer un map pour un accès rapide aux groupes par ID
|
// Créer un map pour un accès rapide aux groupes par ID
|
||||||
const groupsMap = new Map(allGroups.map((group) => [group.id, group]));
|
const groupsMap = new Map(allGroups.map((group) => [group.id, group]));
|
||||||
|
|
||||||
// 6️⃣ Enrichir le feed avec les propriétés friend, member, contactFollow et group
|
// 5.1️⃣ Récupérer tous les événements liés dans le feed
|
||||||
|
const linkedEventIds = filteredFeed
|
||||||
|
.filter((po) => po.contextType === "event" && po.relation === "link")
|
||||||
|
.map((po) => po.contextId);
|
||||||
|
const linkedEventsMap = new Map();
|
||||||
|
if (linkedEventIds.length > 0) {
|
||||||
|
const eventRelationships = await strapi.db
|
||||||
|
.query("api::event-relationship.event-relationship")
|
||||||
|
.findMany({
|
||||||
|
where: { event: { id: linkedEventIds } },
|
||||||
|
populate: ["event"],
|
||||||
|
});
|
||||||
|
eventRelationships.forEach((relationship) => {
|
||||||
|
linkedEventsMap.set(relationship.event.id, relationship);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6️⃣ Enrichir le feed avec les propriétés friend, member, contactFollow, group et linkedEvent
|
||||||
const enrichedFeed = filteredFeed.map((postOwnership) => {
|
const enrichedFeed = filteredFeed.map((postOwnership) => {
|
||||||
const authorId = postOwnership.author?.id;
|
const authorId = postOwnership.author?.id;
|
||||||
const contextType = postOwnership.contextType;
|
const contextType = postOwnership.contextType;
|
||||||
@@ -270,15 +287,27 @@ export default factories.createCoreController(
|
|||||||
? groupsMap.get(contextId)
|
? groupsMap.get(contextId)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
// Ajouter l'événement lié si contextType est "event" et relation est "link"
|
||||||
|
const linkedEvent =
|
||||||
|
contextType === "event" &&
|
||||||
|
postOwnership.relation === "link" &&
|
||||||
|
contextId
|
||||||
|
? linkedEventsMap.get(contextId)
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...postOwnership,
|
...postOwnership,
|
||||||
|
post: {
|
||||||
|
...postOwnership.post,
|
||||||
|
...(linkedEvent && { linkedEvent }),
|
||||||
|
},
|
||||||
friend: isFriend,
|
friend: isFriend,
|
||||||
contactFollow: isContactFollow,
|
contactFollow: isContactFollow,
|
||||||
member: isMember,
|
member: isMember,
|
||||||
blocked: isBlocked,
|
blocked: isBlocked,
|
||||||
contextType,
|
contextType,
|
||||||
contextId,
|
contextId,
|
||||||
...(group && { group }), // Ajouter group seulement s'il existe
|
...(group && { group }),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -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-11-07T14:28:24.261Z"
|
"x-generation-date": "2025-11-08T23:22:04.498Z"
|
||||||
},
|
},
|
||||||
"x-strapi-config": {
|
"x-strapi-config": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
|
|||||||
Reference in New Issue
Block a user