mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
Merge branch 'upgrade_typescript' into admin_add_ai_chat
This commit is contained in:
commit
f466a46407
@ -22,8 +22,6 @@
|
||||
"locales": "scripts/sort.sh"
|
||||
},
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^8.26.1",
|
||||
"@typescript-eslint/parser": "^8.26.1",
|
||||
"apollo-server-express": "^2.25.2",
|
||||
"await-semaphore": "^0.1.3",
|
||||
"axios": "^0.21.1",
|
||||
@ -72,8 +70,10 @@
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/sodium-native": "^2.3.5",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||
"@typescript-eslint/parser": "^5.62.0",
|
||||
"apollo-server-testing": "^2.25.2",
|
||||
"eslint": "^8.37.0",
|
||||
"eslint": "^8.57.1",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-config-standard": "^17.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.4",
|
||||
@ -95,7 +95,7 @@
|
||||
"ts-jest": "^27.0.5",
|
||||
"ts-node": "^10.0.0",
|
||||
"tsconfig-paths": "^3.14.0",
|
||||
"typescript": "^5.8.2"
|
||||
"typescript": "^4.9.5"
|
||||
},
|
||||
"nodemonConfig": {
|
||||
"ignore": [
|
||||
|
||||
@ -49,14 +49,16 @@ export class GmsUser {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
user.alias &&
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
) {
|
||||
return user.alias
|
||||
}
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
((!user.alias && user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
((!user.alias &&
|
||||
(user.gmsPublishName as PublishNameType) ===
|
||||
PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
) {
|
||||
return (
|
||||
this.firstUpperCaseSecondLowerCase(user.firstName) +
|
||||
@ -68,16 +70,18 @@ export class GmsUser {
|
||||
private getGmsFirstName(user: dbUser): string | null | undefined {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
(user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST_INITIAL ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_FULL)
|
||||
((user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_FIRST ||
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_FIRST_INITIAL ||
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_FULL)
|
||||
) {
|
||||
return user.firstName
|
||||
}
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
((!user.alias && user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
((!user.alias &&
|
||||
(user.gmsPublishName as PublishNameType) ===
|
||||
PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
) {
|
||||
// return this.firstUpperCaseSecondLowerCase(user.firstName)
|
||||
return null // cause to delete firstname in gms
|
||||
@ -85,10 +89,16 @@ export class GmsUser {
|
||||
}
|
||||
|
||||
private getGmsLastName(user: dbUser): string | null | undefined {
|
||||
if (user.gmsAllowed && user.gmsPublishName === PublishNameType.PUBLISH_NAME_FULL) {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_FULL
|
||||
) {
|
||||
return user.lastName
|
||||
}
|
||||
if (user.gmsAllowed && user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST_INITIAL) {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
(user.gmsPublishName as PublishNameType) === PublishNameType.PUBLISH_NAME_FIRST_INITIAL
|
||||
) {
|
||||
return this.firstUpperCaseSecondLowerCase(user.lastName)
|
||||
}
|
||||
return null // cause to delete lastname in gms
|
||||
@ -114,8 +124,10 @@ export class GmsUser {
|
||||
private getGmsCountryCode(user: dbUser): string | undefined {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
(user.emailContact?.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_COUNTRY ||
|
||||
user.emailContact?.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL)
|
||||
((user.emailContact?.gmsPublishPhone as GmsPublishPhoneType) ===
|
||||
GmsPublishPhoneType.GMS_PUBLISH_PHONE_COUNTRY ||
|
||||
(user.emailContact?.gmsPublishPhone as GmsPublishPhoneType) ===
|
||||
GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL)
|
||||
) {
|
||||
return user.emailContact?.countryCode
|
||||
}
|
||||
@ -124,7 +136,8 @@ export class GmsUser {
|
||||
private getGmsPhone(user: dbUser): string | undefined {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
user.emailContact?.gmsPublishPhone === GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL
|
||||
(user.emailContact?.gmsPublishPhone as GmsPublishPhoneType) ===
|
||||
GmsPublishPhoneType.GMS_PUBLISH_PHONE_FULL
|
||||
) {
|
||||
return user.emailContact?.phone
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ export class ContributionResolver {
|
||||
dbContributions.map((contribution) => {
|
||||
// filter out moderator messages for this call
|
||||
contribution.messages = contribution.messages?.filter(
|
||||
(m) => m.type !== ContributionMessageType.MODERATOR,
|
||||
(m) => (m.type as ContributionMessageType) !== ContributionMessageType.MODERATOR,
|
||||
)
|
||||
return new Contribution(contribution, user)
|
||||
}),
|
||||
@ -352,7 +352,7 @@ export class ContributionResolver {
|
||||
}
|
||||
const moderator = getUser(context)
|
||||
if (
|
||||
contribution.contributionType === ContributionType.USER &&
|
||||
(contribution.contributionType as ContributionType) === ContributionType.USER &&
|
||||
contribution.userId === moderator.id
|
||||
) {
|
||||
throw new LogError('Own contribution can not be deleted as admin')
|
||||
@ -532,8 +532,9 @@ export class ContributionResolver {
|
||||
throw new LogError('Contribution not found', id)
|
||||
}
|
||||
if (
|
||||
contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
contributionToUpdate.contributionStatus !== ContributionStatus.PENDING
|
||||
(contributionToUpdate.contributionStatus as ContributionStatus) !==
|
||||
ContributionStatus.IN_PROGRESS &&
|
||||
(contributionToUpdate.contributionStatus as ContributionStatus) !== ContributionStatus.PENDING
|
||||
) {
|
||||
throw new LogError(
|
||||
'Status of the contribution is not allowed',
|
||||
|
||||
@ -266,7 +266,7 @@ export class TransactionResolver {
|
||||
// userTransactions.forEach((transaction: dbTransaction) => {
|
||||
// use normal for loop because of timing problems with await in forEach-loop
|
||||
for (const transaction of userTransactions) {
|
||||
if (transaction.typeId === TransactionTypeId.CREATION) {
|
||||
if ((transaction.typeId as TransactionTypeId) === TransactionTypeId.CREATION) {
|
||||
continue
|
||||
}
|
||||
if (transaction.linkedUserId && !involvedUserIds.includes(transaction.linkedUserId)) {
|
||||
@ -398,7 +398,7 @@ export class TransactionResolver {
|
||||
: involvedUsers.find((u) => u.id === userTransaction.linkedUserId)
|
||||
*/
|
||||
let linkedUser: User | undefined
|
||||
if (userTransaction.typeId === TransactionTypeId.CREATION) {
|
||||
if ((userTransaction.typeId as TransactionTypeId) === TransactionTypeId.CREATION) {
|
||||
linkedUser = communityUser
|
||||
logger.debug('CREATION-linkedUser=', linkedUser)
|
||||
} else if (userTransaction.linkedUserId) {
|
||||
|
||||
@ -193,7 +193,10 @@ export class UserResolver {
|
||||
})
|
||||
}
|
||||
|
||||
if (dbUser.passwordEncryptionType !== PasswordEncryptionType.GRADIDO_ID) {
|
||||
if (
|
||||
(dbUser.passwordEncryptionType as PasswordEncryptionType) !==
|
||||
PasswordEncryptionType.GRADIDO_ID
|
||||
) {
|
||||
dbUser.passwordEncryptionType = PasswordEncryptionType.GRADIDO_ID
|
||||
dbUser.password = await encryptPassword(dbUser, password)
|
||||
await dbUser.save()
|
||||
@ -571,7 +574,7 @@ export class UserResolver {
|
||||
|
||||
// Sign into Klicktipp
|
||||
// TODO do we always signUp the user? How to handle things with old users?
|
||||
if (userContact.emailOptInTypeId === OptInType.EMAIL_OPT_IN_REGISTER) {
|
||||
if ((userContact.emailOptInTypeId as OptInType) === OptInType.EMAIL_OPT_IN_REGISTER) {
|
||||
try {
|
||||
await subscribe(userContact.email, user.language, user.firstName, user.lastName)
|
||||
logger.debug(
|
||||
|
||||
@ -2,6 +2,7 @@ import { Point } from '@dbTools/typeorm'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
|
||||
import { UpdateUserInfosArgs } from '@/graphql/arg/UpdateUserInfosArgs'
|
||||
import { GmsPublishLocationType } from '@/graphql/enum/GmsPublishLocationType'
|
||||
import { PublishNameType } from '@/graphql/enum/PublishNameType'
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
@ -44,13 +45,14 @@ export function compareGmsRelevantUserSettings(
|
||||
}
|
||||
if (
|
||||
updateUserInfosArgs.gmsPublishLocation &&
|
||||
orgUser.gmsPublishLocation !== updateUserInfosArgs.gmsPublishLocation
|
||||
(orgUser.gmsPublishLocation as GmsPublishLocationType) !==
|
||||
updateUserInfosArgs.gmsPublishLocation
|
||||
) {
|
||||
return true
|
||||
}
|
||||
if (
|
||||
updateUserInfosArgs.gmsPublishName &&
|
||||
orgUser.gmsPublishName !== updateUserInfosArgs.gmsPublishName
|
||||
(orgUser.gmsPublishName as PublishNameType) !== updateUserInfosArgs.gmsPublishName
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ export abstract class AbstractUnconfirmedContributionRole {
|
||||
throw new LogError('Month of contribution can not be changed')
|
||||
}
|
||||
|
||||
if (this.self.contributionStatus === ContributionStatus.CONFIRMED) {
|
||||
if ((this.self.contributionStatus as ContributionStatus) === ContributionStatus.CONFIRMED) {
|
||||
throw new LogError('the contribution is already confirmed, cannot be changed anymore')
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,10 @@ export class UnconfirmedContributionUserRole extends AbstractUnconfirmedContribu
|
||||
throw new LogError('Can not update contribution of another user', this.self, user.id)
|
||||
}
|
||||
// only admins and moderators can update it when status is other than progress or pending
|
||||
const contributionStatus = this.self.contributionStatus as ContributionStatus
|
||||
if (
|
||||
this.self.contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
this.self.contributionStatus !== ContributionStatus.PENDING
|
||||
contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
contributionStatus !== ContributionStatus.PENDING
|
||||
) {
|
||||
throw new LogError(
|
||||
'Contribution can not be updated due to status',
|
||||
|
||||
@ -22,7 +22,7 @@ export class UnconfirmedContributionUserAddMessageRole extends AbstractUnconfirm
|
||||
|
||||
protected update(): void {
|
||||
if (
|
||||
this.self.contributionStatus === ContributionStatus.IN_PROGRESS ||
|
||||
(this.self.contributionStatus as ContributionStatus) === ContributionStatus.IN_PROGRESS ||
|
||||
this.self.resubmissionAt !== null
|
||||
) {
|
||||
this.self.contributionStatus = ContributionStatus.PENDING
|
||||
@ -38,9 +38,10 @@ export class UnconfirmedContributionUserAddMessageRole extends AbstractUnconfirm
|
||||
}
|
||||
// only admins and moderators can update it when status is other than progress or pending
|
||||
// but we are in the user add message role.. we are currently not admin or moderator
|
||||
const contributionStatus = this.self.contributionStatus as ContributionStatus
|
||||
if (
|
||||
this.self.contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
this.self.contributionStatus !== ContributionStatus.PENDING
|
||||
contributionStatus !== ContributionStatus.IN_PROGRESS &&
|
||||
contributionStatus !== ContributionStatus.PENDING
|
||||
) {
|
||||
throw new LogError(
|
||||
'Contribution can not be updated due to status',
|
||||
|
||||
@ -52,7 +52,8 @@ export const userFactory = async (
|
||||
if (user.deletedAt) {
|
||||
dbUser.deletedAt = user.deletedAt
|
||||
}
|
||||
if (user.role && (user.role === RoleNames.ADMIN || user.role === RoleNames.MODERATOR)) {
|
||||
const userRole = user.role as RoleNames
|
||||
if (userRole && (userRole === RoleNames.ADMIN || userRole === RoleNames.MODERATOR)) {
|
||||
await setUserRole(dbUser, user.role)
|
||||
}
|
||||
await dbUser.save()
|
||||
|
||||
6180
backend/yarn.lock
6180
backend/yarn.lock
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,3 @@
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
|
||||
@ -2435,7 +2435,7 @@ graceful-fs@^4.2.4:
|
||||
joi "^17.13.3"
|
||||
|
||||
"gradido-database@file:../database":
|
||||
version "2.4.4"
|
||||
version "2.5.1"
|
||||
dependencies:
|
||||
"@types/uuid" "^8.3.4"
|
||||
cross-env "^7.0.3"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user