0.11.20 : modify event controller for group owner

This commit is contained in:
2025-11-10 23:10:23 +01:00
parent 539c9cd104
commit 14e013bac1
4 changed files with 44 additions and 40 deletions

View File

@@ -23,8 +23,10 @@ export default ({ strapi }: { strapi: Core.Strapi }) =>
}
try {
const groupId = ctx.request.body.data.group;
// Format tags from array of strings to array of component objects
const data = ctx.request.body.data;
delete data.group;
if (data.tags && Array.isArray(data.tags)) {
data.tags = data.tags
.filter((tag: any) => {
@@ -51,14 +53,17 @@ export default ({ strapi }: { strapi: Core.Strapi }) =>
}
// 2. Create the owner relationship
const contextType = groupId && groupId !== 0 ? "group" : "user";
const contextId = groupId && groupId !== 0 ? groupId : userId;
const ownerRelationship = await strapi.db
.query("api::event-relationship.event-relationship")
.create({
data: {
author: userId,
event: event.id,
contextType: "user",
contextId: userId,
contextType,
contextId,
relation: "owner",
metas: {
createdAt: new Date().toISOString(),