diff --git a/app/graphql/mutations/users/update.rb b/app/graphql/mutations/users/update.rb index d4d1efc3..96e78b94 100644 --- a/app/graphql/mutations/users/update.rb +++ b/app/graphql/mutations/users/update.rb @@ -20,6 +20,7 @@ class Update < BaseMutation String, required: false, description: 'New password repeat for the user to check for typos, required if password is set.' + argument :readme, String, required: false, description: 'New readme for the user.' argument :username, String, required: false, description: 'New username for the user.' argument :mfa, Types::Input::MfaInput, required: false, description: 'The data of the mfa validation' diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb index 4e2f427e..dce975f2 100644 --- a/app/graphql/types/user_type.rb +++ b/app/graphql/types/user_type.rb @@ -19,6 +19,7 @@ class UserType < Types::BaseObject authorize: :read_email field :firstname, String, null: true, description: 'Firstname of the user' field :lastname, String, null: true, description: 'Lastname of the user' + field :readme, String, null: true, description: 'Readme of the user' field :username, String, null: false, description: 'Username of the user' field :namespace_memberships, Types::NamespaceMemberType.connection_type, diff --git a/db/migrate/20260509183408_add_readme_to_user.rb b/db/migrate/20260509183408_add_readme_to_user.rb new file mode 100644 index 00000000..7a0e2106 --- /dev/null +++ b/db/migrate/20260509183408_add_readme_to_user.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddReadmeToUser < Code0::ZeroTrack::Database::Migration[1.0] + def change + add_column :users, :readme, :text, null: true, limit: 5000 + end +end diff --git a/db/schema_migrations/20260509183408 b/db/schema_migrations/20260509183408 new file mode 100644 index 00000000..d494d0c2 --- /dev/null +++ b/db/schema_migrations/20260509183408 @@ -0,0 +1 @@ +80d9fdf9c4750b00b13bd15ea77bb053c3adf998670c519fb3f49b23ee029511 \ No newline at end of file diff --git a/db/structure.sql b/db/structure.sql index 7ce0a9a3..55ef764b 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -860,6 +860,8 @@ CREATE TABLE users ( admin boolean DEFAULT false NOT NULL, totp_secret text, email_verified_at timestamp with time zone, + readme text, + CONSTRAINT check_11461c37fb CHECK ((char_length(readme) <= 5000)), CONSTRAINT check_3bedaaa612 CHECK ((char_length(email) <= 255)), CONSTRAINT check_56606ce552 CHECK ((char_length(username) <= 50)), CONSTRAINT check_60346c5299 CHECK ((char_length(lastname) <= 50)), diff --git a/docs/graphql/mutation/usersupdate.md b/docs/graphql/mutation/usersupdate.md index d27a05e0..3aff8dae 100644 --- a/docs/graphql/mutation/usersupdate.md +++ b/docs/graphql/mutation/usersupdate.md @@ -16,6 +16,7 @@ Update an existing user. | `mfa` | [`MfaInput`](../input_object/mfainput.md) | The data of the mfa validation | | `password` | [`String`](../scalar/string.md) | New password for the user. | | `passwordRepeat` | [`String`](../scalar/string.md) | New password repeat for the user to check for typos, required if password is set. | +| `readme` | [`String`](../scalar/string.md) | New readme for the user. | | `userId` | [`UserID!`](../scalar/userid.md) | ID of the user to update. | | `username` | [`String`](../scalar/string.md) | New username for the user. | diff --git a/docs/graphql/object/user.md b/docs/graphql/object/user.md index 16ca68de..0b8f27af 100644 --- a/docs/graphql/object/user.md +++ b/docs/graphql/object/user.md @@ -20,6 +20,7 @@ Represents a user | `mfaStatus` | [`MfaStatus`](../object/mfastatus.md) | Multi-factor authentication status of this user | | `namespace` | [`Namespace`](../object/namespace.md) | Namespace of this user | | `namespaceMemberships` | [`NamespaceMemberConnection!`](../object/namespacememberconnection.md) | Namespace Memberships of this user | +| `readme` | [`String`](../scalar/string.md) | Readme of the user | | `sessions` | [`UserSessionConnection!`](../object/usersessionconnection.md) | Sessions of this user | | `updatedAt` | [`Time!`](../scalar/time.md) | Time when this User was last updated | | `userAbilities` | [`UserUserAbilities!`](../object/useruserabilities.md) | Abilities for the current user on this User | diff --git a/spec/graphql/types/user_type_spec.rb b/spec/graphql/types/user_type_spec.rb index 361d0193..e27bba55 100644 --- a/spec/graphql/types/user_type_spec.rb +++ b/spec/graphql/types/user_type_spec.rb @@ -11,6 +11,7 @@ namespace firstname lastname + readme admin namespaceMemberships avatarPath diff --git a/spec/requests/graphql/mutation/users/update_spec.rb b/spec/requests/graphql/mutation/users/update_spec.rb index 8fdf21cc..772cd58b 100644 --- a/spec/requests/graphql/mutation/users/update_spec.rb +++ b/spec/requests/graphql/mutation/users/update_spec.rb @@ -13,6 +13,7 @@ user { id username + readme admin } } @@ -26,6 +27,7 @@ { userId: current_user.to_global_id.to_s, username: name, + readme: "# Hello\n\nThis is my profile README.", } end @@ -38,16 +40,18 @@ it 'updates user' do expect(graphql_data_at(:users_update, :user, :id)).to be_present + expect(graphql_data_at(:users_update, :user, :readme)).to be_present user = SagittariusSchema.object_from_id(graphql_data_at(:users_update, :user, :id)) expect(user.username).to eq(input[:username]) + expect(user.readme).to eq(input[:readme]) is_expected.to create_audit_event( :user_updated, author_id: current_user.id, entity_id: user.id, entity_type: 'User', - details: { username: input[:username] }, + details: { username: input[:username], readme: input[:readme] }, target_id: user.id, target_type: 'User' )