mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
Extern trigger for setting fields to subscriber
This commit is contained in:
parent
05e0ab1f7b
commit
f486bc0fd0
@ -1,8 +1,12 @@
|
||||
// eslint-disable @typescript-eslint/no-explicit-any
|
||||
import { User } from '@entity/User'
|
||||
|
||||
import { getKlickTippUser } from '@/apis/KlicktippController'
|
||||
import { getKlickTippUser, addFieldsToSubscriber } from '@/apis/KlicktippController'
|
||||
import LogError from '@/server/LogError'
|
||||
import connection from '@/typeorm/connection'
|
||||
import { lastDateTimeEvents } from '@/graphql/resolver/util/eventList'
|
||||
import { EventType } from '@/event/EventType'
|
||||
import { Event as DbEvent } from '@/event/Event'
|
||||
|
||||
export async function retrieveNotRegisteredEmails(): Promise<string[]> {
|
||||
const con = await connection()
|
||||
@ -27,4 +31,35 @@ export async function retrieveNotRegisteredEmails(): Promise<string[]> {
|
||||
return notRegisteredUser
|
||||
}
|
||||
|
||||
void retrieveNotRegisteredEmails()
|
||||
function klickTippSendFieldToUser(events: any, value: string): void {
|
||||
for(const event of events) {
|
||||
addFieldsToSubscriber(event.email, { [value]: event.value })
|
||||
}
|
||||
}
|
||||
|
||||
export async function exportEventDataToKlickTipp(): Promise<void> {
|
||||
const connectionInstance = await connection()
|
||||
if (!connectionInstance) {
|
||||
throw new LogError('No connection to database')
|
||||
}
|
||||
|
||||
const lastLoginEvents = await lastDateTimeEvents(EventType.USER_LOGIN)
|
||||
klickTippSendFieldToUser(lastLoginEvents, 'GDD last login')
|
||||
|
||||
const registeredEvents = await lastDateTimeEvents(EventType.USER_ACTIVATE_ACCOUNT)
|
||||
klickTippSendFieldToUser(registeredEvents, 'GDD date of registration')
|
||||
|
||||
const receiveTransactionEvents = await lastDateTimeEvents(EventType.TRANSACTION_RECEIVE)
|
||||
klickTippSendFieldToUser(receiveTransactionEvents, 'GDD last received')
|
||||
|
||||
const contributionCreateEvents = await lastDateTimeEvents(EventType.TRANSACTION_SEND)
|
||||
klickTippSendFieldToUser(contributionCreateEvents, 'GDD last sent')
|
||||
|
||||
const linkRedeemedEvents = await lastDateTimeEvents(EventType.TRANSACTION_LINK_REDEEM)
|
||||
klickTippSendFieldToUser(linkRedeemedEvents, 'GDD last invited')
|
||||
|
||||
const confirmContributionEvents = await lastDateTimeEvents(EventType.ADMIN_CONTRIBUTION_CONFIRM)
|
||||
klickTippSendFieldToUser(confirmContributionEvents, 'GDD last created')
|
||||
}
|
||||
void exportEventDataToKlickTipp()
|
||||
// void retrieveNotRegisteredEmails()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user