0.11.21 : change on event and group
This commit is contained in:
@@ -75,6 +75,16 @@ export default ({ strapi }: { strapi: Core.Strapi }) =>
|
||||
`Event ${event.id} created by user ${userId} with owner relationship ${ownerRelationship.id}`
|
||||
);
|
||||
|
||||
if (contextType === "group") {
|
||||
await strapi
|
||||
.service("api::group.group")
|
||||
.addActivity(
|
||||
contextId,
|
||||
ctx.state.user?.username || `User ${userId}`,
|
||||
`Evènement créé : ${event.title}`
|
||||
);
|
||||
}
|
||||
|
||||
ctx.send({ data: event }, 201);
|
||||
} catch (error) {
|
||||
strapi.log.error("Error in create event controller:", error);
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
"owner",
|
||||
"follow",
|
||||
"pending",
|
||||
"invited"
|
||||
"invited",
|
||||
"rejected"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,25 @@
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreService('api::group.group');
|
||||
export default factories.createCoreService('api::group.group', ({ strapi }) => ({
|
||||
async addActivity(groupId: number, userName: string, message: string) {
|
||||
const group = await strapi.entityService.findOne('api::group.group', groupId, {
|
||||
populate: ['activities'],
|
||||
}) as any;
|
||||
|
||||
if (!group) {
|
||||
throw new Error(`Group with id ${groupId} not found`);
|
||||
}
|
||||
|
||||
const activities = group.activities || [];
|
||||
activities.push({
|
||||
activityUser: userName,
|
||||
activityMessage: message,
|
||||
activityDate: new Date(),
|
||||
});
|
||||
|
||||
return await strapi.entityService.update('api::group.group', groupId, {
|
||||
data: { activities },
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user