diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index cc61e8c36..0920fb3bc 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -44,19 +44,19 @@ export class UpdateUserInfosArgs { @IsBoolean() hideAmountGDT?: boolean - @Field({ nullable: false }) + @Field({ nullable: true, defaultValue: true }) @IsBoolean() - gmsAllowed: boolean + gmsAllowed?: boolean - @Field(() => Int, { nullable: false }) + @Field(() => Int, { nullable: true, defaultValue: 0 }) @IsInt() - gmsPublishName: number + gmsPublishName?: number | null @Field(() => Location, { nullable: true }) @isValidLocation() gmsLocation?: Location | null - @Field(() => Int, { nullable: false }) + @Field(() => Int, { nullable: true, defaultValue: 2 }) @IsInt() - gmsPublishLocation: number + gmsPublishLocation?: number | null } diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 8a4e8b7fc..3f70ce112 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -19,6 +19,8 @@ import { SearchUsersFilters } from '@arg/SearchUsersFilters' import { SetUserRoleArgs } from '@arg/SetUserRoleArgs' import { UnsecureLoginArgs } from '@arg/UnsecureLoginArgs' import { UpdateUserInfosArgs } from '@arg/UpdateUserInfosArgs' +import { GmsPublishLocationType } from '@enum/GmsPublishLocationType' +import { GmsPublishNameType } from '@enum/GmsPublishNameType' import { OptInType } from '@enum/OptInType' import { Order } from '@enum/Order' import { PasswordEncryptionType } from '@enum/PasswordEncryptionType' @@ -559,6 +561,17 @@ export class UserResolver { logger.info( `updateUserInfos(${firstName}, ${lastName}, ${alias}, ${language}, ***, ***, ${hideAmountGDD}, ${hideAmountGDT}, ${gmsAllowed}, ${gmsPublishName}, ${gmsLocation}, ${gmsPublishLocation})...`, ) + // check default arg settings + if (gmsAllowed === null || gmsAllowed === undefined) { + gmsAllowed = true + } + if (!gmsPublishName) { + gmsPublishName = GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS + } + if (!gmsPublishLocation) { + gmsPublishLocation = GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM + } + const user = getUser(context) // try { if (firstName) { diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index a658c84d7..b10bb4b4e 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -34,10 +34,10 @@ export const updateUserInfos = gql` $locale: String $hideAmountGDD: Boolean $hideAmountGDT: Boolean - $gmsAllowed: Boolean! - $gmsPublishName: Int! + $gmsAllowed: Boolean + $gmsPublishName: Int $gmsLocation: Location - $gmsPublishLocation: Int! + $gmsPublishLocation: Int ) { updateUserInfos( firstName: $firstName diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index b4f96179f..14e9a62bc 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -25,25 +25,33 @@ export const forgotPassword = gql` ` export const updateUserInfos = gql` - mutation( - $alias: String + mutation ( $firstName: String $lastName: String + $alias: String $password: String $passwordNew: String $locale: String $hideAmountGDD: Boolean $hideAmountGDT: Boolean + $gmsAllowed: Boolean + $gmsPublishName: Int + $gmsLocation: Location + $gmsPublishLocation: Int ) { updateUserInfos( - alias: $alias firstName: $firstName lastName: $lastName + alias: $alias password: $password passwordNew: $passwordNew language: $locale hideAmountGDD: $hideAmountGDD hideAmountGDT: $hideAmountGDT + gmsAllowed: $gmsAllowed + gmsPublishName: $gmsPublishName + gmsLocation: $gmsLocation + gmsPublishLocation: $gmsPublishLocation ) } `