diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index d1e95ebef..81c07a329 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -19,7 +19,4 @@ export default class UpdateUserInfosArgs { @Field({ nullable: true }) passwordNew?: string - - @Field({ nullable: true }) - coinanimation?: boolean } diff --git a/backend/src/graphql/enum/Setting.ts b/backend/src/graphql/enum/Setting.ts deleted file mode 100644 index 8efeec72d..000000000 --- a/backend/src/graphql/enum/Setting.ts +++ /dev/null @@ -1,5 +0,0 @@ -enum Setting { - COIN_ANIMATION = 'coinanimation', -} - -export { Setting } diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 4f577f60a..86c56312f 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -15,8 +15,6 @@ export class User { this.language = user.language this.publisherId = user.publisherId this.isAdmin = user.isAdmin - // TODO - this.coinanimation = null this.klickTipp = null this.hasElopage = null } @@ -61,11 +59,6 @@ export class User { @Field(() => Date, { nullable: true }) isAdmin: Date | null - // TODO this is a bit inconsistent with what we query from the database - // therefore all those fields are now nullable with default value null - @Field(() => Boolean, { nullable: true }) - coinanimation: boolean | null - @Field(() => KlickTipp, { nullable: true }) klickTipp: KlickTipp | null diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index 1afce832b..78b630834 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -344,7 +344,6 @@ describe('UserResolver', () => { expect.objectContaining({ data: { login: { - coinanimation: true, email: 'bibi@bloxberg.de', firstName: 'Bibi', hasElopage: false, @@ -479,7 +478,6 @@ describe('UserResolver', () => { firstName: 'Bibi', lastName: 'Bloxberg', language: 'de', - coinanimation: true, klickTipp: { newsletterState: false, }, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 7080ad68b..9c8a9f16b 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -14,7 +14,6 @@ import UnsecureLoginArgs from '@arg/UnsecureLoginArgs' import UpdateUserInfosArgs from '@arg/UpdateUserInfosArgs' import { klicktippNewsletterStateMiddleware } from '@/middleware/klicktippMiddleware' import { UserSettingRepository } from '@repository/UserSettingRepository' -import { Setting } from '@enum/Setting' import { OptInType } from '@enum/OptInType' import { LoginEmailOptIn } from '@entity/LoginEmailOptIn' import { sendResetPasswordEmail as sendResetPasswordEmailMailer } from '@/mailer/sendResetPasswordEmail' @@ -228,15 +227,6 @@ export class UserResolver { // Elopage Status & Stored PublisherId user.hasElopage = await this.hasElopage(context) - // coinAnimation - const userSettingRepository = getCustomRepository(UserSettingRepository) - const coinanimation = await userSettingRepository - .readBoolean(userEntity.id, Setting.COIN_ANIMATION) - .catch((error) => { - logger.error('error:', error) - throw new Error(error) - }) - user.coinanimation = coinanimation logger.debug(`verifyLogin... successful: ${user.firstName}.${user.lastName}, ${user.email}`) return user } @@ -294,15 +284,6 @@ export class UserResolver { DbUser.save(dbUser) } - // coinAnimation - const userSettingRepository = getCustomRepository(UserSettingRepository) - const coinanimation = await userSettingRepository - .readBoolean(dbUser.id, Setting.COIN_ANIMATION) - .catch((error) => { - throw new Error(error) - }) - user.coinanimation = coinanimation - context.setHeaders.push({ key: 'token', value: encode(dbUser.pubKey), @@ -598,12 +579,10 @@ export class UserResolver { @Mutation(() => Boolean) async updateUserInfos( @Args() - { firstName, lastName, language, password, passwordNew, coinanimation }: UpdateUserInfosArgs, + { firstName, lastName, language, password, passwordNew }: UpdateUserInfosArgs, @Ctx() context: Context, ): Promise { - logger.info( - `updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***, ${coinanimation})...`, - ) + logger.info(`updateUserInfos(${firstName}, ${lastName}, ${language}, ***, ***)...`) const userEntity = getUser(context) if (firstName) { @@ -655,15 +634,6 @@ export class UserResolver { await queryRunner.startTransaction('READ UNCOMMITTED') try { - if (coinanimation !== null && coinanimation !== undefined) { - queryRunner.manager - .getCustomRepository(UserSettingRepository) - .setOrUpdate(userEntity.id, Setting.COIN_ANIMATION, coinanimation.toString()) - .catch((error) => { - throw new Error('error saving coinanimation: ' + error) - }) - } - await queryRunner.manager.save(userEntity).catch((error) => { throw new Error('error saving user: ' + error) }) diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 4598cbbe2..6e1fe9174 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -31,7 +31,6 @@ export const updateUserInfos = gql` $password: String $passwordNew: String $locale: String - $coinanimation: Boolean ) { updateUserInfos( firstName: $firstName @@ -39,7 +38,6 @@ export const updateUserInfos = gql` password: $password passwordNew: $passwordNew language: $locale - coinanimation: $coinanimation ) } ` diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index 82067c968..16b2b71ae 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -8,7 +8,6 @@ export const login = gql` firstName lastName language - coinanimation klickTipp { newsletterState } @@ -26,7 +25,6 @@ export const verifyLogin = gql` firstName lastName language - coinanimation klickTipp { newsletterState } diff --git a/backend/src/typeorm/repository/UserSettingRepository.ts b/backend/src/typeorm/repository/UserSettingRepository.ts index 528090ff2..f911cfd1a 100644 --- a/backend/src/typeorm/repository/UserSettingRepository.ts +++ b/backend/src/typeorm/repository/UserSettingRepository.ts @@ -1,33 +1,22 @@ import { EntityRepository, Repository } from '@dbTools/typeorm' import { UserSetting } from '@entity/UserSetting' -import { Setting } from '@enum/Setting' import { isStringBoolean } from '@/util/validate' @EntityRepository(UserSetting) export class UserSettingRepository extends Repository { - async setOrUpdate(userId: number, key: Setting, value: string): Promise { - switch (key) { - case Setting.COIN_ANIMATION: - if (!isStringBoolean(value)) { - throw new Error("coinanimation value isn't boolean") - } - break - default: - throw new Error("key isn't defined: " + key) - } - let entity = await this.findOne({ userId: userId, key: key }) + async setOrUpdate(userId: number, value: string): Promise { + let entity = await this.findOne({ userId: userId }) if (!entity) { entity = new UserSetting() entity.userId = userId - entity.key = key } entity.value = value return this.save(entity) } - async readBoolean(userId: number, key: Setting): Promise { - const entity = await this.findOne({ userId: userId, key: key }) + async readBoolean(userId: number): Promise { + const entity = await this.findOne({ userId: userId }) if (!entity || !isStringBoolean(entity.value)) { return true }