0.11.20 : modify event controller for group owner
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user