diff --git a/package.json b/package.json index 14c557e..45355a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "harmony-back", - "version": "0.12.2", + "version": "0.12.3", "private": true, "description": "A Strapi application", "scripts": { diff --git a/src/components/configuration/parameter.json b/src/components/configuration/parameter.json new file mode 100644 index 0000000..f054906 --- /dev/null +++ b/src/components/configuration/parameter.json @@ -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 + } + } +} diff --git a/src/components/configuration/privacy.json b/src/components/configuration/privacy.json new file mode 100644 index 0000000..6189b93 --- /dev/null +++ b/src/components/configuration/privacy.json @@ -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 + } + } +} diff --git a/src/extensions/documentation/documentation/1.0.0/full_documentation.json b/src/extensions/documentation/documentation/1.0.0/full_documentation.json index d50e10b..c409641 100644 --- a/src/extensions/documentation/documentation/1.0.0/full_documentation.json +++ b/src/extensions/documentation/documentation/1.0.0/full_documentation.json @@ -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" diff --git a/src/extensions/users-permissions/content-types/user/schema.json b/src/extensions/users-permissions/content-types/user/schema.json index 06bb915..74fc19c 100644 --- a/src/extensions/users-permissions/content-types/user/schema.json +++ b/src/extensions/users-permissions/content-types/user/schema.json @@ -225,6 +225,16 @@ }, "languages": { "type": "json" + }, + "parameter": { + "type": "component", + "repeatable": false, + "component": "configuration.parameter" + }, + "privacy": { + "type": "component", + "repeatable": false, + "component": "configuration.privacy" } } } diff --git a/src/extensions/users-permissions/strapi-server.ts b/src/extensions/users-permissions/strapi-server.ts index 6b38d24..7efff29 100644 --- a/src/extensions/users-permissions/strapi-server.ts +++ b/src/extensions/users-permissions/strapi-server.ts @@ -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({ diff --git a/types/generated/components.d.ts b/types/generated/components.d.ts index b1a6dc5..4baf781 100644 --- a/types/generated/components.d.ts +++ b/types/generated/components.d.ts @@ -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; + pushNotification: Schema.Attribute.Boolean & + Schema.Attribute.DefaultTo; + sendNewsgroup: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo; + }; +} + +export interface ConfigurationPrivacy extends Struct.ComponentSchema { + collectionName: 'components_configuration_privacies'; + info: { + description: ''; + displayName: 'privacy'; + icon: 'key'; + }; + attributes: { + allowInvite: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo; + allowMessage: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo; + allowTag: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo; + profileVisibility: Schema.Attribute.Enumeration< + ['public', 'contacts', 'private'] + >; + showOnline: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo; + }; +} + export interface GroupActivity extends Struct.ComponentSchema { collectionName: 'components_group_activities'; info: { @@ -82,6 +115,8 @@ declare module '@strapi/strapi' { export module Public { export interface ComponentSchemas { 'address.full-address': AddressFullAddress; + 'configuration.parameter': ConfigurationParameter; + 'configuration.privacy': ConfigurationPrivacy; 'group.activity': GroupActivity; 'social.tags': SocialTags; 'user.language': UserLanguage; diff --git a/types/generated/contentTypes.d.ts b/types/generated/contentTypes.d.ts index 58a671a..f779f08 100644 --- a/types/generated/contentTypes.d.ts +++ b/types/generated/contentTypes.d.ts @@ -1889,6 +1889,7 @@ export interface PluginUsersPermissionsUser > & Schema.Attribute.Private; name: Schema.Attribute.String; + parameter: Schema.Attribute.Component<'configuration.parameter', false>; password: Schema.Attribute.Password & Schema.Attribute.Private & Schema.Attribute.SetMinMaxLength<{ @@ -1899,6 +1900,7 @@ export interface PluginUsersPermissionsUser 'oneToMany', 'api::post-ownership.post-ownership' >; + privacy: Schema.Attribute.Component<'configuration.privacy', false>; provider: Schema.Attribute.String; publishedAt: Schema.Attribute.DateTime; related_contacts: Schema.Attribute.Relation<