mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #1215 from gradido/remove_self_creation_confirmation
Remove confirmation of own pending creation
This commit is contained in:
commit
0972be04d8
@ -1,4 +1,4 @@
|
|||||||
import { Resolver, Query, Arg, Args, Authorized, Mutation } from 'type-graphql'
|
import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx } from 'type-graphql'
|
||||||
import { getCustomRepository, Raw } from 'typeorm'
|
import { getCustomRepository, Raw } from 'typeorm'
|
||||||
import { UserAdmin } from '../model/UserAdmin'
|
import { UserAdmin } from '../model/UserAdmin'
|
||||||
import { PendingCreation } from '../model/PendingCreation'
|
import { PendingCreation } from '../model/PendingCreation'
|
||||||
@ -66,7 +66,7 @@ export class AdminResolver {
|
|||||||
return await getUserCreations(user.id)
|
return await getUserCreations(user.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Authorized([RIGHTS.SEARCH_USERS])
|
@Authorized([RIGHTS.SEARCH_USERS])
|
||||||
@Mutation(() => UpdatePendingCreation)
|
@Mutation(() => UpdatePendingCreation)
|
||||||
async updatePendingCreation(
|
async updatePendingCreation(
|
||||||
@Args() { id, email, amount, memo, creationDate, moderator }: UpdatePendingCreationArgs,
|
@Args() { id, email, amount, memo, creationDate, moderator }: UpdatePendingCreationArgs,
|
||||||
@ -94,24 +94,9 @@ export class AdminResolver {
|
|||||||
result.creation = await getUserCreations(user.id)
|
result.creation = await getUserCreations(user.id)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
// const creations = await getUserCreations(user.id)
|
|
||||||
// const creationDateObj = new Date(creationDate)
|
|
||||||
// if (isCreationValid(creations, amount, creationDateObj)) {
|
|
||||||
// const pendingCreationRepository = getCustomRepository(PendingCreationRepository)
|
|
||||||
// const loginPendingTaskAdmin = pendingCreationRepository.create()
|
|
||||||
// loginPendingTaskAdmin.userId = user.id
|
|
||||||
// loginPendingTaskAdmin.amount = BigInt(amount * 10000)
|
|
||||||
// loginPendingTaskAdmin.created = new Date()
|
|
||||||
// loginPendingTaskAdmin.date = creationDateObj
|
|
||||||
// loginPendingTaskAdmin.memo = memo
|
|
||||||
// loginPendingTaskAdmin.moderator = moderator
|
|
||||||
//
|
|
||||||
// pendingCreationRepository.save(loginPendingTaskAdmin)
|
|
||||||
// }
|
|
||||||
// return await getUserCreations(user.id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized([RIGHTS.SEARCH_USERS])
|
||||||
@Query(() => [PendingCreation])
|
@Query(() => [PendingCreation])
|
||||||
async getPendingCreations(): Promise<PendingCreation[]> {
|
async getPendingCreations(): Promise<PendingCreation[]> {
|
||||||
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
||||||
@ -139,6 +124,7 @@ export class AdminResolver {
|
|||||||
return pendingCreationsPromise.reverse()
|
return pendingCreationsPromise.reverse()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized([RIGHTS.SEARCH_USERS])
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
async deletePendingCreation(@Arg('id') id: number): Promise<boolean> {
|
async deletePendingCreation(@Arg('id') id: number): Promise<boolean> {
|
||||||
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
||||||
@ -147,11 +133,17 @@ export class AdminResolver {
|
|||||||
return !!res
|
return !!res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Authorized([RIGHTS.SEARCH_USERS])
|
||||||
@Mutation(() => Boolean)
|
@Mutation(() => Boolean)
|
||||||
async confirmPendingCreation(@Arg('id') id: number): Promise<boolean> {
|
async confirmPendingCreation(@Arg('id') id: number, @Ctx() context: any): Promise<boolean> {
|
||||||
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
const loginPendingTasksAdminRepository = getCustomRepository(LoginPendingTasksAdminRepository)
|
||||||
const pendingCreation = await loginPendingTasksAdminRepository.findOneOrFail(id)
|
const pendingCreation = await loginPendingTasksAdminRepository.findOneOrFail(id)
|
||||||
|
|
||||||
|
const userRepository = getCustomRepository(UserRepository)
|
||||||
|
const moderatorUser = await userRepository.findByPubkeyHex(context.pubKey)
|
||||||
|
if (moderatorUser.id === pendingCreation.userId)
|
||||||
|
throw new Error('Moderator can not confirm own pending creation')
|
||||||
|
|
||||||
const transactionRepository = getCustomRepository(TransactionRepository)
|
const transactionRepository = getCustomRepository(TransactionRepository)
|
||||||
const receivedCallDate = new Date()
|
const receivedCallDate = new Date()
|
||||||
let transaction = new Transaction()
|
let transaction = new Transaction()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user