diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index 961d83219..9aabaf4ad 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -10,7 +10,7 @@ Decimal.set({ }) const constants = { - DB_VERSION: '0061-event_refactoring', + DB_VERSION: '0062-event_contribution_confirm', DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info diff --git a/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts b/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts new file mode 100644 index 000000000..755cc8fe2 --- /dev/null +++ b/backend/src/event/EVENT_ACTIVATE_ACCOUNT.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => + Event(EventType.ACTIVATE_ACCOUNT, user, user).save() diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts new file mode 100644 index 000000000..140ba8497 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CONFIRM.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_CONFIRM, + user, + moderator, + null, + null, + contribution, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts new file mode 100644 index 000000000..c95ba5b9b --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_CREATE.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_CREATE, + user, + moderator, + null, + null, + contribution, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts new file mode 100644 index 000000000..30cfd8b93 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DELETE.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_DELETE, + user, + moderator, + null, + null, + contribution, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts new file mode 100644 index 000000000..d84467f4f --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_DENY.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_DENY, + user, + moderator, + null, + null, + contribution, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts new file mode 100644 index 000000000..3fc17f7d2 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_CONTRIBUTION_UPDATE.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( + user: DbUser, + moderator: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event( + EventType.ADMIN_CONTRIBUTION_UPDATE, + user, + moderator, + null, + null, + contribution, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts new file mode 100644 index 000000000..da4907930 --- /dev/null +++ b/backend/src/event/EVENT_ADMIN_SEND_CONFIRMATION_EMAIL.ts @@ -0,0 +1,8 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( + user: DbUser, + moderator: DbUser, +): Promise => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save() diff --git a/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts new file mode 100644 index 000000000..cbc514dc8 --- /dev/null +++ b/backend/src/event/EVENT_CONTRIBUTION_CREATE.ts @@ -0,0 +1,12 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_CONTRIBUTION_CREATE = async ( + user: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event(EventType.CONTRIBUTION_CREATE, user, user, null, null, contribution, null, amount).save() diff --git a/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts new file mode 100644 index 000000000..b15e57ea8 --- /dev/null +++ b/backend/src/event/EVENT_CONTRIBUTION_DELETE.ts @@ -0,0 +1,12 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_CONTRIBUTION_DELETE = async ( + user: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event(EventType.CONTRIBUTION_DELETE, user, user, null, null, contribution, null, amount).save() diff --git a/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts new file mode 100644 index 000000000..2fb56dc77 --- /dev/null +++ b/backend/src/event/EVENT_CONTRIBUTION_UPDATE.ts @@ -0,0 +1,12 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Contribution as DbContribution } from '@entity/Contribution' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_CONTRIBUTION_UPDATE = async ( + user: DbUser, + contribution: DbContribution, + amount: Decimal, +): Promise => + Event(EventType.CONTRIBUTION_UPDATE, user, user, null, null, contribution, null, amount).save() diff --git a/backend/src/event/EVENT_LOGIN.ts b/backend/src/event/EVENT_LOGIN.ts new file mode 100644 index 000000000..2c1e763ec --- /dev/null +++ b/backend/src/event/EVENT_LOGIN.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_LOGIN = async (user: DbUser): Promise => + Event(EventType.LOGIN, user, user).save() diff --git a/backend/src/event/EVENT_REGISTER.ts b/backend/src/event/EVENT_REGISTER.ts new file mode 100644 index 000000000..73c6bf4f9 --- /dev/null +++ b/backend/src/event/EVENT_REGISTER.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_REGISTER = async (user: DbUser): Promise => + Event(EventType.REGISTER, user, user).save() diff --git a/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts b/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts new file mode 100644 index 000000000..3110ece1f --- /dev/null +++ b/backend/src/event/EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise => + Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save() diff --git a/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts b/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts new file mode 100644 index 000000000..b387c0e60 --- /dev/null +++ b/backend/src/event/EVENT_SEND_CONFIRMATION_EMAIL.ts @@ -0,0 +1,6 @@ +import { User as DbUser } from '@entity/User' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise => + Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save() diff --git a/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts new file mode 100644 index 000000000..78f561148 --- /dev/null +++ b/backend/src/event/EVENT_TRANSACTION_RECEIVE.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_TRANSACTION_RECEIVE = async ( + user: DbUser, + involvedUser: DbUser, + transaction: DbTransaction, + amount: Decimal, +): Promise => + Event( + EventType.TRANSACTION_RECEIVE, + user, + involvedUser, + involvedUser, + transaction, + null, + null, + amount, + ).save() diff --git a/backend/src/event/EVENT_TRANSACTION_SEND.ts b/backend/src/event/EVENT_TRANSACTION_SEND.ts new file mode 100644 index 000000000..e281b0d30 --- /dev/null +++ b/backend/src/event/EVENT_TRANSACTION_SEND.ts @@ -0,0 +1,22 @@ +import Decimal from 'decimal.js-light' +import { User as DbUser } from '@entity/User' +import { Transaction as DbTransaction } from '@entity/Transaction' +import { Event as DbEvent } from '@entity/Event' +import { Event, EventType } from './Event' + +export const EVENT_TRANSACTION_SEND = async ( + user: DbUser, + involvedUser: DbUser, + transaction: DbTransaction, + amount: Decimal, +): Promise => + Event( + EventType.TRANSACTION_SEND, + user, + user, + involvedUser, + transaction, + null, + null, + amount, + ).save() diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 720cb2799..163b0b646 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -4,7 +4,7 @@ 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 { EventType } from './EventType' +import { EventType } from './Event' export const Event = ( type: EventType, @@ -28,162 +28,21 @@ export const Event = ( return event } -export const EVENT_CONTRIBUTION_CREATE = async ( - user: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event(EventType.CONTRIBUTION_CREATE, user, user, null, null, contribution, null, amount).save() +export { EventType } from './EventType' -export const EVENT_CONTRIBUTION_DELETE = async ( - user: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - 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 => - Event(EventType.CONTRIBUTION_UPDATE, user, user, null, null, contribution, null, amount).save() - -export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( - user: DbUser, - moderator: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event( - EventType.ADMIN_CONTRIBUTION_CREATE, - user, - moderator, - null, - null, - contribution, - null, - amount, - ).save() - -export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( - user: DbUser, - moderator: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event( - EventType.ADMIN_CONTRIBUTION_UPDATE, - user, - moderator, - null, - null, - contribution, - null, - amount, - ).save() - -export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( - user: DbUser, - moderator: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event( - EventType.ADMIN_CONTRIBUTION_DELETE, - user, - moderator, - null, - null, - contribution, - null, - amount, - ).save() - -export const EVENT_CONTRIBUTION_CONFIRM = async ( - user: DbUser, - moderator: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event( - EventType.CONTRIBUTION_CONFIRM, - user, - moderator, - null, - null, - contribution, - null, - amount, - ).save() - -export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( - user: DbUser, - moderator: DbUser, - contribution: DbContribution, - amount: Decimal, -): Promise => - Event( - EventType.ADMIN_CONTRIBUTION_DENY, - user, - moderator, - null, - null, - contribution, - null, - amount, - ).save() - -export const EVENT_TRANSACTION_SEND = async ( - user: DbUser, - involvedUser: DbUser, - transaction: DbTransaction, - amount: Decimal, -): Promise => - Event( - EventType.TRANSACTION_SEND, - user, - user, - involvedUser, - transaction, - null, - null, - amount, - ).save() - -export const EVENT_TRANSACTION_RECEIVE = async ( - user: DbUser, - involvedUser: DbUser, - transaction: DbTransaction, - amount: Decimal, -): Promise => - Event( - EventType.TRANSACTION_RECEIVE, - user, - involvedUser, - involvedUser, - transaction, - null, - null, - amount, - ).save() - -export const EVENT_LOGIN = async (user: DbUser): Promise => - Event(EventType.LOGIN, user, user).save() - -export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async (user: DbUser): Promise => - Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save() - -export const EVENT_SEND_CONFIRMATION_EMAIL = async (user: DbUser): Promise => - Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save() - -export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( - user: DbUser, - moderator: DbUser, -): Promise => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save() - -export const EVENT_REGISTER = async (user: DbUser): Promise => - Event(EventType.REGISTER, user, user).save() - -export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise => - Event(EventType.ACTIVATE_ACCOUNT, user, user).save() +export { EVENT_ACTIVATE_ACCOUNT } from './EVENT_ACTIVATE_ACCOUNT' +export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM' +export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE' +export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE' +export { EVENT_ADMIN_CONTRIBUTION_DENY } from './EVENT_ADMIN_CONTRIBUTION_DENY' +export { EVENT_ADMIN_CONTRIBUTION_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_UPDATE' +export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL' +export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE' +export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' +export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' +export { EVENT_LOGIN } from './EVENT_LOGIN' +export { EVENT_REGISTER } from './EVENT_REGISTER' +export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' +export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' +export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND' +export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' diff --git a/backend/src/event/EventType.ts b/backend/src/event/EventType.ts index 360d5efb4..241923ffd 100644 --- a/backend/src/event/EventType.ts +++ b/backend/src/event/EventType.ts @@ -1,42 +1,48 @@ +export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' +export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' +export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND' +export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' + export enum EventType { - // VISIT_GRADIDO = 'VISIT_GRADIDO', - REGISTER = 'REGISTER', - REDEEM_REGISTER = 'REDEEM_REGISTER', - // VERIFY_REDEEM = 'VERIFY_REDEEM', - // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', - SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL', - ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', - SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', - // CONFIRM_EMAIL = 'CONFIRM_EMAIL', - // REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', - LOGIN = 'LOGIN', - // LOGOUT = 'LOGOUT', - // REDEEM_LOGIN = 'REDEEM_LOGIN', ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT', - // SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', - // PASSWORD_CHANGE = 'PASSWORD_CHANGE', - // SEND_TRANSACTION_SEND_EMAIL = 'SEND_TRANSACTION_SEND_EMAIL', - // SEND_TRANSACTION_RECEIVE_EMAIL = 'SEND_TRANSACTION_RECEIVE_EMAIL', - TRANSACTION_SEND = 'TRANSACTION_SEND', - // TRANSACTION_SEND_REDEEM = 'TRANSACTION_SEND_REDEEM', - // TRANSACTION_REPEATE_REDEEM = 'TRANSACTION_REPEATE_REDEEM', - // TRANSACTION_CREATION = 'TRANSACTION_CREATION', - TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', - // TRANSACTION_RECEIVE_REDEEM = 'TRANSACTION_RECEIVE_REDEEM', - // SEND_TRANSACTION_LINK_REDEEM_EMAIL = 'SEND_TRANSACTION_LINK_REDEEM_EMAIL', - // SEND_ADDED_CONTRIBUTION_EMAIL = 'SEND_ADDED_CONTRIBUTION_EMAIL', - // SEND_CONTRIBUTION_CONFIRM_EMAIL = 'SEND_CONTRIBUTION_CONFIRM_EMAIL', - CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', - CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM', - // CONTRIBUTION_DENY = 'CONTRIBUTION_DENY', - // CONTRIBUTION_LINK_DEFINE = 'CONTRIBUTION_LINK_DEFINE', - // CONTRIBUTION_LINK_ACTIVATE_REDEEM = 'CONTRIBUTION_LINK_ACTIVATE_REDEEM', - CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', - CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', + // TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM', + ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM', ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE', ADMIN_CONTRIBUTION_DELETE = 'ADMIN_CONTRIBUTION_DELETE', ADMIN_CONTRIBUTION_DENY = 'ADMIN_CONTRIBUTION_DENY', ADMIN_CONTRIBUTION_UPDATE = 'ADMIN_CONTRIBUTION_UPDATE', + ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', + CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', + CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', + CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', + LOGIN = 'LOGIN', + REGISTER = 'REGISTER', + REDEEM_REGISTER = 'REDEEM_REGISTER', + SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', + SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL', + TRANSACTION_SEND = 'TRANSACTION_SEND', + TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', + // VISIT_GRADIDO = 'VISIT_GRADIDO', + // VERIFY_REDEEM = 'VERIFY_REDEEM', + // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', + // CONFIRM_EMAIL = 'CONFIRM_EMAIL', + // REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', + // LOGOUT = 'LOGOUT', + // REDEEM_LOGIN = 'REDEEM_LOGIN', + // SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', + // PASSWORD_CHANGE = 'PASSWORD_CHANGE', + // SEND_TRANSACTION_SEND_EMAIL = 'SEND_TRANSACTION_SEND_EMAIL', + // SEND_TRANSACTION_RECEIVE_EMAIL = 'SEND_TRANSACTION_RECEIVE_EMAIL', + // TRANSACTION_SEND_REDEEM = 'TRANSACTION_SEND_REDEEM', + // TRANSACTION_REPEATE_REDEEM = 'TRANSACTION_REPEATE_REDEEM', + // TRANSACTION_CREATION = 'TRANSACTION_CREATION', + // TRANSACTION_RECEIVE_REDEEM = 'TRANSACTION_RECEIVE_REDEEM', + // SEND_TRANSACTION_LINK_REDEEM_EMAIL = 'SEND_TRANSACTION_LINK_REDEEM_EMAIL', + // SEND_ADDED_CONTRIBUTION_EMAIL = 'SEND_ADDED_CONTRIBUTION_EMAIL', + // SEND_CONTRIBUTION_CONFIRM_EMAIL = 'SEND_CONTRIBUTION_CONFIRM_EMAIL', + // CONTRIBUTION_DENY = 'CONTRIBUTION_DENY', + // CONTRIBUTION_LINK_DEFINE = 'CONTRIBUTION_LINK_DEFINE', + // CONTRIBUTION_LINK_ACTIVATE_REDEEM = 'CONTRIBUTION_LINK_ACTIVATE_REDEEM', // USER_CREATE_CONTRIBUTION_MESSAGE = 'USER_CREATE_CONTRIBUTION_MESSAGE', // ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE', // DELETE_USER = 'DELETE_USER', diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index f43c12868..d4f059832 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -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 { EventType } from '@/event/EventType' +import { EventType } from '@/event/Event' import { logger, i18n as localization } from '@test/testSetup' import { UserInputError } from 'apollo-server-express' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' @@ -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: EventType.CONTRIBUTION_CONFIRM, + type: EventType.ADMIN_CONTRIBUTION_CONFIRM, }), ) }) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 688380701..55d90dab6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -42,7 +42,7 @@ import { EVENT_ADMIN_CONTRIBUTION_CREATE, EVENT_ADMIN_CONTRIBUTION_UPDATE, EVENT_ADMIN_CONTRIBUTION_DELETE, - EVENT_CONTRIBUTION_CONFIRM, + EVENT_ADMIN_CONTRIBUTION_CONFIRM, EVENT_ADMIN_CONTRIBUTION_DENY, } from '@/event/Event' import { calculateDecay } from '@/util/decay' @@ -555,7 +555,7 @@ export class ContributionResolver { await queryRunner.release() } - await EVENT_CONTRIBUTION_CONFIRM(user, moderatorUser, contribution, contribution.amount) + await EVENT_ADMIN_CONTRIBUTION_CONFIRM(user, moderatorUser, contribution, contribution.amount) } finally { releaseLock() } diff --git a/backend/src/graphql/resolver/TransactionResolver.test.ts b/backend/src/graphql/resolver/TransactionResolver.test.ts index f20230e6c..225569e6f 100644 --- a/backend/src/graphql/resolver/TransactionResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionResolver.test.ts @@ -6,7 +6,7 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import Decimal from 'decimal.js-light' -import { EventType } from '@/event/EventType' +import { EventType } from '@/event/Event' import { userFactory } from '@/seeds/factory/user' import { confirmContribution, diff --git a/backend/src/graphql/resolver/UserResolver.test.ts b/backend/src/graphql/resolver/UserResolver.test.ts index ba8972b96..da2dd8cdf 100644 --- a/backend/src/graphql/resolver/UserResolver.test.ts +++ b/backend/src/graphql/resolver/UserResolver.test.ts @@ -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 { EventType } from '@/event/EventType' +import { EventType } from '@/event/Event' import { Event as DbEvent } from '@entity/Event' import { validate as validateUUID, version as versionUUID } from 'uuid' import { peterLustig } from '@/seeds/users/peter-lustig' diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 5b18fd31e..cedea81b1 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -56,6 +56,7 @@ import { RIGHTS } from '@/auth/RIGHTS' import { hasElopageBuys } from '@/util/hasElopageBuys' import { Event, + EventType, EVENT_LOGIN, EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, EVENT_SEND_CONFIRMATION_EMAIL, @@ -69,7 +70,6 @@ import { FULL_CREATION_AVAILABLE } from './const/const' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import LogError from '@/server/LogError' -import { EventType } from '@/event/EventType' // eslint-disable-next-line @typescript-eslint/no-var-requires const sodium = require('sodium-native') diff --git a/database/migrations/0062-event_contribution_confirm.ts b/database/migrations/0062-event_contribution_confirm.ts new file mode 100644 index 000000000..97635b359 --- /dev/null +++ b/database/migrations/0062-event_contribution_confirm.ts @@ -0,0 +1,20 @@ +/* MIGRATION TO RENAME CONTRIBUTION_CONFIRM EVENT + * + * This migration renames the CONTRIBUTION_CONFIRM Event + * to ADMIN_CONTRIBUTION_CONFIRM + */ + +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ +/* eslint-disable @typescript-eslint/no-explicit-any */ + +export async function upgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'UPDATE `events` SET `type` = "ADMIN_CONTRIBUTION_CONFIRM" WHERE `type` = "CONTRIBUTION_CONFIRM";', + ) +} + +export async function downgrade(queryFn: (query: string, values?: any[]) => Promise>) { + await queryFn( + 'UPDATE `events` SET `type` = "CONTRIBUTION_CONFIRM" WHERE `type` = "ADMIN_CONTRIBUTION_CONFIRM";', + ) +} diff --git a/dht-node/src/config/index.ts b/dht-node/src/config/index.ts index 6ba9493ac..7ca44e52c 100644 --- a/dht-node/src/config/index.ts +++ b/dht-node/src/config/index.ts @@ -3,7 +3,7 @@ import dotenv from 'dotenv' dotenv.config() const constants = { - DB_VERSION: '0061-event_refactoring', + DB_VERSION: '0062-event_contribution_confirm', LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info LOG_LEVEL: process.env.LOG_LEVEL || 'info', diff --git a/federation/src/config/index.ts b/federation/src/config/index.ts index f792448d0..36fec7a7a 100644 --- a/federation/src/config/index.ts +++ b/federation/src/config/index.ts @@ -11,7 +11,7 @@ Decimal.set({ */ const constants = { - DB_VERSION: '0061-event_refactoring', + DB_VERSION: '0062-event_contribution_confirm', // DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 LOG4JS_CONFIG: 'log4js-config.json', // default log level on production should be info