mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #2776 from gradido/rename-evenProtocolType-to-eventType
refactor(backend): rename `evenProtocolType` to `eventType`
This commit is contained in:
commit
eefe8f1d65
@ -4,10 +4,10 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi
|
||||
import { Contribution as DbContribution } from '@entity/Contribution'
|
||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||
import Decimal from 'decimal.js-light'
|
||||
import { EventProtocolType } from './EventProtocolType'
|
||||
import { EventType } from './EventType'
|
||||
|
||||
export const Event = (
|
||||
type: EventProtocolType,
|
||||
type: EventType,
|
||||
affectedUser: DbUser,
|
||||
actingUser: DbUser,
|
||||
involvedUser: DbUser | null = null,
|
||||
@ -33,48 +33,21 @@ export const EVENT_CONTRIBUTION_CREATE = async (
|
||||
contribution: DbContribution,
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.CONTRIBUTION_CREATE,
|
||||
user,
|
||||
user,
|
||||
null,
|
||||
null,
|
||||
contribution,
|
||||
null,
|
||||
amount,
|
||||
).save()
|
||||
Event(EventType.CONTRIBUTION_CREATE, user, user, null, null, contribution, null, amount).save()
|
||||
|
||||
export const EVENT_CONTRIBUTION_DELETE = async (
|
||||
user: DbUser,
|
||||
contribution: DbContribution,
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.CONTRIBUTION_DELETE,
|
||||
user,
|
||||
user,
|
||||
null,
|
||||
null,
|
||||
contribution,
|
||||
null,
|
||||
amount,
|
||||
).save()
|
||||
Event(EventType.CONTRIBUTION_DELETE, user, user, null, null, contribution, null, amount).save()
|
||||
|
||||
export const EVENT_CONTRIBUTION_UPDATE = async (
|
||||
user: DbUser,
|
||||
contribution: DbContribution,
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.CONTRIBUTION_UPDATE,
|
||||
user,
|
||||
user,
|
||||
null,
|
||||
null,
|
||||
contribution,
|
||||
null,
|
||||
amount,
|
||||
).save()
|
||||
Event(EventType.CONTRIBUTION_UPDATE, user, user, null, null, contribution, null, amount).save()
|
||||
|
||||
export const EVENT_ADMIN_CONTRIBUTION_CREATE = async (
|
||||
user: DbUser,
|
||||
@ -83,7 +56,7 @@ export const EVENT_ADMIN_CONTRIBUTION_CREATE = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.ADMIN_CONTRIBUTION_CREATE,
|
||||
EventType.ADMIN_CONTRIBUTION_CREATE,
|
||||
user,
|
||||
moderator,
|
||||
null,
|
||||
@ -100,7 +73,7 @@ export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
EventType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
user,
|
||||
moderator,
|
||||
null,
|
||||
@ -117,7 +90,7 @@ export const EVENT_ADMIN_CONTRIBUTION_DELETE = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.ADMIN_CONTRIBUTION_DELETE,
|
||||
EventType.ADMIN_CONTRIBUTION_DELETE,
|
||||
user,
|
||||
moderator,
|
||||
null,
|
||||
@ -134,7 +107,7 @@ export const EVENT_CONTRIBUTION_CONFIRM = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.CONTRIBUTION_CONFIRM,
|
||||
EventType.CONTRIBUTION_CONFIRM,
|
||||
user,
|
||||
moderator,
|
||||
null,
|
||||
@ -151,7 +124,7 @@ export const EVENT_ADMIN_CONTRIBUTION_DENY = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.ADMIN_CONTRIBUTION_DENY,
|
||||
EventType.ADMIN_CONTRIBUTION_DENY,
|
||||
user,
|
||||
moderator,
|
||||
null,
|
||||
@ -168,7 +141,7 @@ export const EVENT_TRANSACTION_SEND = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.TRANSACTION_SEND,
|
||||
EventType.TRANSACTION_SEND,
|
||||
user,
|
||||
user,
|
||||
involvedUser,
|
||||
@ -185,7 +158,7 @@ export const EVENT_TRANSACTION_RECEIVE = async (
|
||||
amount: Decimal,
|
||||
): Promise<DbEvent> =>
|
||||
Event(
|
||||
EventProtocolType.TRANSACTION_RECEIVE,
|
||||
EventType.TRANSACTION_RECEIVE,
|
||||
user,
|
||||
involvedUser,
|
||||
involvedUser,
|
||||
@ -196,22 +169,21 @@ export const EVENT_TRANSACTION_RECEIVE = async (
|
||||
).save()
|
||||
|
||||
export const EVENT_LOGIN = async (user: DbUser): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.LOGIN, user, user).save()
|
||||
Event(EventType.LOGIN, user, user).save()
|
||||
|
||||
export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save()
|
||||
Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save()
|
||||
|
||||
export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.SEND_CONFIRMATION_EMAIL, user, user).save()
|
||||
Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save()
|
||||
|
||||
export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async (
|
||||
user: DbUser,
|
||||
moderator: DbUser,
|
||||
): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save()
|
||||
): Promise<DbEvent> => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save()
|
||||
|
||||
export const EVENT_REGISTER = async (user: DbUser): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.REGISTER, user, user).save()
|
||||
Event(EventType.REGISTER, user, user).save()
|
||||
|
||||
export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> =>
|
||||
Event(EventProtocolType.ACTIVATE_ACCOUNT, user, user).save()
|
||||
Event(EventType.ACTIVATE_ACCOUNT, user, user).save()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
export enum EventProtocolType {
|
||||
export enum EventType {
|
||||
// VISIT_GRADIDO = 'VISIT_GRADIDO',
|
||||
REGISTER = 'REGISTER',
|
||||
REDEEM_REGISTER = 'REDEEM_REGISTER',
|
||||
@ -50,7 +50,7 @@ import { Event as DbEvent } from '@entity/Event'
|
||||
import { Contribution } from '@entity/Contribution'
|
||||
import { Transaction as DbTransaction } from '@entity/Transaction'
|
||||
import { User } from '@entity/User'
|
||||
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||
import { EventType } from '@/event/EventType'
|
||||
import { logger, i18n as localization } from '@test/testSetup'
|
||||
import { UserInputError } from 'apollo-server-express'
|
||||
import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz'
|
||||
@ -281,7 +281,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the CONTRIBUTION_CREATE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.CONTRIBUTION_CREATE,
|
||||
type: EventType.CONTRIBUTION_CREATE,
|
||||
affectedUserId: bibi.id,
|
||||
actingUserId: bibi.id,
|
||||
involvedContributionId: pendingContribution.data.createContribution.id,
|
||||
@ -587,7 +587,7 @@ describe('ContributionResolver', () => {
|
||||
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.CONTRIBUTION_UPDATE,
|
||||
type: EventType.CONTRIBUTION_UPDATE,
|
||||
affectedUserId: bibi.id,
|
||||
actingUserId: bibi.id,
|
||||
involvedContributionId: pendingContribution.data.createContribution.id,
|
||||
@ -818,7 +818,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the ADMIN_CONTRIBUTION_DENY event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_CONTRIBUTION_DENY,
|
||||
type: EventType.ADMIN_CONTRIBUTION_DENY,
|
||||
affectedUserId: bibi.id,
|
||||
actingUserId: admin.id,
|
||||
involvedContributionId: contributionToDeny.data.createContribution.id,
|
||||
@ -946,7 +946,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the CONTRIBUTION_DELETE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.CONTRIBUTION_DELETE,
|
||||
type: EventType.CONTRIBUTION_DELETE,
|
||||
affectedUserId: bibi.id,
|
||||
actingUserId: bibi.id,
|
||||
involvedContributionId: contributionToDelete.data.createContribution.id,
|
||||
@ -2036,7 +2036,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the ADMIN_CONTRIBUTION_CREATE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_CONTRIBUTION_CREATE,
|
||||
type: EventType.ADMIN_CONTRIBUTION_CREATE,
|
||||
affectedUserId: bibi.id,
|
||||
actingUserId: admin.id,
|
||||
amount: expect.decimalEqual(200),
|
||||
@ -2262,7 +2262,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the ADMIN_CONTRIBUTION_UPDATE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
type: EventType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
affectedUserId: creation?.userId,
|
||||
actingUserId: admin.id,
|
||||
amount: 300,
|
||||
@ -2304,7 +2304,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the ADMIN_CONTRIBUTION_UPDATE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
type: EventType.ADMIN_CONTRIBUTION_UPDATE,
|
||||
affectedUserId: creation?.userId,
|
||||
actingUserId: admin.id,
|
||||
amount: expect.decimalEqual(200),
|
||||
@ -2390,7 +2390,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the ADMIN_CONTRIBUTION_DELETE event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_CONTRIBUTION_DELETE,
|
||||
type: EventType.ADMIN_CONTRIBUTION_DELETE,
|
||||
affectedUserId: creation?.userId,
|
||||
actingUserId: admin.id,
|
||||
involvedContributionId: creation?.id,
|
||||
@ -2548,7 +2548,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the CONTRIBUTION_CONFIRM event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.CONTRIBUTION_CONFIRM,
|
||||
type: EventType.CONTRIBUTION_CONFIRM,
|
||||
}),
|
||||
)
|
||||
})
|
||||
@ -2580,7 +2580,7 @@ describe('ContributionResolver', () => {
|
||||
it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.SEND_CONFIRMATION_EMAIL,
|
||||
type: EventType.SEND_CONFIRMATION_EMAIL,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import Decimal from 'decimal.js-light'
|
||||
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||
import { EventType } from '@/event/EventType'
|
||||
import { userFactory } from '@/seeds/factory/user'
|
||||
import {
|
||||
confirmContribution,
|
||||
@ -343,7 +343,7 @@ describe('send coins', () => {
|
||||
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.TRANSACTION_SEND,
|
||||
type: EventType.TRANSACTION_SEND,
|
||||
affectedUserId: user[1].id,
|
||||
actingUserId: user[1].id,
|
||||
involvedUserId: user[0].id,
|
||||
@ -361,7 +361,7 @@ describe('send coins', () => {
|
||||
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.TRANSACTION_RECEIVE,
|
||||
type: EventType.TRANSACTION_RECEIVE,
|
||||
affectedUserId: user[0].id,
|
||||
actingUserId: user[1].id,
|
||||
involvedUserId: user[1].id,
|
||||
|
||||
@ -39,7 +39,7 @@ import { contributionLinkFactory } from '@/seeds/factory/contributionLink'
|
||||
import { transactionLinkFactory } from '@/seeds/factory/transactionLink'
|
||||
import { ContributionLink } from '@model/ContributionLink'
|
||||
import { TransactionLink } from '@entity/TransactionLink'
|
||||
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||
import { EventType } from '@/event/EventType'
|
||||
import { Event as DbEvent } from '@entity/Event'
|
||||
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
@ -189,7 +189,7 @@ describe('UserResolver', () => {
|
||||
)
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.REGISTER,
|
||||
type: EventType.REGISTER,
|
||||
affectedUserId: userConatct.user.id,
|
||||
actingUserId: userConatct.user.id,
|
||||
}),
|
||||
@ -219,7 +219,7 @@ describe('UserResolver', () => {
|
||||
it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.SEND_CONFIRMATION_EMAIL,
|
||||
type: EventType.SEND_CONFIRMATION_EMAIL,
|
||||
affectedUserId: user[0].id,
|
||||
actingUserId: user[0].id,
|
||||
}),
|
||||
@ -265,7 +265,7 @@ describe('UserResolver', () => {
|
||||
)
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL,
|
||||
type: EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL,
|
||||
affectedUserId: userConatct.user.id,
|
||||
actingUserId: 0,
|
||||
}),
|
||||
@ -366,7 +366,7 @@ describe('UserResolver', () => {
|
||||
it('stores the ACTIVATE_ACCOUNT event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ACTIVATE_ACCOUNT,
|
||||
type: EventType.ACTIVATE_ACCOUNT,
|
||||
affectedUserId: user[0].id,
|
||||
actingUserId: user[0].id,
|
||||
}),
|
||||
@ -376,7 +376,7 @@ describe('UserResolver', () => {
|
||||
it('stores the REDEEM_REGISTER event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.REDEEM_REGISTER,
|
||||
type: EventType.REDEEM_REGISTER,
|
||||
affectedUserId: result.data.createUser.id,
|
||||
actingUserId: result.data.createUser.id,
|
||||
involvedContributionId: link.id,
|
||||
@ -461,7 +461,7 @@ describe('UserResolver', () => {
|
||||
it('stores the REDEEM_REGISTER event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.REDEEM_REGISTER,
|
||||
type: EventType.REDEEM_REGISTER,
|
||||
affectedUserId: newUser.data.createUser.id,
|
||||
actingUserId: newUser.data.createUser.id,
|
||||
involvedTransactionId: transactionLink.id,
|
||||
@ -694,7 +694,7 @@ describe('UserResolver', () => {
|
||||
)
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.LOGIN,
|
||||
type: EventType.LOGIN,
|
||||
affectedUserId: userConatct.user.id,
|
||||
actingUserId: userConatct.user.id,
|
||||
}),
|
||||
@ -943,7 +943,7 @@ describe('UserResolver', () => {
|
||||
it('stores the LOGIN event in the database', async () => {
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.LOGIN,
|
||||
type: EventType.LOGIN,
|
||||
affectedUserId: user[0].id,
|
||||
actingUserId: user[0].id,
|
||||
}),
|
||||
@ -1863,7 +1863,7 @@ describe('UserResolver', () => {
|
||||
)
|
||||
await expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventProtocolType.ADMIN_SEND_CONFIRMATION_EMAIL,
|
||||
type: EventType.ADMIN_SEND_CONFIRMATION_EMAIL,
|
||||
affectedUserId: userConatct.user.id,
|
||||
actingUserId: admin.id,
|
||||
}),
|
||||
|
||||
@ -69,7 +69,7 @@ import { FULL_CREATION_AVAILABLE } from './const/const'
|
||||
import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor'
|
||||
import { PasswordEncryptionType } from '../enum/PasswordEncryptionType'
|
||||
import LogError from '@/server/LogError'
|
||||
import { EventProtocolType } from '@/event/EventProtocolType'
|
||||
import { EventType } from '@/event/EventType'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const sodium = require('sodium-native')
|
||||
@ -273,7 +273,7 @@ export class UserResolver {
|
||||
const gradidoID = await newGradidoID()
|
||||
|
||||
const eventRegisterRedeem = Event(
|
||||
EventProtocolType.REDEEM_REGISTER,
|
||||
EventType.REDEEM_REGISTER,
|
||||
{ id: 0 } as DbUser,
|
||||
{ id: 0 } as DbUser,
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user