mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
refactor(backend): remove admin create contributions
This commit is contained in:
parent
7970c9410b
commit
3cc5494736
@ -42,7 +42,6 @@ export enum RIGHTS {
|
|||||||
DELETE_USER = 'DELETE_USER',
|
DELETE_USER = 'DELETE_USER',
|
||||||
UNDELETE_USER = 'UNDELETE_USER',
|
UNDELETE_USER = 'UNDELETE_USER',
|
||||||
ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION',
|
ADMIN_CREATE_CONTRIBUTION = 'ADMIN_CREATE_CONTRIBUTION',
|
||||||
ADMIN_CREATE_CONTRIBUTIONS = 'ADMIN_CREATE_CONTRIBUTIONS',
|
|
||||||
ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION',
|
ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION',
|
||||||
ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION',
|
ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION',
|
||||||
LIST_UNCONFIRMED_CONTRIBUTIONS = 'LIST_UNCONFIRMED_CONTRIBUTIONS',
|
LIST_UNCONFIRMED_CONTRIBUTIONS = 'LIST_UNCONFIRMED_CONTRIBUTIONS',
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
import { ObjectType, Field } from 'type-graphql'
|
|
||||||
|
|
||||||
@ObjectType()
|
|
||||||
export class AdminCreateContributions {
|
|
||||||
constructor() {
|
|
||||||
this.success = false
|
|
||||||
this.successfulContribution = []
|
|
||||||
this.failedContribution = []
|
|
||||||
}
|
|
||||||
|
|
||||||
@Field(() => Boolean)
|
|
||||||
success: boolean
|
|
||||||
|
|
||||||
@Field(() => [String])
|
|
||||||
successfulContribution: string[]
|
|
||||||
|
|
||||||
@Field(() => [String])
|
|
||||||
failedContribution: string[]
|
|
||||||
}
|
|
||||||
@ -8,7 +8,6 @@ import { UserContact } from '@entity/UserContact'
|
|||||||
import { User as DbUser } from '@entity/User'
|
import { User as DbUser } from '@entity/User'
|
||||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||||
|
|
||||||
import { AdminCreateContributions } from '@model/AdminCreateContributions'
|
|
||||||
import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
|
import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
|
||||||
import { Contribution, ContributionListResult } from '@model/Contribution'
|
import { Contribution, ContributionListResult } from '@model/Contribution'
|
||||||
import { Decay } from '@model/Decay'
|
import { Decay } from '@model/Decay'
|
||||||
@ -329,33 +328,6 @@ export class ContributionResolver {
|
|||||||
return getUserCreation(emailContact.userId, clientTimezoneOffset)
|
return getUserCreation(emailContact.userId, clientTimezoneOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Authorized([RIGHTS.ADMIN_CREATE_CONTRIBUTIONS])
|
|
||||||
@Mutation(() => AdminCreateContributions)
|
|
||||||
async adminCreateContributions(
|
|
||||||
@Arg('pendingCreations', () => [AdminCreateContributionArgs])
|
|
||||||
contributions: AdminCreateContributionArgs[],
|
|
||||||
@Ctx() context: Context,
|
|
||||||
): Promise<AdminCreateContributions> {
|
|
||||||
let success = false
|
|
||||||
const successfulContribution: string[] = []
|
|
||||||
const failedContribution: string[] = []
|
|
||||||
for (const contribution of contributions) {
|
|
||||||
await this.adminCreateContribution(contribution, context)
|
|
||||||
.then(() => {
|
|
||||||
successfulContribution.push(contribution.email)
|
|
||||||
success = true
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
failedContribution.push(contribution.email)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
success,
|
|
||||||
successfulContribution,
|
|
||||||
failedContribution,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Authorized([RIGHTS.ADMIN_UPDATE_CONTRIBUTION])
|
@Authorized([RIGHTS.ADMIN_UPDATE_CONTRIBUTION])
|
||||||
@Mutation(() => AdminUpdateContribution)
|
@Mutation(() => AdminUpdateContribution)
|
||||||
async adminUpdateContribution(
|
async adminUpdateContribution(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user