mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into admin-email-confirmation
This commit is contained in:
commit
70fd858cf8
@ -4,7 +4,7 @@ import dotenv from 'dotenv'
|
||||
dotenv.config()
|
||||
|
||||
const constants = {
|
||||
DB_VERSION: '0020-rename_and_clean_state_users',
|
||||
DB_VERSION: '0021-elopagebuys_fields_nullable',
|
||||
}
|
||||
|
||||
const server = {
|
||||
|
||||
@ -53,12 +53,13 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
||||
membership,
|
||||
} = req.body
|
||||
|
||||
loginElopageBuy.affiliateProgramId = parseInt(product.affiliate_program_id)
|
||||
loginElopageBuy.publisherId = parseInt(publisher.id)
|
||||
loginElopageBuy.orderId = parseInt(order_id)
|
||||
loginElopageBuy.productId = parseInt(product_id)
|
||||
loginElopageBuy.affiliateProgramId = parseInt(product.affiliate_program_id) || null
|
||||
loginElopageBuy.publisherId = parseInt(publisher.id) || null
|
||||
loginElopageBuy.orderId = parseInt(order_id) || null
|
||||
loginElopageBuy.productId = parseInt(product_id) || null
|
||||
// TODO: WHAT THE ACTUAL FUK? Please save this as float in the future directly in the database
|
||||
loginElopageBuy.productPrice = Math.trunc(parseFloat(product.price) * 100)
|
||||
const productPrice = parseFloat(product.price)
|
||||
loginElopageBuy.productPrice = productPrice ? Math.trunc(productPrice * 100) : 0
|
||||
loginElopageBuy.payerEmail = payer.email
|
||||
loginElopageBuy.publisherEmail = publisher.email
|
||||
// eslint-disable-next-line camelcase
|
||||
@ -66,7 +67,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
||||
loginElopageBuy.successDate = new Date(success_date)
|
||||
loginElopageBuy.event = event
|
||||
// TODO this was never set on login_server - its unclear if this is the correct value
|
||||
loginElopageBuy.elopageUserId = parseInt(membership.id)
|
||||
loginElopageBuy.elopageUserId = parseInt(membership.id) || null
|
||||
|
||||
const firstName = payer.first_name
|
||||
const lastName = payer.last_name
|
||||
@ -79,7 +80,13 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
||||
}
|
||||
|
||||
// Save the hook data
|
||||
await LoginElopageBuys.save(loginElopageBuy)
|
||||
try {
|
||||
await LoginElopageBuys.save(loginElopageBuy)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Error saving LoginElopageBuy', error)
|
||||
return
|
||||
}
|
||||
|
||||
// create user for certain products
|
||||
/*
|
||||
@ -90,7 +97,10 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
||||
Business-Mitgliedschaft, 43960
|
||||
Förderbeitrag: 49106
|
||||
*/
|
||||
if ([36001, 43741, 43870, 43944, 43960, 49106].includes(loginElopageBuy.productId)) {
|
||||
if (
|
||||
loginElopageBuy.productId &&
|
||||
[36001, 43741, 43870, 43944, 43960, 49106].includes(loginElopageBuy.productId)
|
||||
) {
|
||||
const email = loginElopageBuy.payerEmail
|
||||
|
||||
const VALIDATE_EMAIL = /^[a-zA-Z0-9.!#$%&?*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/
|
||||
@ -123,7 +133,7 @@ export const elopageWebhook = async (req: any, res: any): Promise<void> => {
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
publisherId: loginElopageBuy.publisherId,
|
||||
publisherId: loginElopageBuy.publisherId || 0, // This seemed to be the default value if not set
|
||||
})
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
|
||||
@ -5,8 +5,8 @@ export class LoginElopageBuys extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@Column({ name: 'elopage_user_id', nullable: false })
|
||||
elopageUserId: number
|
||||
@Column({ type: 'int', width: 11, name: 'elopage_user_id', nullable: true, default: null })
|
||||
elopageUserId: number | null
|
||||
|
||||
@Column({ name: 'affiliate_program_id', nullable: false })
|
||||
affiliateProgramId: number
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
|
||||
@Entity('login_elopage_buys')
|
||||
export class LoginElopageBuys extends BaseEntity {
|
||||
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||
id: number
|
||||
|
||||
@Column({ type: 'int', width: 11, name: 'elopage_user_id', nullable: true, default: null })
|
||||
elopageUserId: number | null
|
||||
|
||||
@Column({ type: 'int', width: 11, name: 'affiliate_program_id', nullable: true, default: null })
|
||||
affiliateProgramId: number | null
|
||||
|
||||
@Column({ type: 'int', width: 11, name: 'publisher_id', nullable: true, default: null })
|
||||
publisherId: number | null
|
||||
|
||||
@Column({ type: 'int', width: 11, name: 'order_id', nullable: true, default: null })
|
||||
orderId: number | null
|
||||
|
||||
@Column({ type: 'int', width: 11, name: 'product_id', nullable: true, default: null })
|
||||
productId: number | null
|
||||
|
||||
@Column({ name: 'product_price', nullable: false })
|
||||
productPrice: number
|
||||
|
||||
@Column({
|
||||
name: 'payer_email',
|
||||
length: 255,
|
||||
nullable: false,
|
||||
charset: 'utf8',
|
||||
collation: 'utf8_bin',
|
||||
})
|
||||
payerEmail: string
|
||||
|
||||
@Column({
|
||||
name: 'publisher_email',
|
||||
length: 255,
|
||||
nullable: false,
|
||||
charset: 'utf8',
|
||||
collation: 'utf8_bin',
|
||||
})
|
||||
publisherEmail: string
|
||||
|
||||
@Column({ nullable: false })
|
||||
payed: boolean
|
||||
|
||||
@Column({ name: 'success_date', nullable: false })
|
||||
successDate: Date
|
||||
|
||||
@Column({ length: 255, nullable: false })
|
||||
event: string
|
||||
}
|
||||
@ -1 +1 @@
|
||||
export { LoginElopageBuys } from './0003-login_server_tables/LoginElopageBuys'
|
||||
export { LoginElopageBuys } from './0021-elopagebuys_fields_nullable/LoginElopageBuys'
|
||||
|
||||
25
database/migrations/0021-elopagebuys_fields_nullable.ts
Normal file
25
database/migrations/0021-elopagebuys_fields_nullable.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/* MIGRATION TO ALLOW NULL FIELDS ON ELOPAGEBUYS
|
||||
*
|
||||
* This migration allows null on `affiliate_program_id`,
|
||||
* `publisher_id`, `order_id`. `product_id`.
|
||||
*/
|
||||
|
||||
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(
|
||||
'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `affiliate_program_id` int(11) DEFAULT NULL;',
|
||||
)
|
||||
await queryFn(
|
||||
'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `publisher_id` int(11) DEFAULT NULL;',
|
||||
)
|
||||
await queryFn('ALTER TABLE `login_elopage_buys` MODIFY COLUMN `order_id` int(11) DEFAULT NULL;')
|
||||
await queryFn('ALTER TABLE `login_elopage_buys` MODIFY COLUMN `product_id` int(11) DEFAULT NULL;')
|
||||
}
|
||||
|
||||
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||
await queryFn(
|
||||
'ALTER TABLE `login_elopage_buys` MODIFY COLUMN `affiliate_program_id` int(11) NOT NULL;',
|
||||
)
|
||||
await queryFn('ALTER TABLE `login_elopage_buys` MODIFY COLUMN `publisher_id` int(11) NOT NULL;')
|
||||
await queryFn('ALTER TABLE `login_elopage_buys` MODIFY COLUMN `order_id` int(11) NOT NULL;')
|
||||
await queryFn('ALTER TABLE `login_elopage_buys` MODIFY COLUMN `product_id` int(11) NOT NULL;')
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user