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

@@ -1,6 +1,6 @@
{ {
"name": "harmony-back", "name": "harmony-back",
"version": "0.12.2", "version": "0.12.3",
"private": true, "private": true,
"description": "A Strapi application", "description": "A Strapi application",
"scripts": { "scripts": {

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", "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-12T20:11:53.117Z" "x-generation-date": "2025-11-13T22:01:13.582Z"
}, },
"x-strapi-config": { "x-strapi-config": {
"plugins": [ "plugins": [
@@ -17867,6 +17867,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "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": { "AnnouncementRequest": {
"type": "object", "type": "object",
"required": [ "required": [
@@ -21473,6 +21524,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -25406,6 +25463,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -28898,6 +28961,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -32838,6 +32907,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -37029,6 +37104,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -41669,6 +41750,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -45599,6 +45686,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -49431,6 +49524,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -53250,6 +53349,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -57105,6 +57210,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -60852,6 +60963,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -64776,6 +64893,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -68773,6 +68896,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -72259,6 +72388,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -76674,6 +76809,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -80478,6 +80619,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -84603,6 +84750,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -88440,6 +88593,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -92381,6 +92540,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -96223,6 +96388,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -99570,6 +99741,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -104126,6 +104303,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -108011,6 +108194,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"
@@ -111856,6 +112045,12 @@
}, },
"tags": {}, "tags": {},
"languages": {}, "languages": {},
"parameter": {
"$ref": "#/components/schemas/ConfigurationParameterComponent"
},
"privacy": {
"$ref": "#/components/schemas/ConfigurationPrivacyComponent"
},
"createdAt": { "createdAt": {
"type": "string", "type": "string",
"format": "date-time" "format": "date-time"

View File

@@ -225,6 +225,16 @@
}, },
"languages": { "languages": {
"type": "json" "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", "experience",
"tags", "tags",
"languages", "languages",
"parameter",
"privacy",
]); ]);
/* /*
@@ -248,9 +250,26 @@ module.exports = (plugin) => {
ctx.request.body = newData; ctx.request.body = newData;
ctx.params = { id: user.id }; ctx.params = { id: user.id };
const avatarId = await uploadImage(ctx, "avatar", newData.username); const keysExcludingParameterAndPrivacy = Object.keys(newData).filter(
if (avatarId != 0) ctx.request.body.avatar = avatarId; (key) => key !== "parameter" && key !== "privacy"
return plugin.controllers.user.update(ctx); );
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({ plugin.routes["content-api"].routes.push({

View File

@@ -19,6 +19,39 @@ export interface AddressFullAddress extends Struct.ComponentSchema {
}; };
} }
export interface ConfigurationParameter extends Struct.ComponentSchema {
collectionName: 'components_configuration_parameters';
info: {
displayName: 'parameter';
icon: 'cog';
};
attributes: {
emailNotification: Schema.Attribute.Boolean &
Schema.Attribute.DefaultTo<false>;
pushNotification: Schema.Attribute.Boolean &
Schema.Attribute.DefaultTo<false>;
sendNewsgroup: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
};
}
export interface ConfigurationPrivacy extends Struct.ComponentSchema {
collectionName: 'components_configuration_privacies';
info: {
description: '';
displayName: 'privacy';
icon: 'key';
};
attributes: {
allowInvite: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<true>;
allowMessage: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<true>;
allowTag: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<true>;
profileVisibility: Schema.Attribute.Enumeration<
['public', 'contacts', 'private']
>;
showOnline: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<true>;
};
}
export interface GroupActivity extends Struct.ComponentSchema { export interface GroupActivity extends Struct.ComponentSchema {
collectionName: 'components_group_activities'; collectionName: 'components_group_activities';
info: { info: {
@@ -82,6 +115,8 @@ declare module '@strapi/strapi' {
export module Public { export module Public {
export interface ComponentSchemas { export interface ComponentSchemas {
'address.full-address': AddressFullAddress; 'address.full-address': AddressFullAddress;
'configuration.parameter': ConfigurationParameter;
'configuration.privacy': ConfigurationPrivacy;
'group.activity': GroupActivity; 'group.activity': GroupActivity;
'social.tags': SocialTags; 'social.tags': SocialTags;
'user.language': UserLanguage; 'user.language': UserLanguage;

View File

@@ -1889,6 +1889,7 @@ export interface PluginUsersPermissionsUser
> & > &
Schema.Attribute.Private; Schema.Attribute.Private;
name: Schema.Attribute.String; name: Schema.Attribute.String;
parameter: Schema.Attribute.Component<'configuration.parameter', false>;
password: Schema.Attribute.Password & password: Schema.Attribute.Password &
Schema.Attribute.Private & Schema.Attribute.Private &
Schema.Attribute.SetMinMaxLength<{ Schema.Attribute.SetMinMaxLength<{
@@ -1899,6 +1900,7 @@ export interface PluginUsersPermissionsUser
'oneToMany', 'oneToMany',
'api::post-ownership.post-ownership' 'api::post-ownership.post-ownership'
>; >;
privacy: Schema.Attribute.Component<'configuration.privacy', false>;
provider: Schema.Attribute.String; provider: Schema.Attribute.String;
publishedAt: Schema.Attribute.DateTime; publishedAt: Schema.Attribute.DateTime;
related_contacts: Schema.Attribute.Relation< related_contacts: Schema.Attribute.Relation<