0.12.3 : change updateMe to handle components

This commit is contained in:
2025-11-13 23:01:28 +01:00
parent 1e642d194e
commit b2e1ab0361
8 changed files with 323 additions and 5 deletions

View File

@@ -0,0 +1,22 @@
{
"collectionName": "components_configuration_parameters",
"info": {
"displayName": "parameter",
"icon": "cog"
},
"options": {},
"attributes": {
"emailNotification": {
"type": "boolean",
"default": false
},
"pushNotification": {
"type": "boolean",
"default": false
},
"sendNewsgroup": {
"type": "boolean",
"default": false
}
}
}

View File

@@ -0,0 +1,35 @@
{
"collectionName": "components_configuration_privacies",
"info": {
"displayName": "privacy",
"icon": "key",
"description": ""
},
"options": {},
"attributes": {
"profileVisibility": {
"type": "enumeration",
"enum": [
"public",
"contacts",
"private"
]
},
"allowMessage": {
"type": "boolean",
"default": true
},
"allowInvite": {
"type": "boolean",
"default": true
},
"allowTag": {
"type": "boolean",
"default": true
},
"showOnline": {
"type": "boolean",
"default": true
}
}
}

View File

@@ -14,7 +14,7 @@
"name": "Apache 2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
},
"x-generation-date": "2025-11-12T20:11:53.117Z"
"x-generation-date": "2025-11-13T22:01:13.582Z"
},
"x-strapi-config": {
"plugins": [
@@ -17867,6 +17867,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -18335,6 +18341,51 @@
}
}
},
"ConfigurationParameterComponent": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"emailNotification": {
"type": "boolean"
},
"pushNotification": {
"type": "boolean"
},
"sendNewsgroup": {
"type": "boolean"
}
}
},
"ConfigurationPrivacyComponent": {
"type": "object",
"properties": {
"id": {
"type": "number"
},
"profileVisibility": {
"type": "string",
"enum": [
"public",
"contacts",
"private"
]
},
"allowMessage": {
"type": "boolean"
},
"allowInvite": {
"type": "boolean"
},
"allowTag": {
"type": "boolean"
},
"showOnline": {
"type": "boolean"
}
}
},
"AnnouncementRequest": {
"type": "object",
"required": [
@@ -21473,6 +21524,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -25406,6 +25463,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -28898,6 +28961,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -32838,6 +32907,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -37029,6 +37104,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -41669,6 +41750,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -45599,6 +45686,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -49431,6 +49524,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -53250,6 +53349,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -57105,6 +57210,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -60852,6 +60963,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -64776,6 +64893,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -68773,6 +68896,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -72259,6 +72388,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -76674,6 +76809,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -80478,6 +80619,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -84603,6 +84750,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -88440,6 +88593,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -92381,6 +92540,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -96223,6 +96388,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -99570,6 +99741,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -104126,6 +104303,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -108011,6 +108194,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"
@@ -111856,6 +112045,12 @@
},
"tags": {},
"languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": {
"type": "string",
"format": "date-time"

View File

@@ -225,6 +225,16 @@
},
"languages": {
"type": "json"
},
"parameter": {
"type": "component",
"repeatable": false,
"component": "configuration.parameter"
},
"privacy": {
"type": "component",
"repeatable": false,
"component": "configuration.privacy"
}
}
}

View File

@@ -206,6 +206,8 @@ module.exports = (plugin) => {
"experience",
"tags",
"languages",
"parameter",
"privacy",
]);
/*
@@ -248,9 +250,26 @@ module.exports = (plugin) => {
ctx.request.body = newData;
ctx.params = { id: user.id };
const avatarId = await uploadImage(ctx, "avatar", newData.username);
if (avatarId != 0) ctx.request.body.avatar = avatarId;
return plugin.controllers.user.update(ctx);
const keysExcludingParameterAndPrivacy = Object.keys(newData).filter(
(key) => key !== "parameter" && key !== "privacy"
);
if (keysExcludingParameterAndPrivacy.length === 0) {
await strapi.entityService
.update("plugin::users-permissions.user", user.id, {
data: newData,
})
.then((res) => {
ctx.response.status = 200;
ctx.response.body = res;
return ctx;
});
} else {
const avatarId = await uploadImage(ctx, "avatar", newData.username);
if (avatarId != 0) ctx.request.body.avatar = avatarId;
return plugin.controllers.user.update(ctx);
}
};
plugin.routes["content-api"].routes.push({