mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
emit Redeem-Events
This commit is contained in:
parent
e4fc2cce6d
commit
a99a568f39
57
backend/src/graphql/model/Event.ts
Normal file
57
backend/src/graphql/model/Event.ts
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { ObjectType, Field } from 'type-graphql'
|
||||||
|
import { EventProtocol } from '@entity/EventProtocol'
|
||||||
|
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||||
|
import Decimal from 'decimal.js-light'
|
||||||
|
|
||||||
|
export interface EventInterface {
|
||||||
|
type: string
|
||||||
|
createdAt: Date
|
||||||
|
userId: number
|
||||||
|
xUserId?: number
|
||||||
|
xCommunityId?: number
|
||||||
|
transactionId?: number
|
||||||
|
contributionId?: number
|
||||||
|
amount?: Decimal
|
||||||
|
}
|
||||||
|
|
||||||
|
@ObjectType()
|
||||||
|
export class Event {
|
||||||
|
constructor(event: EventProtocol) {
|
||||||
|
this.id = event.id
|
||||||
|
this.type = event.type
|
||||||
|
this.createdAt = event.createdAt
|
||||||
|
this.userId = event.userId
|
||||||
|
this.xUserId = event.xUserId
|
||||||
|
this.xCommunityId = event.xCommunityId
|
||||||
|
this.transactionId = event.transactionId
|
||||||
|
this.contributionId = event.contributionId
|
||||||
|
this.amount = event.amount
|
||||||
|
}
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Field(() => EventProtocolType)
|
||||||
|
type: string
|
||||||
|
|
||||||
|
@Field(() => Date)
|
||||||
|
createdAt: Date
|
||||||
|
|
||||||
|
@Field(() => Number)
|
||||||
|
userId: number
|
||||||
|
|
||||||
|
@Field(() => Number, { nullable: true })
|
||||||
|
xUserId: number | null
|
||||||
|
|
||||||
|
@Field(() => Number, { nullable: true })
|
||||||
|
xCommunityId: number | null
|
||||||
|
|
||||||
|
@Field(() => Number, { nullable: true })
|
||||||
|
transactionId: number | null
|
||||||
|
|
||||||
|
@Field(() => Number, { nullable: true })
|
||||||
|
contributionId: number | null
|
||||||
|
|
||||||
|
@Field(() => Decimal)
|
||||||
|
amount: Decimal | null
|
||||||
|
}
|
||||||
@ -23,7 +23,7 @@ import { sendAccountMultiRegistrationEmail } from '@/mailer/sendAccountMultiRegi
|
|||||||
import { klicktippSignIn } from '@/apis/KlicktippController'
|
import { klicktippSignIn } from '@/apis/KlicktippController'
|
||||||
import { RIGHTS } from '@/auth/RIGHTS'
|
import { RIGHTS } from '@/auth/RIGHTS'
|
||||||
import { hasElopageBuys } from '@/util/hasElopageBuys'
|
import { hasElopageBuys } from '@/util/hasElopageBuys'
|
||||||
import { eventProtocol } from '@/event/EventProtocolEmitter'
|
import { EventInterface, eventProtocol } from '@/event/EventProtocolEmitter'
|
||||||
import { EventProtocolType } from '@/event/EventProtocolType'
|
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
@ -374,6 +374,9 @@ export class UserResolver {
|
|||||||
// const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
// const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
||||||
const emailHash = getEmailHash(email)
|
const emailHash = getEmailHash(email)
|
||||||
|
|
||||||
|
let eventType = EventProtocolType.REGISTER
|
||||||
|
let eventContributionId = null
|
||||||
|
let eventTransactionId = null
|
||||||
const dbUser = new DbUser()
|
const dbUser = new DbUser()
|
||||||
dbUser.email = email
|
dbUser.email = email
|
||||||
dbUser.firstName = firstName
|
dbUser.firstName = firstName
|
||||||
@ -391,6 +394,8 @@ export class UserResolver {
|
|||||||
logger.info('redeemCode found contributionLink=' + contributionLink)
|
logger.info('redeemCode found contributionLink=' + contributionLink)
|
||||||
if (contributionLink) {
|
if (contributionLink) {
|
||||||
dbUser.contributionLinkId = contributionLink.id
|
dbUser.contributionLinkId = contributionLink.id
|
||||||
|
eventType = EventProtocolType.REDEEM_REGISTER
|
||||||
|
eventContributionId = contributionLink.id
|
||||||
/* eventProtocol.emit(
|
/* eventProtocol.emit(
|
||||||
EventProtocolType.REDEEM_REGISTER,
|
EventProtocolType.REDEEM_REGISTER,
|
||||||
new Date(Date.now()),
|
new Date(Date.now()),
|
||||||
@ -404,6 +409,8 @@ export class UserResolver {
|
|||||||
logger.info('redeemCode found transactionLink=' + transactionLink)
|
logger.info('redeemCode found transactionLink=' + transactionLink)
|
||||||
if (transactionLink) {
|
if (transactionLink) {
|
||||||
dbUser.referrerId = transactionLink.userId
|
dbUser.referrerId = transactionLink.userId
|
||||||
|
eventType = EventProtocolType.REDEEM_REGISTER
|
||||||
|
eventTransactionId = transactionLink.id
|
||||||
/* eventProtocol.emit(
|
/* eventProtocol.emit(
|
||||||
EventProtocolType.REDEEM_REGISTER,
|
EventProtocolType.REDEEM_REGISTER,
|
||||||
new Date(Date.now()),
|
new Date(Date.now()),
|
||||||
@ -467,9 +474,13 @@ export class UserResolver {
|
|||||||
logger.info('createUser() successful...')
|
logger.info('createUser() successful...')
|
||||||
|
|
||||||
eventProtocol.emit('writeEvent', {
|
eventProtocol.emit('writeEvent', {
|
||||||
type: EventProtocolType.REGISTER,
|
type: eventType,
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
userId: dbUser.id,
|
userId: dbUser.id,
|
||||||
|
xUserId: null,
|
||||||
|
xCommunityId: null,
|
||||||
|
transactionId: eventTransactionId,
|
||||||
|
contributionId: eventContributionId,
|
||||||
})
|
})
|
||||||
|
|
||||||
return new User(dbUser)
|
return new User(dbUser)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user