Merge branch 'master' into 2825-add-download-link-to-qr-code

This commit is contained in:
elweyn 2023-03-31 09:13:23 +02:00
commit 2a37358fe1
157 changed files with 2126 additions and 1160 deletions

View File

@ -2,14 +2,18 @@ import { mount } from '@vue/test-utils'
import CreationFormular from './CreationFormular' import CreationFormular from './CreationFormular'
import { adminCreateContribution } from '../graphql/adminCreateContribution' import { adminCreateContribution } from '../graphql/adminCreateContribution'
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
import VueApollo from 'vue-apollo'
import { createMockClient } from 'mock-apollo-client'
import { adminOpenCreations } from '../graphql/adminOpenCreations'
const mockClient = createMockClient()
const apolloProvider = new VueApollo({
defaultClient: mockClient,
})
const localVue = global.localVue const localVue = global.localVue
localVue.use(VueApollo)
const apolloMutateMock = jest.fn().mockResolvedValue({
data: {
adminCreateContribution: [0, 0, 0],
},
})
const stateCommitMock = jest.fn() const stateCommitMock = jest.fn()
const mocks = { const mocks = {
@ -18,9 +22,6 @@ const mocks = {
const date = new Date(d) const date = new Date(d)
return date.toISOString().split('T')[0] return date.toISOString().split('T')[0]
}), }),
$apollo: {
mutate: apolloMutateMock,
},
$store: { $store: {
commit: stateCommitMock, commit: stateCommitMock,
}, },
@ -31,7 +32,8 @@ const propsData = {
creation: [], creation: [],
} }
const now = new Date(Date.now()) const now = new Date()
const getCreationDate = (sub) => { const getCreationDate = (sub) => {
const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0)
return date.toISOString().split('T')[0] return date.toISOString().split('T')[0]
@ -40,8 +42,43 @@ const getCreationDate = (sub) => {
describe('CreationFormular', () => { describe('CreationFormular', () => {
let wrapper let wrapper
const adminOpenCreationsMock = jest.fn()
const adminCreateContributionMock = jest.fn()
mockClient.setRequestHandler(
adminOpenCreations,
adminOpenCreationsMock.mockResolvedValue({
data: {
adminOpenCreations: [
{
month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(),
year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(),
amount: '200',
},
{
month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(),
year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(),
amount: '400',
},
{
month: now.getMonth(),
year: now.getFullYear(),
amount: '600',
},
],
},
}),
)
mockClient.setRequestHandler(
adminCreateContribution,
adminCreateContributionMock.mockResolvedValue({
data: {
adminCreateContribution: [0, 0, 0],
},
}),
)
const Wrapper = () => { const Wrapper = () => {
return mount(CreationFormular, { localVue, mocks, propsData }) return mount(CreationFormular, { localVue, mocks, propsData, apolloProvider })
} }
describe('mount', () => { describe('mount', () => {
@ -107,17 +144,12 @@ describe('CreationFormular', () => {
}) })
it('sends ... to apollo', () => { it('sends ... to apollo', () => {
expect(apolloMutateMock).toBeCalledWith( expect(adminCreateContributionMock).toBeCalledWith({
expect.objectContaining({
mutation: adminCreateContribution,
variables: {
email: 'benjamin@bluemchen.de', email: 'benjamin@bluemchen.de',
creationDate: getCreationDate(2), creationDate: getCreationDate(2),
amount: 90, amount: 90,
memo: 'Test create coins', memo: 'Test create coins',
}, })
}),
)
}) })
it('emits update-user-data', () => { it('emits update-user-data', () => {
@ -144,7 +176,7 @@ describe('CreationFormular', () => {
describe('sendForm with server error', () => { describe('sendForm with server error', () => {
beforeEach(async () => { beforeEach(async () => {
apolloMutateMock.mockRejectedValueOnce({ message: 'Ouch!' }) adminCreateContributionMock.mockRejectedValueOnce({ message: 'Ouch!' })
await wrapper.find('.test-submit').trigger('click') await wrapper.find('.test-submit').trigger('click')
}) })
@ -212,7 +244,7 @@ describe('CreationFormular', () => {
}) })
it('sends ... to apollo', () => { it('sends ... to apollo', () => {
expect(apolloMutateMock).toBeCalled() expect(adminCreateContributionMock).toBeCalled()
}) })
}) })
@ -275,7 +307,7 @@ describe('CreationFormular', () => {
}) })
it('sends mutation to apollo', () => { it('sends mutation to apollo', () => {
expect(apolloMutateMock).toBeCalled() expect(adminCreateContributionMock).toBeCalled()
}) })
it('toast success message', () => { it('toast success message', () => {

View File

@ -117,10 +117,6 @@ export default {
return {} return {}
}, },
}, },
creation: {
type: Array,
required: true,
},
}, },
data() { data() {
return { return {
@ -129,6 +125,7 @@ export default {
rangeMin: 0, rangeMin: 0,
rangeMax: 1000, rangeMax: 1000,
selected: '', selected: '',
userId: this.item.userId,
} }
}, },
methods: { methods: {
@ -136,7 +133,7 @@ export default {
// do we want to reset the memo everytime the month changes? // do we want to reset the memo everytime the month changes?
this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year this.text = this.$t('creation_form.creation_for') + ' ' + name.short + ' ' + name.year
this.rangeMin = 0 this.rangeMin = 0
this.rangeMax = name.creation this.rangeMax = Number(name.creation)
}, },
submitCreation() { submitCreation() {
this.$apollo this.$apollo
@ -167,6 +164,10 @@ export default {
this.$refs.creationForm.reset() this.$refs.creationForm.reset()
this.value = 0 this.value = 0
}) })
.finally(() => {
this.$apollo.queries.OpenCreations.refetch()
this.selected = ''
})
}, },
}, },
watch: { watch: {

View File

@ -1,19 +1,18 @@
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import EditCreationFormular from './EditCreationFormular' import EditCreationFormular from './EditCreationFormular'
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup' import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
import VueApollo from 'vue-apollo'
import { createMockClient } from 'mock-apollo-client'
import { adminOpenCreations } from '../graphql/adminOpenCreations'
import { adminUpdateContribution } from '../graphql/adminUpdateContribution'
const mockClient = createMockClient()
const apolloProvider = new VueApollo({
defaultClient: mockClient,
})
const localVue = global.localVue const localVue = global.localVue
localVue.use(VueApollo)
const apolloMutateMock = jest.fn().mockResolvedValue({
data: {
adminUpdateContribution: {
creation: [0, 0, 0],
amount: 500,
date: new Date(),
memo: 'Test Schöpfung 2',
},
},
})
const stateCommitMock = jest.fn() const stateCommitMock = jest.fn()
@ -23,22 +22,18 @@ const mocks = {
const date = new Date(d) const date = new Date(d)
return date.toISOString().split('T')[0] return date.toISOString().split('T')[0]
}), }),
$apollo: {
mutate: apolloMutateMock,
},
$store: { $store: {
commit: stateCommitMock, commit: stateCommitMock,
}, },
} }
const now = new Date(Date.now()) const now = new Date()
const getCreationDate = (sub) => { const getCreationDate = (sub) => {
const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0) const date = sub === 0 ? now : new Date(now.getFullYear(), now.getMonth() - sub, 1, 0)
return date.toISOString().split('T')[0] return date.toISOString().split('T')[0]
} }
const propsData = { const propsData = {
creation: [200, 400, 600],
creationUserData: { creationUserData: {
memo: 'Test schöpfung 1', memo: 'Test schöpfung 1',
amount: 100, amount: 100,
@ -46,20 +41,65 @@ const propsData = {
}, },
item: { item: {
id: 0, id: 0,
email: 'bob@baumeister.de', amount: '300',
contributionDate: `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`,
}, },
} }
const data = () => {
return { creation: ['1000', '1000', '400'] }
}
describe('EditCreationFormular', () => { describe('EditCreationFormular', () => {
let wrapper let wrapper
const adminUpdateContributionMock = jest.fn()
const adminOpenCreationsMock = jest.fn()
mockClient.setRequestHandler(
adminOpenCreations,
adminOpenCreationsMock.mockResolvedValue({
data: {
adminOpenCreations: [
{
month: new Date(now.getFullYear(), now.getMonth() - 2).getMonth(),
year: new Date(now.getFullYear(), now.getMonth() - 2).getFullYear(),
amount: '1000',
},
{
month: new Date(now.getFullYear(), now.getMonth() - 1).getMonth(),
year: new Date(now.getFullYear(), now.getMonth() - 1).getFullYear(),
amount: '1000',
},
{
month: now.getMonth(),
year: now.getFullYear(),
amount: '400',
},
],
},
}),
)
mockClient.setRequestHandler(
adminUpdateContribution,
adminUpdateContributionMock.mockResolvedValue({
data: {
adminUpdateContribution: {
amount: '600',
date: new Date(),
memo: 'This is my memo',
},
},
}),
)
const Wrapper = () => { const Wrapper = () => {
return mount(EditCreationFormular, { localVue, mocks, propsData }) return mount(EditCreationFormular, { localVue, mocks, propsData, data, apolloProvider })
} }
describe('mount', () => { describe('mount', () => {
beforeEach(() => { beforeEach(async () => {
wrapper = Wrapper() wrapper = Wrapper()
await wrapper.vm.$nextTick()
}) })
it('has a DIV element with the class.component-edit-creation-formular', () => { it('has a DIV element with the class.component-edit-creation-formular', () => {
@ -89,42 +129,16 @@ describe('EditCreationFormular', () => {
}) })
it('calls the API', () => { it('calls the API', () => {
expect(apolloMutateMock).toBeCalledWith( expect(adminUpdateContributionMock).toBeCalledWith({
expect.objectContaining({
variables: {
id: 0, id: 0,
email: 'bob@baumeister.de',
creationDate: getCreationDate(0), creationDate: getCreationDate(0),
amount: 500, amount: 500,
memo: 'Test Schöpfung 2', memo: 'Test Schöpfung 2',
},
}),
)
}) })
it('emits update-user-data', () => {
expect(wrapper.emitted('update-user-data')).toEqual([
[
{
id: 0,
email: 'bob@baumeister.de',
},
[0, 0, 0],
],
])
}) })
it('emits update-creation-data', () => { it('emits update-creation-data', () => {
expect(wrapper.emitted('update-creation-data')).toEqual([ expect(wrapper.emitted('update-creation-data')).toBeTruthy()
[
{
amount: 500,
date: expect.any(Date),
memo: 'Test Schöpfung 2',
row: expect.any(Object),
},
],
])
}) })
it('toasts a success message', () => { it('toasts a success message', () => {
@ -134,7 +148,7 @@ describe('EditCreationFormular', () => {
describe('change and save memo and value with error', () => { describe('change and save memo and value with error', () => {
beforeEach(async () => { beforeEach(async () => {
apolloMutateMock.mockRejectedValue({ message: 'Oh no!' }) adminUpdateContributionMock.mockRejectedValue({ message: 'Oh no!' })
await wrapper.find('input[type="number"]').setValue(500) await wrapper.find('input[type="number"]').setValue(500)
await wrapper.find('textarea').setValue('Test Schöpfung 2') await wrapper.find('textarea').setValue('Test Schöpfung 2')
await wrapper.find('.test-submit').trigger('click') await wrapper.find('.test-submit').trigger('click')

View File

@ -96,18 +96,14 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
creation: {
type: Array,
required: true,
},
}, },
data() { data() {
return { return {
text: !this.creationUserData.memo ? '' : this.creationUserData.memo, text: !this.creationUserData.memo ? '' : this.creationUserData.memo,
value: !this.creationUserData.amount ? 0 : Number(this.creationUserData.amount), value: !this.creationUserData.amount ? 0 : Number(this.creationUserData.amount),
rangeMin: 0, rangeMin: 0,
rangeMax: 1000, selected: this.selectedComputed,
selected: '', userId: this.item.userId,
} }
}, },
methods: { methods: {
@ -117,20 +113,13 @@ export default {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: this.item.id, id: this.item.id,
email: this.item.email,
creationDate: this.selected.date, creationDate: this.selected.date,
amount: Number(this.value), amount: Number(this.value),
memo: this.text, memo: this.text,
}, },
}) })
.then((result) => { .then((result) => {
this.$emit('update-user-data', this.item, result.data.adminUpdateContribution.creation) this.$emit('update-creation-data')
this.$emit('update-creation-data', {
amount: Number(result.data.adminUpdateContribution.amount),
date: result.data.adminUpdateContribution.date,
memo: result.data.adminUpdateContribution.memo,
row: this.row,
})
this.toastSuccess( this.toastSuccess(
this.$t('creation_form.toasted_update', { this.$t('creation_form.toasted_update', {
value: this.value, value: this.value,
@ -149,15 +138,29 @@ export default {
// Den geschöpften Wert auf o setzen // Den geschöpften Wert auf o setzen
this.value = 0 this.value = 0
}) })
.finally(() => {
this.$apollo.queries.OpenCreations.refetch()
})
}, },
}, },
created() { computed: {
if (this.creationUserData.date) { creationIndex() {
const month = this.$d(new Date(this.creationUserData.date), 'month') const month = this.$d(new Date(this.item.contributionDate), 'month')
const index = this.radioOptions.findIndex((obj) => obj.item.short === month) return this.radioOptions.findIndex((obj) => {
this.selected = this.radioOptions[index].item return obj.item.short === month
this.rangeMax = Number(this.creation[index]) + Number(this.creationUserData.amount) })
} },
selectedComputed() {
return this.radioOptions[this.creationIndex].item
},
rangeMax() {
return Number(this.creation[this.creationIndex]) + Number(this.item.amount)
},
},
watch: {
selectedComputed() {
this.selected = this.selectedComputed
},
}, },
} }
</script> </script>

View File

@ -5,7 +5,6 @@ const localVue = global.localVue
const apolloMutateMock = jest.fn().mockResolvedValue({}) const apolloMutateMock = jest.fn().mockResolvedValue({})
const apolloQueryMock = jest.fn().mockResolvedValue({}) const apolloQueryMock = jest.fn().mockResolvedValue({})
const toggleDetailsMock = jest.fn()
const propsData = { const propsData = {
items: [ items: [
@ -17,7 +16,7 @@ const propsData = {
amount: 300, amount: 300,
memo: 'Aktives Grundeinkommen für Januar 2022', memo: 'Aktives Grundeinkommen für Januar 2022',
date: '2022-01-01T00:00:00.000Z', date: '2022-01-01T00:00:00.000Z',
moderator: 1, moderatorId: 1,
creation: [700, 1000, 1000], creation: [700, 1000, 1000],
__typename: 'PendingCreation', __typename: 'PendingCreation',
}, },
@ -29,7 +28,7 @@ const propsData = {
amount: 210, amount: 210,
memo: 'Aktives Grundeinkommen für Januar 2022', memo: 'Aktives Grundeinkommen für Januar 2022',
date: '2022-01-01T00:00:00.000Z', date: '2022-01-01T00:00:00.000Z',
moderator: null, moderatorId: null,
creation: [790, 1000, 1000], creation: [790, 1000, 1000],
__typename: 'PendingCreation', __typename: 'PendingCreation',
}, },
@ -41,7 +40,7 @@ const propsData = {
amount: 330, amount: 330,
memo: 'Aktives Grundeinkommen für Januar 2022', memo: 'Aktives Grundeinkommen für Januar 2022',
date: '2022-01-01T00:00:00.000Z', date: '2022-01-01T00:00:00.000Z',
moderator: 1, moderatorId: 1,
creation: [670, 1000, 1000], creation: [670, 1000, 1000],
__typename: 'PendingCreation', __typename: 'PendingCreation',
}, },
@ -83,7 +82,7 @@ const mocks = {
$store: { $store: {
state: { state: {
moderator: { moderator: {
id: 0, id: 1,
name: 'test moderator', name: 'test moderator',
}, },
}, },
@ -132,14 +131,6 @@ describe('OpenCreationsTable', () => {
}) })
}) })
describe('call updateUserData', () => {
it('user creations has updated data', async () => {
wrapper.vm.updateUserData(propsData.items[0], [444, 555, 666])
await wrapper.vm.$nextTick()
expect(wrapper.vm.items[0].creation).toEqual([444, 555, 666])
})
})
describe('call updateState', () => { describe('call updateState', () => {
beforeEach(() => { beforeEach(() => {
wrapper.vm.updateState(4) wrapper.vm.updateState(4)
@ -149,40 +140,5 @@ describe('OpenCreationsTable', () => {
expect(wrapper.vm.$root.$emit('update-state', 4)).toBeTruthy() expect(wrapper.vm.$root.$emit('update-state', 4)).toBeTruthy()
}) })
}) })
describe('call updateCreationData', () => {
const date = new Date()
beforeEach(() => {
wrapper.vm.updateCreationData({
amount: Number(80.0),
date: date,
memo: 'Test memo',
row: {
item: {},
detailsShowing: false,
toggleDetails: toggleDetailsMock,
},
})
})
it('emits update-state', () => {
expect(
wrapper.vm.$emit('update-contributions', {
amount: Number(80.0),
date: date,
memo: 'Test memo',
row: {
item: {},
detailsShowing: false,
toggleDetails: toggleDetailsMock,
},
}),
).toBeTruthy()
})
it('calls toggleDetails', () => {
expect(toggleDetailsMock).toBeCalled()
})
})
}) })
}) })

View File

@ -27,9 +27,10 @@
<template #cell(editCreation)="row"> <template #cell(editCreation)="row">
<div v-if="!myself(row.item)"> <div v-if="!myself(row.item)">
<b-button <b-button
v-if="row.item.moderator" v-if="row.item.moderatorId"
variant="info" variant="info"
size="md" size="md"
:index="0"
@click="rowToggleDetails(row, 0)" @click="rowToggleDetails(row, 0)"
class="mr-2" class="mr-2"
> >
@ -89,14 +90,13 @@
@row-toggle-details="rowToggleDetails(row, 0)" @row-toggle-details="rowToggleDetails(row, 0)"
> >
<template #show-creation> <template #show-creation>
<div v-if="row.item.moderator"> <div v-if="row.item.moderatorId">
<edit-creation-formular <edit-creation-formular
type="singleCreation" type="singleCreation"
:creation="row.item.creation"
:item="row.item" :item="row.item"
:row="row" :row="row"
:creationUserData="creationUserData" :creationUserData="creationUserData"
@update-creation-data="updateCreationData" @update-creation-data="$emit('update-contributions')"
/> />
</div> </div>
<div v-else> <div v-else>
@ -104,7 +104,6 @@
:contributionId="row.item.id" :contributionId="row.item.id"
:contributionState="row.item.state" :contributionState="row.item.state"
@update-state="updateState" @update-state="updateState"
@update-user-data="updateUserData"
/> />
</div> </div>
</template> </template>
@ -146,22 +145,9 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
creationUserData: {
amount: null,
date: null,
memo: null,
moderator: null,
},
}
},
methods: { methods: {
myself(item) { myself(item) {
return ( return item.userId === this.$store.state.moderator.id
`${item.firstName} ${item.lastName}` ===
`${this.$store.state.moderator.firstName} ${this.$store.state.moderator.lastName}`
)
}, },
getStatusIcon(status) { getStatusIcon(status) {
return iconMap[status] ? iconMap[status] : 'default-icon' return iconMap[status] ? iconMap[status] : 'default-icon'
@ -174,16 +160,6 @@ export default {
if (item.state === 'IN_PROGRESS') return 'table-primary' if (item.state === 'IN_PROGRESS') return 'table-primary'
if (item.state === 'PENDING') return 'table-primary' if (item.state === 'PENDING') return 'table-primary'
}, },
updateCreationData(data) {
const row = data.row
this.$emit('update-contributions', data)
delete data.row
this.creationUserData = { ...this.creationUserData, ...data }
row.toggleDetails()
},
updateUserData(rowItem, newCreation) {
rowItem.creation = newCreation
},
updateState(id) { updateState(id) {
this.$emit('update-state', id) this.$emit('update-state', id)
}, },

View File

@ -32,6 +32,8 @@ export const adminListContributions = gql`
deniedBy deniedBy
deletedAt deletedAt
deletedBy deletedBy
moderatorId
userId
} }
} }
} }

View File

@ -0,0 +1,11 @@
import gql from 'graphql-tag'
export const adminOpenCreations = gql`
query ($userId: Int!) {
adminOpenCreations(userId: $userId) {
year
month
amount
}
}
`

View File

@ -1,18 +1,11 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const adminUpdateContribution = gql` export const adminUpdateContribution = gql`
mutation ($id: Int!, $email: String!, $amount: Decimal!, $memo: String!, $creationDate: String!) { mutation ($id: Int!, $amount: Decimal!, $memo: String!, $creationDate: String!) {
adminUpdateContribution( adminUpdateContribution(id: $id, amount: $amount, memo: $memo, creationDate: $creationDate) {
id: $id
email: $email
amount: $amount
memo: $memo
creationDate: $creationDate
) {
amount amount
date date
memo memo
creation
} }
} }
` `

View File

@ -1,9 +1,11 @@
import { adminOpenCreations } from '../graphql/adminOpenCreations'
export const creationMonths = { export const creationMonths = {
props: { data() {
creation: { return {
type: Array, creation: [1000, 1000, 1000],
default: () => [1000, 1000, 1000], userId: 0,
}, }
}, },
computed: { computed: {
creationDates() { creationDates() {
@ -38,4 +40,23 @@ export const creationMonths = {
return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ') return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ')
}, },
}, },
apollo: {
OpenCreations: {
query() {
return adminOpenCreations
},
variables() {
return {
userId: this.userId,
}
},
fetchPolicy: 'no-cache',
update({ adminOpenCreations }) {
this.creation = adminOpenCreations.map((obj) => obj.amount)
},
error({ message }) {
this.toastError(message)
},
},
},
} }

View File

@ -44,7 +44,7 @@
:fields="fields" :fields="fields"
@show-overlay="showOverlay" @show-overlay="showOverlay"
@update-state="updateStatus" @update-state="updateStatus"
@update-contributions="$apollo.queries.AllContributions.refetch()" @update-contributions="$apollo.queries.ListAllContributions.refetch()"
/> />
<b-pagination <b-pagination
@ -212,7 +212,7 @@ export default {
return this.formatDateOrDash(value) return this.formatDateOrDash(value)
}, },
}, },
{ key: 'moderator', label: this.$t('moderator') }, { key: 'moderatorId', label: this.$t('moderator') },
{ key: 'editCreation', label: this.$t('chat') }, { key: 'editCreation', label: this.$t('chat') },
{ key: 'confirm', label: this.$t('save') }, { key: 'confirm', label: this.$t('save') },
], ],

View File

@ -42,7 +42,7 @@ const defaultData = () => {
amount: 500, amount: 500,
memo: 'Danke für alles', memo: 'Danke für alles',
date: new Date(), date: new Date(),
moderator: 1, moderatorId: 1,
state: 'PENDING', state: 'PENDING',
creation: [500, 500, 500], creation: [500, 500, 500],
messagesCount: 0, messagesCount: 0,
@ -64,7 +64,7 @@ const defaultData = () => {
amount: 1000000, amount: 1000000,
memo: 'Gut Ergattert', memo: 'Gut Ergattert',
date: new Date(), date: new Date(),
moderator: 1, moderatorId: 1,
state: 'PENDING', state: 'PENDING',
creation: [500, 500, 500], creation: [500, 500, 500],
messagesCount: 0, messagesCount: 0,

View File

@ -1,12 +1,27 @@
// eslint-disable-next-line import/no-commonjs, import/unambiguous
module.exports = { module.exports = {
root: true, root: true,
env: { env: {
node: true, node: true,
}, },
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest'], plugins: ['prettier', '@typescript-eslint', 'type-graphql', 'jest', 'import'],
extends: ['standard', 'eslint:recommended', 'plugin:prettier/recommended'], extends: [
// add your custom rules here 'standard',
'eslint:recommended',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: true,
node: true,
},
},
rules: { rules: {
'no-console': ['error'], 'no-console': ['error'],
'no-debugger': 'error', 'no-debugger': 'error',
@ -22,6 +37,70 @@ module.exports = {
'jest/no-identical-title': 'error', 'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'error', 'jest/prefer-to-have-length': 'error',
'jest/valid-expect': 'error', 'jest/valid-expect': 'error',
// import
'import/export': 'error',
'import/no-deprecated': 'error',
'import/no-empty-named-blocks': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-mutable-exports': 'error',
'import/no-unused-modules': 'error',
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-amd': 'error',
'import/no-commonjs': 'error',
'import/no-import-module-exports': 'error',
'import/no-nodejs-modules': 'off',
'import/unambiguous': 'error',
'import/default': 'error',
'import/named': 'error',
'import/namespace': 'error',
'import/no-absolute-path': 'error',
'import/no-cycle': 'off',
'import/no-dynamic-require': 'error',
'import/no-internal-modules': 'off',
'import/no-relative-packages': 'error',
'import/no-relative-parent-imports': ['error', { ignore: ['@/*'] }],
'import/no-self-import': 'error',
'import/no-unresolved': 'error',
'import/no-useless-path-segments': 'error',
'import/no-webpack-loader-syntax': 'error',
'import/consistent-type-specifier-style': 'error',
'import/exports-last': 'off',
'import/extensions': 'error',
'import/first': 'error',
'import/group-exports': 'off',
'import/newline-after-import': 'error',
'import/no-anonymous-default-export': 'error',
'import/no-default-export': 'off',
'import/no-duplicates': 'error',
'import/no-named-default': 'error',
'import/no-namespace': 'error',
'import/no-unassigned-import': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
'newlines-between': 'always',
pathGroups: [
{
pattern: '@?*/**',
group: 'external',
position: 'after',
},
{
pattern: '@/**',
group: 'external',
position: 'after',
},
],
alphabetize: {
order: 'asc' /* sort in ascending order. Options: ['ignore', 'asc', 'desc'] */,
caseInsensitive: true /* ignore case. Options: [true, false] */,
},
distinctGroup: true,
},
],
'import/prefer-default-export': 'off', // TODO
}, },
overrides: [ overrides: [
// only for ts files // only for ts files
@ -38,9 +117,11 @@ module.exports = {
'no-void': ['error', { allowAsStatement: true }], 'no-void': ['error', { allowAsStatement: true }],
// ignore prefer-regexp-exec rule to allow string.match(regex) // ignore prefer-regexp-exec rule to allow string.match(regex)
'@typescript-eslint/prefer-regexp-exec': 'off', '@typescript-eslint/prefer-regexp-exec': 'off',
// this should not run on ts files: https://github.com/import-js/eslint-plugin-import/issues/2215#issuecomment-911245486
'import/unambiguous': 'off',
}, },
parserOptions: { parserOptions: {
tsconfigRootDir: __dirname, tsconfigRootDir: './',
project: ['./tsconfig.json'], project: ['./tsconfig.json'],
// this is to properly reference the referenced project database without requirement of compiling it // this is to properly reference the referenced project database without requirement of compiling it
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true, EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,

View File

@ -1,4 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ /** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
// eslint-disable-next-line import/no-commonjs, import/unambiguous
module.exports = { module.exports = {
verbose: true, verbose: true,
preset: 'ts-jest', preset: 'ts-jest',

View File

@ -12,7 +12,7 @@
"clean": "tsc --build --clean", "clean": "tsc --build --clean",
"start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js", "start": "cross-env TZ=UTC TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/src/index.js",
"dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r tsconfig-paths/register src/index.ts", "dev": "cross-env TZ=UTC nodemon -w src --ext ts --exec ts-node -r tsconfig-paths/register src/index.ts",
"lint": "eslint --max-warnings=0 --ext .js,.ts .", "lint": "eslint --max-warnings=0 .",
"test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles", "test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --forceExit --detectOpenHandles",
"seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts",
"klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts", "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts",
@ -29,6 +29,7 @@
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"email-templates": "^10.0.1", "email-templates": "^10.0.1",
"express": "^4.17.1", "express": "^4.17.1",
"gradido-database": "file:../database",
"graphql": "^15.5.1", "graphql": "^15.5.1",
"graphql-request": "5.0.0", "graphql-request": "5.0.0",
"i18n": "^0.15.1", "i18n": "^0.15.1",
@ -61,13 +62,15 @@
"eslint": "^7.29.0", "eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.3", "eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.23.4", "eslint-import-resolver-typescript": "^3.5.3",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1", "eslint-plugin-jest": "^27.2.1",
"eslint-plugin-node": "^11.1.0", "eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-promise": "^5.1.0", "eslint-plugin-promise": "^5.1.0",
"eslint-plugin-type-graphql": "^1.0.0", "eslint-plugin-type-graphql": "^1.0.0",
"faker": "^5.5.3", "faker": "^5.5.3",
"graphql-tag": "^2.12.6",
"jest": "^27.2.4", "jest": "^27.2.4",
"klicktipp-api": "^1.0.2", "klicktipp-api": "^1.0.2",
"nodemon": "^2.0.7", "nodemon": "^2.0.7",

View File

@ -2,8 +2,8 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import axios from 'axios' import axios from 'axios'
import { backendLogger as logger } from '@/server/logger'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
export const apiPost = async (url: string, payload: unknown): Promise<any> => { export const apiPost = async (url: string, payload: unknown): Promise<any> => {

View File

@ -4,9 +4,11 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import KlicktippConnector from 'klicktipp-api'
import CONFIG from '@/config' import CONFIG from '@/config'
// eslint-disable-next-line import/no-relative-parent-imports
import KlicktippConnector from 'klicktipp-api'
const klicktippConnector = new KlicktippConnector() const klicktippConnector = new KlicktippConnector()
export const klicktippSignIn = async ( export const klicktippSignIn = async (

View File

@ -1,19 +1,21 @@
import jwt from 'jsonwebtoken' import { verify, sign } from 'jsonwebtoken'
import CONFIG from '@/config/' import CONFIG from '@/config/'
import { CustomJwtPayload } from './CustomJwtPayload'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { CustomJwtPayload } from './CustomJwtPayload'
export const decode = (token: string): CustomJwtPayload | null => { export const decode = (token: string): CustomJwtPayload | null => {
if (!token) throw new LogError('401 Unauthorized') if (!token) throw new LogError('401 Unauthorized')
try { try {
return <CustomJwtPayload>jwt.verify(token, CONFIG.JWT_SECRET) return <CustomJwtPayload>verify(token, CONFIG.JWT_SECRET)
} catch (err) { } catch (err) {
return null return null
} }
} }
export const encode = (gradidoID: string): string => { export const encode = (gradidoID: string): string => {
const token = jwt.sign({ gradidoID }, CONFIG.JWT_SECRET, { const token = sign({ gradidoID }, CONFIG.JWT_SECRET, {
expiresIn: CONFIG.JWT_EXPIRES_IN, expiresIn: CONFIG.JWT_EXPIRES_IN,
}) })
return token return token

View File

@ -1,7 +1,8 @@
// ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env) // ATTENTION: DO NOT PUT ANY SECRETS IN HERE (or the .env)
import { Decimal } from 'decimal.js-light'
import dotenv from 'dotenv' import dotenv from 'dotenv'
import Decimal from 'decimal.js-light'
dotenv.config() dotenv.config()
Decimal.set({ Decimal.set({
@ -10,7 +11,7 @@ Decimal.set({
}) })
const constants = { const constants = {
DB_VERSION: '0063-event_link_fields', DB_VERSION: '0064-event_rename',
DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0 DECAY_START_TIME: new Date('2021-05-13 17:46:31-0000'), // GMT+0
LOG4JS_CONFIG: 'log4js-config.json', LOG4JS_CONFIG: 'log4js-config.json',
// default log level on production should be info // default log level on production should be info

View File

@ -1,8 +1,11 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/unbound-method */ /* eslint-disable @typescript-eslint/unbound-method */
import { createTransport } from 'nodemailer' import { createTransport } from 'nodemailer'
import { logger, i18n } from '@test/testSetup' import { logger, i18n } from '@test/testSetup'
import CONFIG from '@/config' import CONFIG from '@/config'
import { sendEmailTranslated } from './sendEmailTranslated' import { sendEmailTranslated } from './sendEmailTranslated'
CONFIG.EMAIL = false CONFIG.EMAIL = false

View File

@ -1,11 +1,13 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
import CONFIG from '@/config'
import { backendLogger as logger } from '@/server/logger'
import path from 'path' import path from 'path'
import { createTransport } from 'nodemailer'
import Email from 'email-templates' import Email from 'email-templates'
import i18n from 'i18n' import i18n from 'i18n'
import { createTransport } from 'nodemailer'
import CONFIG from '@/config'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export const sendEmailTranslated = async (params: { export const sendEmailTranslated = async (params: {
receiver: { receiver: {

View File

@ -3,10 +3,14 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import Decimal from 'decimal.js-light' import { Decimal } from 'decimal.js-light'
import { testEnvironment } from '@test/helpers' import { testEnvironment } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup' import { logger, i18n as localization } from '@test/testSetup'
import CONFIG from '@/config' import CONFIG from '@/config'
import { sendEmailTranslated } from './sendEmailTranslated'
import { import {
sendAddedContributionMessageEmail, sendAddedContributionMessageEmail,
sendAccountActivationEmail, sendAccountActivationEmail,
@ -18,7 +22,6 @@ import {
sendTransactionLinkRedeemedEmail, sendTransactionLinkRedeemedEmail,
sendTransactionReceivedEmail, sendTransactionReceivedEmail,
} from './sendEmailVariants' } from './sendEmailVariants'
import { sendEmailTranslated } from './sendEmailTranslated'
let con: any let con: any
let testEnv: any let testEnv: any

View File

@ -1,6 +1,8 @@
import Decimal from 'decimal.js-light' import { Decimal } from 'decimal.js-light'
import CONFIG from '@/config' import CONFIG from '@/config'
import { decimalSeparatorByLanguage } from '@/util/utilities' import { decimalSeparatorByLanguage } from '@/util/utilities'
import { sendEmailTranslated } from './sendEmailTranslated' import { sendEmailTranslated } from './sendEmailTranslated'
export const sendAddedContributionMessageEmail = (data: { export const sendAddedContributionMessageEmail = (data: {

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async ( export const EVENT_ADMIN_CONTRIBUTION_CONFIRM = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( export const EVENT_ADMIN_CONTRIBUTION_CREATE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( export const EVENT_ADMIN_CONTRIBUTION_DELETE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( export const EVENT_ADMIN_CONTRIBUTION_DENY = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async ( export const EVENT_ADMIN_CONTRIBUTION_LINK_CREATE = async (

View File

@ -1,6 +1,7 @@
import { User as DbUser } from '@entity/User'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async ( export const EVENT_ADMIN_CONTRIBUTION_LINK_DELETE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async ( export const EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE = async (

View File

@ -1,7 +1,8 @@
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async ( export const EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async (

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_ADMIN_USER_DELETE = async (user: DbUser, moderator: DbUser): Promise<DbEvent> =>
Event(EventType.ADMIN_USER_DELETE, user, moderator).save()

View File

@ -1,8 +1,9 @@
import { User as DbUser } from '@entity/User'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ADMIN_SEND_CONFIRMATION_EMAIL = async ( export const EVENT_ADMIN_USER_ROLE_SET = async (
user: DbUser, user: DbUser,
moderator: DbUser, moderator: DbUser,
): Promise<DbEvent> => Event(EventType.ADMIN_SEND_CONFIRMATION_EMAIL, user, moderator).save() ): Promise<DbEvent> => Event(EventType.ADMIN_USER_ROLE_SET, user, moderator).save()

View File

@ -0,0 +1,9 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_ADMIN_USER_UNDELETE = async (
user: DbUser,
moderator: DbUser,
): Promise<DbEvent> => Event(EventType.ADMIN_USER_UNDELETE, user, moderator).save()

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_CONTRIBUTION_CREATE = async ( export const EVENT_CONTRIBUTION_CREATE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_CONTRIBUTION_DELETE = async ( export const EVENT_CONTRIBUTION_DELETE = async (

View File

@ -1,9 +1,10 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Transaction as DbTransaction } from '@entity/Transaction'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_CONTRIBUTION_LINK_REDEEM = async ( export const EVENT_CONTRIBUTION_LINK_REDEEM = async (

View File

@ -1,7 +1,8 @@
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async ( export const EVENT_CONTRIBUTION_MESSAGE_CREATE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_CONTRIBUTION_UPDATE = async ( export const EVENT_CONTRIBUTION_UPDATE = async (

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_ACCOUNT_MULTIREGISTRATION, user, { id: 0 } as DbUser).save()

View File

@ -0,0 +1,9 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_EMAIL_ADMIN_CONFIRMATION = async (
user: DbUser,
moderator: DbUser,
): Promise<DbEvent> => Event(EventType.EMAIL_ADMIN_CONFIRMATION, user, moderator).save()

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_EMAIL_CONFIRMATION = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_CONFIRMATION, user, user).save()

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_EMAIL_FORGOT_PASSWORD = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.EMAIL_FORGOT_PASSWORD, user, { id: 0 } as DbUser).save()

View File

@ -1,6 +0,0 @@
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<DbEvent> =>
Event(EventType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, user, { id: 0 } as DbUser).save()

View File

@ -1,6 +0,0 @@
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<DbEvent> =>
Event(EventType.SEND_CONFIRMATION_EMAIL, user, user).save()

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_TRANSACTION_LINK_CREATE = async ( export const EVENT_TRANSACTION_LINK_CREATE = async (

View File

@ -1,6 +1,7 @@
import { User as DbUser } from '@entity/User'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_TRANSACTION_LINK_DELETE = async ( export const EVENT_TRANSACTION_LINK_DELETE = async (

View File

@ -1,7 +1,8 @@
import Decimal from 'decimal.js-light'
import { User as DbUser } from '@entity/User'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_TRANSACTION_LINK_REDEEM = async ( export const EVENT_TRANSACTION_LINK_REDEEM = async (

View File

@ -1,7 +1,8 @@
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 as DbEvent } from '@entity/Event'
import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_TRANSACTION_RECEIVE = async ( export const EVENT_TRANSACTION_RECEIVE = async (

View File

@ -1,7 +1,8 @@
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 as DbEvent } from '@entity/Event'
import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_TRANSACTION_SEND = async ( export const EVENT_TRANSACTION_SEND = async (

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_USER_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_ACTIVATE_ACCOUNT, user, user).save()

View File

@ -1,6 +1,7 @@
import { User as DbUser } from '@entity/User'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_ACTIVATE_ACCOUNT = async (user: DbUser): Promise<DbEvent> => export const EVENT_USER_INFO_UPDATE = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.ACTIVATE_ACCOUNT, user, user).save() Event(EventType.USER_INFO_UPDATE, user, user).save()

View File

@ -1,6 +1,7 @@
import { User as DbUser } from '@entity/User'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_LOGIN = async (user: DbUser): Promise<DbEvent> => export const EVENT_USER_LOGIN = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.LOGIN, user, user).save() Event(EventType.USER_LOGIN, user, user).save()

View File

@ -1,6 +1,7 @@
import { User as DbUser } from '@entity/User'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event' import { Event, EventType } from './Event'
export const EVENT_REGISTER = async (user: DbUser): Promise<DbEvent> => export const EVENT_USER_LOGOUT = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.REGISTER, user, user).save() Event(EventType.USER_LOGOUT, user, user).save()

View File

@ -0,0 +1,7 @@
import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Event, EventType } from './Event'
export const EVENT_USER_REGISTER = async (user: DbUser): Promise<DbEvent> =>
Event(EventType.USER_REGISTER, user, user).save()

View File

@ -1,12 +1,13 @@
import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { Event as DbEvent } from '@entity/Event' import { Event as DbEvent } from '@entity/Event'
import { User as DbUser } from '@entity/User'
import { Transaction as DbTransaction } from '@entity/Transaction' import { Transaction as DbTransaction } from '@entity/Transaction'
import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink' import { TransactionLink as DbTransactionLink } from '@entity/TransactionLink'
import { Contribution as DbContribution } from '@entity/Contribution' import { User as DbUser } from '@entity/User'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { Decimal } from 'decimal.js-light'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import Decimal from 'decimal.js-light' import { EventType } from './EventType'
import { EventType } from './Event'
export const Event = ( export const Event = (
type: EventType, type: EventType,
@ -34,9 +35,8 @@ export const Event = (
return event return event
} }
export { EventType } from './EventType' export { EventType }
export { EVENT_ACTIVATE_ACCOUNT } from './EVENT_ACTIVATE_ACCOUNT'
export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM' export { EVENT_ADMIN_CONTRIBUTION_CONFIRM } from './EVENT_ADMIN_CONTRIBUTION_CONFIRM'
export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE' export { EVENT_ADMIN_CONTRIBUTION_CREATE } from './EVENT_ADMIN_CONTRIBUTION_CREATE'
export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE' export { EVENT_ADMIN_CONTRIBUTION_DELETE } from './EVENT_ADMIN_CONTRIBUTION_DELETE'
@ -46,18 +46,25 @@ export { EVENT_ADMIN_CONTRIBUTION_LINK_CREATE } from './EVENT_ADMIN_CONTRIBUTION
export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE' export { EVENT_ADMIN_CONTRIBUTION_LINK_DELETE } from './EVENT_ADMIN_CONTRIBUTION_LINK_DELETE'
export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE' export { EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE } from './EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE'
export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_ADMIN_SEND_CONFIRMATION_EMAIL } from './EVENT_ADMIN_SEND_CONFIRMATION_EMAIL' export { EVENT_ADMIN_USER_DELETE } from './EVENT_ADMIN_USER_DELETE'
export { EVENT_ADMIN_USER_UNDELETE } from './EVENT_ADMIN_USER_UNDELETE'
export { EVENT_ADMIN_USER_ROLE_SET } from './EVENT_ADMIN_USER_ROLE_SET'
export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE' export { EVENT_CONTRIBUTION_CREATE } from './EVENT_CONTRIBUTION_CREATE'
export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE' export { EVENT_CONTRIBUTION_DELETE } from './EVENT_CONTRIBUTION_DELETE'
export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE' export { EVENT_CONTRIBUTION_UPDATE } from './EVENT_CONTRIBUTION_UPDATE'
export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE' export { EVENT_CONTRIBUTION_MESSAGE_CREATE } from './EVENT_CONTRIBUTION_MESSAGE_CREATE'
export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM' export { EVENT_CONTRIBUTION_LINK_REDEEM } from './EVENT_CONTRIBUTION_LINK_REDEEM'
export { EVENT_LOGIN } from './EVENT_LOGIN' export { EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION } from './EVENT_EMAIL_ACCOUNT_MULTIREGISTRATION'
export { EVENT_REGISTER } from './EVENT_REGISTER' export { EVENT_EMAIL_ADMIN_CONFIRMATION } from './EVENT_EMAIL_ADMIN_CONFIRMATION'
export { EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL } from './EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL' export { EVENT_EMAIL_CONFIRMATION } from './EVENT_EMAIL_CONFIRMATION'
export { EVENT_SEND_CONFIRMATION_EMAIL } from './EVENT_SEND_CONFIRMATION_EMAIL' export { EVENT_EMAIL_FORGOT_PASSWORD } from './EVENT_EMAIL_FORGOT_PASSWORD'
export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND' export { EVENT_TRANSACTION_SEND } from './EVENT_TRANSACTION_SEND'
export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE' export { EVENT_TRANSACTION_RECEIVE } from './EVENT_TRANSACTION_RECEIVE'
export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE' export { EVENT_TRANSACTION_LINK_CREATE } from './EVENT_TRANSACTION_LINK_CREATE'
export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE' export { EVENT_TRANSACTION_LINK_DELETE } from './EVENT_TRANSACTION_LINK_DELETE'
export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM' export { EVENT_TRANSACTION_LINK_REDEEM } from './EVENT_TRANSACTION_LINK_REDEEM'
export { EVENT_USER_ACTIVATE_ACCOUNT } from './EVENT_USER_ACTIVATE_ACCOUNT'
export { EVENT_USER_INFO_UPDATE } from './EVENT_USER_INFO_UPDATE'
export { EVENT_USER_LOGIN } from './EVENT_USER_LOGIN'
export { EVENT_USER_LOGOUT } from './EVENT_USER_LOGOUT'
export { EVENT_USER_REGISTER } from './EVENT_USER_REGISTER'

View File

@ -1,5 +1,4 @@
export enum EventType { export enum EventType {
ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT',
// TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM', // TODO CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM',
ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM', ADMIN_CONTRIBUTION_CONFIRM = 'ADMIN_CONTRIBUTION_CONFIRM',
ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE', ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE',
@ -10,28 +9,34 @@ export enum EventType {
ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE', ADMIN_CONTRIBUTION_LINK_DELETE = 'ADMIN_CONTRIBUTION_LINK_DELETE',
ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE', ADMIN_CONTRIBUTION_LINK_UPDATE = 'ADMIN_CONTRIBUTION_LINK_UPDATE',
ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE', ADMIN_CONTRIBUTION_MESSAGE_CREATE = 'ADMIN_CONTRIBUTION_MESSAGE_CREATE',
ADMIN_SEND_CONFIRMATION_EMAIL = 'ADMIN_SEND_CONFIRMATION_EMAIL', ADMIN_USER_DELETE = 'ADMIN_USER_DELETE',
ADMIN_USER_UNDELETE = 'ADMIN_USER_UNDELETE',
ADMIN_USER_ROLE_SET = 'ADMIN_USER_ROLE_SET',
CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE',
CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE',
CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE',
CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE', CONTRIBUTION_MESSAGE_CREATE = 'CONTRIBUTION_MESSAGE_CREATE',
CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM', CONTRIBUTION_LINK_REDEEM = 'CONTRIBUTION_LINK_REDEEM',
LOGIN = 'LOGIN', EMAIL_ACCOUNT_MULTIREGISTRATION = 'EMAIL_ACCOUNT_MULTIREGISTRATION',
REGISTER = 'REGISTER', EMAIL_ADMIN_CONFIRMATION = 'EMAIL_ADMIN_CONFIRMATION',
REDEEM_REGISTER = 'REDEEM_REGISTER', EMAIL_CONFIRMATION = 'EMAIL_CONFIRMATION',
SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', EMAIL_FORGOT_PASSWORD = 'EMAIL_FORGOT_PASSWORD',
SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL',
TRANSACTION_SEND = 'TRANSACTION_SEND', TRANSACTION_SEND = 'TRANSACTION_SEND',
TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE',
TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE', TRANSACTION_LINK_CREATE = 'TRANSACTION_LINK_CREATE',
TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE', TRANSACTION_LINK_DELETE = 'TRANSACTION_LINK_DELETE',
TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM', TRANSACTION_LINK_REDEEM = 'TRANSACTION_LINK_REDEEM',
USER_ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT',
USER_INFO_UPDATE = 'USER_INFO_UPDATE',
USER_LOGIN = 'USER_LOGIN',
USER_LOGOUT = 'USER_LOGOUT',
USER_REGISTER = 'USER_REGISTER',
USER_REGISTER_REDEEM = 'USER_REGISTER_REDEEM',
// VISIT_GRADIDO = 'VISIT_GRADIDO', // VISIT_GRADIDO = 'VISIT_GRADIDO',
// VERIFY_REDEEM = 'VERIFY_REDEEM', // VERIFY_REDEEM = 'VERIFY_REDEEM',
// INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT',
// CONFIRM_EMAIL = 'CONFIRM_EMAIL', // CONFIRM_EMAIL = 'CONFIRM_EMAIL',
// REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', // REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP',
// LOGOUT = 'LOGOUT',
// REDEEM_LOGIN = 'REDEEM_LOGIN', // REDEEM_LOGIN = 'REDEEM_LOGIN',
// SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', // SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL',
// PASSWORD_CHANGE = 'PASSWORD_CHANGE', // PASSWORD_CHANGE = 'PASSWORD_CHANGE',

View File

@ -1,11 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { gql } from 'graphql-request'
import { backendLogger as logger } from '@/server/logger'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'
import { GraphQLGetClient } from '../GraphQLGetClient' import { gql } from 'graphql-request'
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> { export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/' let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/'

View File

@ -1,11 +1,12 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { gql } from 'graphql-request'
import { backendLogger as logger } from '@/server/logger'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'
import { GraphQLGetClient } from '../GraphQLGetClient' import { gql } from 'graphql-request'
import { GraphQLGetClient } from '@/federation/client/GraphQLGetClient'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> { export async function requestGetPublicKey(dbCom: DbCommunity): Promise<string | undefined> {
let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/' let endpoint = dbCom.endPoint.endsWith('/') ? dbCom.endPoint : dbCom.endPoint + '/'

View File

@ -5,9 +5,11 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { logger } from '@test/testSetup'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'
import { testEnvironment, cleanDB } from '@test/helpers' import { testEnvironment, cleanDB } from '@test/helpers'
import { logger } from '@test/testSetup'
import { validateCommunities } from './validateCommunities' import { validateCommunities } from './validateCommunities'
let con: any let con: any

View File

@ -1,12 +1,14 @@
import { Community as DbCommunity } from '@entity/Community'
import { IsNull } from '@dbTools/typeorm' import { IsNull } from '@dbTools/typeorm'
import { Community as DbCommunity } from '@entity/Community'
import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient' import { requestGetPublicKey as v1_0_requestGetPublicKey } from './client/1_0/FederationClient'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient' import { requestGetPublicKey as v1_1_requestGetPublicKey } from './client/1_1/FederationClient'
import { backendLogger as logger } from '@/server/logger'
import { ApiVersionType } from './enum/apiVersionType' import { ApiVersionType } from './enum/apiVersionType'
import LogError from '@/server/LogError'
export function startValidateCommunities(timerInterval: number): void { export function startValidateCommunities(timerInterval: number): void {
logger.info( logger.info(

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, InputType } from 'type-graphql' import { ArgsType, Field, InputType } from 'type-graphql'
import Decimal from 'decimal.js-light'
@InputType() @InputType()
@ArgsType() @ArgsType()

View File

@ -1,14 +1,11 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, Int } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ArgsType() @ArgsType()
export default class AdminUpdateContributionArgs { export default class AdminUpdateContributionArgs {
@Field(() => Int) @Field(() => Int)
id: number id: number
@Field(() => String)
email: string
@Field(() => Decimal) @Field(() => Decimal)
amount: Decimal amount: Decimal

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, InputType } from 'type-graphql' import { ArgsType, Field, InputType } from 'type-graphql'
import Decimal from 'decimal.js-light'
@InputType() @InputType()
@ArgsType() @ArgsType()

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field, Int } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ArgsType() @ArgsType()
export default class ContributionLinkArgs { export default class ContributionLinkArgs {

View File

@ -1,5 +1,6 @@
/* eslint-disable type-graphql/invalid-nullable-input-type */ /* eslint-disable type-graphql/invalid-nullable-input-type */
import { ArgsType, Field, Int } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
import { Order } from '@enum/Order' import { Order } from '@enum/Order'
@ArgsType() @ArgsType()

View File

@ -1,4 +1,5 @@
import { ArgsType, Field, Int } from 'type-graphql' import { ArgsType, Field, Int } from 'type-graphql'
import SearchUsersFilters from '@arg/SearchUsersFilters' import SearchUsersFilters from '@arg/SearchUsersFilters'
@ArgsType() @ArgsType()

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field } from 'type-graphql' import { ArgsType, Field } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ArgsType() @ArgsType()
export default class TransactionLinkArgs { export default class TransactionLinkArgs {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ArgsType, Field } from 'type-graphql' import { ArgsType, Field } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ArgsType() @ArgsType()
export default class TransactionSendArgs { export default class TransactionSendArgs {

View File

@ -2,13 +2,13 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { User } from '@entity/User'
import { AuthChecker } from 'type-graphql' import { AuthChecker } from 'type-graphql'
import { decode, encode } from '@/auth/JWT'
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES'
import { RIGHTS } from '@/auth/RIGHTS'
import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS' import { INALIENABLE_RIGHTS } from '@/auth/INALIENABLE_RIGHTS'
import { User } from '@entity/User' import { decode, encode } from '@/auth/JWT'
import { RIGHTS } from '@/auth/RIGHTS'
import { ROLE_UNAUTHORIZED, ROLE_USER, ROLE_ADMIN } from '@/auth/ROLES'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
const isAuthorized: AuthChecker<any> = async ({ context }, rights) => { const isAuthorized: AuthChecker<any> = async ({ context }, rights) => {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ObjectType() @ObjectType()
export class AdminUpdateContribution { export class AdminUpdateContribution {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int, Float } from 'type-graphql' import { ObjectType, Field, Int, Float } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ObjectType() @ObjectType()
export class Balance { export class Balance {

View File

@ -1,5 +1,5 @@
import { ObjectType, Field, Int } from 'type-graphql'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class Community { export class Community {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ObjectType() @ObjectType()
export class DynamicStatisticsFields { export class DynamicStatisticsFields {

View File

@ -1,7 +1,7 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
import { Contribution as dbContribution } from '@entity/Contribution' import { Contribution as dbContribution } from '@entity/Contribution'
import { User } from '@entity/User' import { User } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class Contribution { export class Contribution {
@ -21,6 +21,8 @@ export class Contribution {
this.deniedBy = contribution.deniedBy this.deniedBy = contribution.deniedBy
this.deletedAt = contribution.deletedAt this.deletedAt = contribution.deletedAt
this.deletedBy = contribution.deletedBy this.deletedBy = contribution.deletedBy
this.moderatorId = contribution.moderatorId
this.userId = contribution.userId
} }
@Field(() => Int) @Field(() => Int)
@ -67,6 +69,12 @@ export class Contribution {
@Field(() => String) @Field(() => String)
state: string state: string
@Field(() => Int, { nullable: true })
moderatorId: number | null
@Field(() => Int, { nullable: true })
userId: number | null
} }
@ObjectType() @ObjectType()

View File

@ -1,6 +1,7 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
import { ContributionLink as dbContributionLink } from '@entity/ContributionLink' import { ContributionLink as dbContributionLink } from '@entity/ContributionLink'
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
import CONFIG from '@/config' import CONFIG from '@/config'
@ObjectType() @ObjectType()

View File

@ -1,4 +1,5 @@
import { ObjectType, Field, Int } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import { ContributionLink } from '@model/ContributionLink' import { ContributionLink } from '@model/ContributionLink'
@ObjectType() @ObjectType()

View File

@ -1,6 +1,6 @@
import { Field, Int, ObjectType } from 'type-graphql'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { User } from '@entity/User' import { User } from '@entity/User'
import { Field, Int, ObjectType } from 'type-graphql'
@ObjectType() @ObjectType()
export class ContributionMessage { export class ContributionMessage {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
interface DecayInterface { interface DecayInterface {
balance: Decimal balance: Decimal

View File

@ -3,6 +3,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ObjectType, Field, Float, Int } from 'type-graphql' import { ObjectType, Field, Float, Int } from 'type-graphql'
import { GdtEntryType } from '@enum/GdtEntryType' import { GdtEntryType } from '@enum/GdtEntryType'
@ObjectType() @ObjectType()

View File

@ -3,9 +3,10 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { GdtEntry } from './GdtEntry'
import { ObjectType, Field, Int, Float } from 'type-graphql' import { ObjectType, Field, Int, Float } from 'type-graphql'
import { GdtEntry } from './GdtEntry'
@ObjectType() @ObjectType()
export class GdtEntryList { export class GdtEntryList {
constructor(json: any) { constructor(json: any) {

View File

@ -1,5 +1,5 @@
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql' import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
@ObjectType() @ObjectType()
export class OpenCreation { export class OpenCreation {

View File

@ -1,8 +1,10 @@
import { ObjectType, Field, Int } from 'type-graphql'
import { Decay } from './Decay'
import { Transaction as dbTransaction } from '@entity/Transaction' import { Transaction as dbTransaction } from '@entity/Transaction'
import Decimal from 'decimal.js-light' import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
import { TransactionTypeId } from '@enum/TransactionTypeId' import { TransactionTypeId } from '@enum/TransactionTypeId'
import { Decay } from './Decay'
import { User } from './User' import { User } from './User'
@ObjectType() @ObjectType()

View File

@ -1,9 +1,11 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
import { User } from './User' import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
import CONFIG from '@/config' import CONFIG from '@/config'
import { User } from './User'
@ObjectType() @ObjectType()
export class TransactionLink { export class TransactionLink {
constructor(transactionLink: dbTransactionLink, user: User, redeemedBy: User | null = null) { constructor(transactionLink: dbTransactionLink, user: User, redeemedBy: User | null = null) {

View File

@ -1,6 +1,7 @@
import { ObjectType, Field } from 'type-graphql' import { ObjectType, Field } from 'type-graphql'
import { Transaction } from './Transaction'
import { Balance } from './Balance' import { Balance } from './Balance'
import { Transaction } from './Transaction'
@ObjectType() @ObjectType()
export class TransactionList { export class TransactionList {

View File

@ -1,7 +1,7 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
import { Contribution } from '@entity/Contribution' import { Contribution } from '@entity/Contribution'
import { User } from '@entity/User' import { User } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class UnconfirmedContribution { export class UnconfirmedContribution {

View File

@ -1,6 +1,7 @@
import { ObjectType, Field, Int } from 'type-graphql'
import { KlickTipp } from './KlickTipp'
import { User as dbUser } from '@entity/User' import { User as dbUser } from '@entity/User'
import { ObjectType, Field, Int } from 'type-graphql'
import { KlickTipp } from './KlickTipp'
import { UserContact } from './UserContact' import { UserContact } from './UserContact'
@ObjectType() @ObjectType()

View File

@ -1,6 +1,6 @@
import { ObjectType, Field, Int } from 'type-graphql'
import Decimal from 'decimal.js-light'
import { User } from '@entity/User' import { User } from '@entity/User'
import { Decimal } from 'decimal.js-light'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class UserAdmin { export class UserAdmin {

View File

@ -1,5 +1,5 @@
import { ObjectType, Field, Int } from 'type-graphql'
import { UserContact as dbUserContact } from '@entity/UserContact' import { UserContact as dbUserContact } from '@entity/UserContact'
import { ObjectType, Field, Int } from 'type-graphql'
@ObjectType() @ObjectType()
export class UserContact { export class UserContact {

View File

@ -1,21 +1,19 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
import Decimal from 'decimal.js-light'
import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
import { getCustomRepository } from '@dbTools/typeorm' import { getCustomRepository } from '@dbTools/typeorm'
import { Transaction as dbTransaction } from '@entity/Transaction' import { Transaction as dbTransaction } from '@entity/Transaction'
import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink' import { TransactionLink as dbTransactionLink } from '@entity/TransactionLink'
import { Decimal } from 'decimal.js-light'
import { TransactionLinkRepository } from '@repository/TransactionLink' import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
import { Balance } from '@model/Balance' import { Balance } from '@model/Balance'
import { TransactionLinkRepository } from '@repository/TransactionLink'
import { backendLogger as logger } from '@/server/logger'
import { Context, getUser } from '@/server/context'
import { calculateDecay } from '@/util/decay'
import { RIGHTS } from '@/auth/RIGHTS' import { RIGHTS } from '@/auth/RIGHTS'
import { GdtResolver } from './GdtResolver' import { Context, getUser } from '@/server/context'
import { backendLogger as logger } from '@/server/logger'
import { calculateDecay } from '@/util/decay'
import { GdtResolver } from './GdtResolver'
import { getLastTransaction } from './util/getLastTransaction' import { getLastTransaction } from './util/getLastTransaction'
@Resolver() @Resolver()

View File

@ -5,10 +5,12 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { getCommunities } from '@/seeds/graphql/queries'
import { Community as DbCommunity } from '@entity/Community' import { Community as DbCommunity } from '@entity/Community'
import { testEnvironment } from '@test/helpers' import { testEnvironment } from '@test/helpers'
import { getCommunities } from '@/seeds/graphql/queries'
let query: any let query: any
// to do: We need a setup for the tests that closes the connection // to do: We need a setup for the tests that closes the connection

View File

@ -1,7 +1,7 @@
import { Community as DbCommunity } from '@entity/Community'
import { Resolver, Query, Authorized } from 'type-graphql' import { Resolver, Query, Authorized } from 'type-graphql'
import { Community } from '@model/Community' import { Community } from '@model/Community'
import { Community as DbCommunity } from '@entity/Community'
import { RIGHTS } from '@/auth/RIGHTS' import { RIGHTS } from '@/auth/RIGHTS'

View File

@ -4,9 +4,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import Decimal from 'decimal.js-light' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { logger } from '@test/testSetup' import { Event as DbEvent } from '@entity/Event'
import { Decimal } from 'decimal.js-light'
import { GraphQLError } from 'graphql' import { GraphQLError } from 'graphql'
import { cleanDB, testEnvironment, resetToken } from '@test/helpers'
import { logger } from '@test/testSetup'
import { EventType } from '@/event/Event'
import { userFactory } from '@/seeds/factory/user'
import { import {
login, login,
createContributionLink, createContributionLink,
@ -14,13 +21,8 @@ import {
updateContributionLink, updateContributionLink,
} from '@/seeds/graphql/mutations' } from '@/seeds/graphql/mutations'
import { listContributionLinks } from '@/seeds/graphql/queries' import { listContributionLinks } from '@/seeds/graphql/queries'
import { cleanDB, testEnvironment, resetToken } from '@test/helpers'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { peterLustig } from '@/seeds/users/peter-lustig' import { peterLustig } from '@/seeds/users/peter-lustig'
import { userFactory } from '@/seeds/factory/user'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { EventType } from '@/event/Event'
import { Event as DbEvent } from '@entity/Event'
let mutate: any, query: any, con: any let mutate: any, query: any, con: any
let testEnv: any let testEnv: any

View File

@ -1,6 +1,23 @@
import Decimal from 'decimal.js-light'
import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql'
import { MoreThan, IsNull } from '@dbTools/typeorm' import { MoreThan, IsNull } from '@dbTools/typeorm'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Decimal } from 'decimal.js-light'
import { Resolver, Args, Arg, Authorized, Mutation, Query, Int, Ctx } from 'type-graphql'
// TODO: this is a strange construct
import ContributionLinkArgs from '@arg/ContributionLinkArgs'
import Paginated from '@arg/Paginated'
import { Order } from '@enum/Order'
import { ContributionLink } from '@model/ContributionLink'
import { ContributionLinkList } from '@model/ContributionLinkList'
import { RIGHTS } from '@/auth/RIGHTS'
import {
EVENT_ADMIN_CONTRIBUTION_LINK_CREATE,
EVENT_ADMIN_CONTRIBUTION_LINK_DELETE,
EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE,
} from '@/event/Event'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
import { import {
CONTRIBUTIONLINK_NAME_MAX_CHARS, CONTRIBUTIONLINK_NAME_MAX_CHARS,
@ -8,24 +25,8 @@ import {
MEMO_MAX_CHARS, MEMO_MAX_CHARS,
MEMO_MIN_CHARS, MEMO_MIN_CHARS,
} from './const/const' } from './const/const'
import { isStartEndDateValid } from './util/creations'
import { ContributionLinkList } from '@model/ContributionLinkList'
import { ContributionLink } from '@model/ContributionLink'
import ContributionLinkArgs from '@arg/ContributionLinkArgs'
import { RIGHTS } from '@/auth/RIGHTS'
import { ContributionLink as DbContributionLink } from '@entity/ContributionLink'
import { Order } from '@enum/Order'
import Paginated from '@arg/Paginated'
// TODO: this is a strange construct
import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver' import { transactionLinkCode as contributionLinkCode } from './TransactionLinkResolver'
import LogError from '@/server/LogError' import { isStartEndDateValid } from './util/creations'
import { Context, getUser } from '@/server/context'
import {
EVENT_ADMIN_CONTRIBUTION_LINK_CREATE,
EVENT_ADMIN_CONTRIBUTION_LINK_DELETE,
EVENT_ADMIN_CONTRIBUTION_LINK_UPDATE,
} from '@/event/Event'
@Resolver() @Resolver()
export class ContributionLinkResolver { export class ContributionLinkResolver {

View File

@ -6,9 +6,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { Event as DbEvent } from '@entity/Event'
import { GraphQLError } from 'graphql'
import { cleanDB, resetToken, testEnvironment } from '@test/helpers' import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup' import { logger, i18n as localization } from '@test/testSetup'
import { GraphQLError } from 'graphql'
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { userFactory } from '@/seeds/factory/user'
import { import {
adminCreateContributionMessage, adminCreateContributionMessage,
createContribution, createContribution,
@ -16,12 +22,8 @@ import {
login, login,
} from '@/seeds/graphql/mutations' } from '@/seeds/graphql/mutations'
import { listContributionMessages } from '@/seeds/graphql/queries' import { listContributionMessages } from '@/seeds/graphql/queries'
import { userFactory } from '@/seeds/factory/user'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { peterLustig } from '@/seeds/users/peter-lustig' import { peterLustig } from '@/seeds/users/peter-lustig'
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { Event as DbEvent } from '@entity/Event'
jest.mock('@/emails/sendEmailVariants', () => { jest.mock('@/emails/sendEmailVariants', () => {
const originalModule = jest.requireActual('@/emails/sendEmailVariants') const originalModule = jest.requireActual('@/emails/sendEmailVariants')

View File

@ -1,27 +1,26 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import { getConnection } from '@dbTools/typeorm' import { getConnection } from '@dbTools/typeorm'
import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { UserContact as DbUserContact } from '@entity/UserContact' import { ContributionMessage as DbContributionMessage } from '@entity/ContributionMessage'
import { User as DbUser } from '@entity/User' import { User as DbUser } from '@entity/User'
import { UserContact as DbUserContact } from '@entity/UserContact'
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage'
import ContributionMessageArgs from '@arg/ContributionMessageArgs' import ContributionMessageArgs from '@arg/ContributionMessageArgs'
import { ContributionMessageType } from '@enum/MessageType'
import { ContributionStatus } from '@enum/ContributionStatus'
import { Order } from '@enum/Order'
import Paginated from '@arg/Paginated' import Paginated from '@arg/Paginated'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionMessageType } from '@enum/MessageType'
import { Order } from '@enum/Order'
import { ContributionMessage, ContributionMessageListResult } from '@model/ContributionMessage'
import { RIGHTS } from '@/auth/RIGHTS' import { RIGHTS } from '@/auth/RIGHTS'
import { Context, getUser } from '@/server/context'
import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants' import { sendAddedContributionMessageEmail } from '@/emails/sendEmailVariants'
import LogError from '@/server/LogError'
import { import {
EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE, EVENT_ADMIN_CONTRIBUTION_MESSAGE_CREATE,
EVENT_CONTRIBUTION_MESSAGE_CREATE, EVENT_CONTRIBUTION_MESSAGE_CREATE,
} from '@/event/Event' } from '@/event/Event'
import { Context, getUser } from '@/server/context'
import LogError from '@/server/LogError'
@Resolver() @Resolver()
export class ContributionMessageResolver { export class ContributionMessageResolver {

View File

@ -6,11 +6,36 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import Decimal from 'decimal.js-light' import { Contribution } from '@entity/Contribution'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { Event as DbEvent } from '@entity/Event'
import { bobBaumeister } from '@/seeds/users/bob-baumeister' import { Transaction as DbTransaction } from '@entity/Transaction'
import { stephenHawking } from '@/seeds/users/stephen-hawking' import { User } from '@entity/User'
import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { UserInputError } from 'apollo-server-express'
import { Decimal } from 'decimal.js-light'
import { GraphQLError } from 'graphql'
import { ContributionStatus } from '@enum/ContributionStatus'
import { Order } from '@enum/Order'
import { ContributionListResult } from '@model/Contribution'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import {
cleanDB,
resetToken,
testEnvironment,
contributionDateFormatter,
resetEntity,
} from '@test/helpers'
import { logger, i18n as localization } from '@test/testSetup'
import {
sendContributionConfirmedEmail,
sendContributionDeletedEmail,
sendContributionDeniedEmail,
} from '@/emails/sendEmailVariants'
import { EventType } from '@/event/Event'
import { creations } from '@/seeds/creation/index'
import { creationFactory } from '@/seeds/factory/creation'
import { userFactory } from '@/seeds/factory/user'
import { import {
createContribution, createContribution,
updateContribution, updateContribution,
@ -29,35 +54,12 @@ import {
listContributions, listContributions,
adminListContributions, adminListContributions,
} from '@/seeds/graphql/queries' } from '@/seeds/graphql/queries'
import { import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
sendContributionConfirmedEmail, import { bobBaumeister } from '@/seeds/users/bob-baumeister'
sendContributionDeletedEmail, import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
sendContributionDeniedEmail,
} from '@/emails/sendEmailVariants'
import {
cleanDB,
resetToken,
testEnvironment,
contributionDateFormatter,
resetEntity,
} from '@test/helpers'
import { GraphQLError } from 'graphql'
import { userFactory } from '@/seeds/factory/user'
import { creationFactory } from '@/seeds/factory/creation'
import { creations } from '@/seeds/creation/index'
import { peterLustig } from '@/seeds/users/peter-lustig' import { peterLustig } from '@/seeds/users/peter-lustig'
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/Event'
import { logger, i18n as localization } from '@test/testSetup'
import { UserInputError } from 'apollo-server-express'
import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz' import { raeuberHotzenplotz } from '@/seeds/users/raeuber-hotzenplotz'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { stephenHawking } from '@/seeds/users/stephen-hawking'
import { ContributionListResult } from '@model/Contribution'
import { ContributionStatus } from '@enum/ContributionStatus'
import { Order } from '@enum/Order'
jest.mock('@/emails/sendEmailVariants') jest.mock('@/emails/sendEmailVariants')
@ -435,7 +437,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: pendingContribution.data.createContribution.id, id: pendingContribution.data.createContribution.id,
email: 'bibi@bloxberg.de',
amount: 10.0, amount: 10.0,
memo: 'Test env contribution', memo: 'Test env contribution',
creationDate: new Date().toString(), creationDate: new Date().toString(),
@ -1670,7 +1671,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: 1, id: 1,
email: 'bibi@bloxberg.de',
amount: new Decimal(300), amount: new Decimal(300),
memo: 'Danke Bibi!', memo: 'Danke Bibi!',
creationDate: contributionDateFormatter(new Date()), creationDate: contributionDateFormatter(new Date()),
@ -1749,7 +1749,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: 1, id: 1,
email: 'bibi@bloxberg.de',
amount: new Decimal(300), amount: new Decimal(300),
memo: 'Danke Bibi!', memo: 'Danke Bibi!',
creationDate: contributionDateFormatter(new Date()), creationDate: contributionDateFormatter(new Date()),
@ -2043,6 +2042,50 @@ describe('ContributionResolver', () => {
}), }),
) )
}) })
describe('user tries to update admin contribution', () => {
beforeAll(async () => {
await mutate({
mutation: login,
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
})
})
afterAll(async () => {
await mutate({
mutation: login,
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
})
})
it('logs and throws "Cannot update contribution of moderator" error', async () => {
jest.clearAllMocks()
const adminContribution = await Contribution.findOne({
where: {
moderatorId: admin.id,
userId: bibi.id,
},
})
await expect(
mutate({
mutation: updateContribution,
variables: {
contributionId: (adminContribution && adminContribution.id) || -1,
amount: 100.0,
memo: 'Test Test Test',
creationDate: new Date().toString(),
},
}),
).resolves.toMatchObject({
errors: [new GraphQLError('Cannot update contribution of moderator')],
})
expect(logger.error).toBeCalledWith(
'Cannot update contribution of moderator',
expect.any(Object),
bibi.id,
)
})
})
}) })
describe('second creation surpasses the available amount ', () => { describe('second creation surpasses the available amount ', () => {
@ -2080,58 +2123,6 @@ describe('ContributionResolver', () => {
// stephen@hawking.uk: [1000, 1000, 1000] - deleted // stephen@hawking.uk: [1000, 1000, 1000] - deleted
// garrick@ollivander.com: [1000, 1000, 1000] - not activated // garrick@ollivander.com: [1000, 1000, 1000] - not activated
describe('user for creation to update does not exist', () => {
it('throws an error', async () => {
jest.clearAllMocks()
await expect(
mutate({
mutation: adminUpdateContribution,
variables: {
id: 1,
email: 'bob@baumeister.de',
amount: new Decimal(300),
memo: 'Danke Bibi!',
creationDate: contributionDateFormatter(new Date()),
},
}),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('Could not find User')],
}),
)
})
it('logs the error "Could not find User"', () => {
expect(logger.error).toBeCalledWith('Could not find User', 'bob@baumeister.de')
})
})
describe('user for creation to update is deleted', () => {
it('throws an error', async () => {
jest.clearAllMocks()
await expect(
mutate({
mutation: adminUpdateContribution,
variables: {
id: 1,
email: 'stephen@hawking.uk',
amount: new Decimal(300),
memo: 'Danke Bibi!',
creationDate: contributionDateFormatter(new Date()),
},
}),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('User was deleted')],
}),
)
})
it('logs the error "User was deleted"', () => {
expect(logger.error).toBeCalledWith('User was deleted', 'stephen@hawking.uk')
})
})
describe('creation does not exist', () => { describe('creation does not exist', () => {
it('throws an error', async () => { it('throws an error', async () => {
jest.clearAllMocks() jest.clearAllMocks()
@ -2140,7 +2131,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: -1, id: -1,
email: 'bibi@bloxberg.de',
amount: new Decimal(300), amount: new Decimal(300),
memo: 'Danke Bibi!', memo: 'Danke Bibi!',
creationDate: contributionDateFormatter(new Date()), creationDate: contributionDateFormatter(new Date()),
@ -2158,40 +2148,6 @@ describe('ContributionResolver', () => {
}) })
}) })
describe('user email does not match creation user', () => {
it('throws an error', async () => {
jest.clearAllMocks()
await expect(
mutate({
mutation: adminUpdateContribution,
variables: {
id: creation ? creation.id : -1,
email: 'bibi@bloxberg.de',
amount: new Decimal(300),
memo: 'Danke Bibi!',
creationDate: creation
? contributionDateFormatter(creation.contributionDate)
: contributionDateFormatter(new Date()),
},
}),
).resolves.toEqual(
expect.objectContaining({
errors: [
new GraphQLError(
'User of the pending contribution and send user does not correspond',
),
],
}),
)
})
it('logs the error "User of the pending contribution and send user does not correspond"', () => {
expect(logger.error).toBeCalledWith(
'User of the pending contribution and send user does not correspond',
)
})
})
describe('creation update is not valid', () => { describe('creation update is not valid', () => {
// as this test has not clearly defined that date, it is a false positive // as this test has not clearly defined that date, it is a false positive
it('throws an error', async () => { it('throws an error', async () => {
@ -2201,7 +2157,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: creation ? creation.id : -1, id: creation ? creation.id : -1,
email: 'peter@lustig.de',
amount: new Decimal(1900), amount: new Decimal(1900),
memo: 'Danke Peter!', memo: 'Danke Peter!',
creationDate: creation creationDate: creation
@ -2238,7 +2193,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: creation?.id, id: creation?.id,
email: 'peter@lustig.de',
amount: new Decimal(300), amount: new Decimal(300),
memo: 'Danke Peter!', memo: 'Danke Peter!',
creationDate: creation creationDate: creation
@ -2253,7 +2207,6 @@ describe('ContributionResolver', () => {
date: expect.any(String), date: expect.any(String),
memo: 'Danke Peter!', memo: 'Danke Peter!',
amount: '300', amount: '300',
creation: ['1000', '700', '500'],
}, },
}, },
}), }),
@ -2280,7 +2233,6 @@ describe('ContributionResolver', () => {
mutation: adminUpdateContribution, mutation: adminUpdateContribution,
variables: { variables: {
id: creation?.id, id: creation?.id,
email: 'peter@lustig.de',
amount: new Decimal(200), amount: new Decimal(200),
memo: 'Das war leider zu Viel!', memo: 'Das war leider zu Viel!',
creationDate: creation creationDate: creation
@ -2295,7 +2247,6 @@ describe('ContributionResolver', () => {
date: expect.any(String), date: expect.any(String),
memo: 'Das war leider zu Viel!', memo: 'Das war leider zu Viel!',
amount: '200', amount: '200',
creation: ['1000', '800', '1000'],
}, },
}, },
}), }),
@ -2578,10 +2529,10 @@ describe('ContributionResolver', () => {
}) })
}) })
it('stores the SEND_CONFIRMATION_EMAIL event in the database', async () => { it('stores the EMAIL_CONFIRMATION event in the database', async () => {
await expect(DbEvent.find()).resolves.toContainEqual( await expect(DbEvent.find()).resolves.toContainEqual(
expect.objectContaining({ expect.objectContaining({
type: EventType.SEND_CONFIRMATION_EMAIL, type: EventType.EMAIL_CONFIRMATION,
}), }),
) )
}) })

View File

@ -1,40 +1,34 @@
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
import Decimal from 'decimal.js-light'
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import { IsNull, getConnection } from '@dbTools/typeorm' import { IsNull, getConnection } from '@dbTools/typeorm'
import { Contribution as DbContribution } from '@entity/Contribution' import { Contribution as DbContribution } from '@entity/Contribution'
import { ContributionMessage } from '@entity/ContributionMessage' import { ContributionMessage } from '@entity/ContributionMessage'
import { UserContact } from '@entity/UserContact'
import { User as DbUser } from '@entity/User'
import { Transaction as DbTransaction } from '@entity/Transaction' import { Transaction as DbTransaction } from '@entity/Transaction'
import { User as DbUser } from '@entity/User'
import { UserContact } from '@entity/UserContact'
import { Decimal } from 'decimal.js-light'
import { Arg, Args, Authorized, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'
import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs'
import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs'
import ContributionArgs from '@arg/ContributionArgs'
import Paginated from '@arg/Paginated'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionType } from '@enum/ContributionType'
import { ContributionMessageType } from '@enum/MessageType'
import { Order } from '@enum/Order'
import { TransactionTypeId } from '@enum/TransactionTypeId'
import { AdminUpdateContribution } from '@model/AdminUpdateContribution' import { AdminUpdateContribution } from '@model/AdminUpdateContribution'
import { Contribution, ContributionListResult } from '@model/Contribution' import { Contribution, ContributionListResult } from '@model/Contribution'
import { Decay } from '@model/Decay' import { Decay } from '@model/Decay'
import { OpenCreation } from '@model/OpenCreation' import { OpenCreation } from '@model/OpenCreation'
import { UnconfirmedContribution } from '@model/UnconfirmedContribution' import { UnconfirmedContribution } from '@model/UnconfirmedContribution'
import { TransactionTypeId } from '@enum/TransactionTypeId'
import { Order } from '@enum/Order'
import { ContributionType } from '@enum/ContributionType'
import { ContributionStatus } from '@enum/ContributionStatus'
import { ContributionMessageType } from '@enum/MessageType'
import ContributionArgs from '@arg/ContributionArgs'
import Paginated from '@arg/Paginated'
import AdminCreateContributionArgs from '@arg/AdminCreateContributionArgs'
import AdminUpdateContributionArgs from '@arg/AdminUpdateContributionArgs'
import { RIGHTS } from '@/auth/RIGHTS' import { RIGHTS } from '@/auth/RIGHTS'
import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import { backendLogger as logger } from '@/server/logger'
import { import {
getUserCreation, sendContributionConfirmedEmail,
validateContribution, sendContributionDeletedEmail,
updateCreations, sendContributionDeniedEmail,
isValidDateString, } from '@/emails/sendEmailVariants'
getOpenCreations,
} from './util/creations'
import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
import { import {
EVENT_CONTRIBUTION_CREATE, EVENT_CONTRIBUTION_CREATE,
EVENT_CONTRIBUTION_DELETE, EVENT_CONTRIBUTION_DELETE,
@ -45,17 +39,22 @@ import {
EVENT_ADMIN_CONTRIBUTION_CONFIRM, EVENT_ADMIN_CONTRIBUTION_CONFIRM,
EVENT_ADMIN_CONTRIBUTION_DENY, EVENT_ADMIN_CONTRIBUTION_DENY,
} from '@/event/Event' } from '@/event/Event'
import { calculateDecay } from '@/util/decay' import { Context, getUser, getClientTimezoneOffset } from '@/server/context'
import {
sendContributionConfirmedEmail,
sendContributionDeletedEmail,
sendContributionDeniedEmail,
} from '@/emails/sendEmailVariants'
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
import LogError from '@/server/LogError' import LogError from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
import { calculateDecay } from '@/util/decay'
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
import { getLastTransaction } from './util/getLastTransaction' import { MEMO_MAX_CHARS, MEMO_MIN_CHARS } from './const/const'
import {
getUserCreation,
validateContribution,
updateCreations,
isValidDateString,
getOpenCreations,
} from './util/creations'
import { findContributions } from './util/findContributions' import { findContributions } from './util/findContributions'
import { getLastTransaction } from './util/getLastTransaction'
@Resolver() @Resolver()
export class ContributionResolver { export class ContributionResolver {
@ -202,6 +201,9 @@ export class ContributionResolver {
user.id, user.id,
) )
} }
if (contributionToUpdate.moderatorId) {
throw new LogError('Cannot update contribution of moderator', contributionToUpdate, user.id)
}
if ( if (
contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS &&
contributionToUpdate.contributionStatus !== ContributionStatus.PENDING contributionToUpdate.contributionStatus !== ContributionStatus.PENDING
@ -307,41 +309,27 @@ export class ContributionResolver {
@Authorized([RIGHTS.ADMIN_UPDATE_CONTRIBUTION]) @Authorized([RIGHTS.ADMIN_UPDATE_CONTRIBUTION])
@Mutation(() => AdminUpdateContribution) @Mutation(() => AdminUpdateContribution)
async adminUpdateContribution( async adminUpdateContribution(
@Args() { id, email, amount, memo, creationDate }: AdminUpdateContributionArgs, @Args() { id, amount, memo, creationDate }: AdminUpdateContributionArgs,
@Ctx() context: Context, @Ctx() context: Context,
): Promise<AdminUpdateContribution> { ): Promise<AdminUpdateContribution> {
const clientTimezoneOffset = getClientTimezoneOffset(context) const clientTimezoneOffset = getClientTimezoneOffset(context)
const emailContact = await UserContact.findOne({
where: { email },
withDeleted: true,
relations: ['user'],
})
if (!emailContact || !emailContact.user) {
throw new LogError('Could not find User', email)
}
if (emailContact.deletedAt || emailContact.user.deletedAt) {
throw new LogError('User was deleted', email)
}
const moderator = getUser(context) const moderator = getUser(context)
const contributionToUpdate = await DbContribution.findOne({ const contributionToUpdate = await DbContribution.findOne({
where: { id, confirmedAt: IsNull(), deniedAt: IsNull() }, where: { id, confirmedAt: IsNull(), deniedAt: IsNull() },
}) })
if (!contributionToUpdate) { if (!contributionToUpdate) {
throw new LogError('Contribution not found', id) throw new LogError('Contribution not found', id)
} }
if (contributionToUpdate.userId !== emailContact.user.id) {
throw new LogError('User of the pending contribution and send user does not correspond')
}
if (contributionToUpdate.moderatorId === null) { if (contributionToUpdate.moderatorId === null) {
throw new LogError('An admin is not allowed to update an user contribution') throw new LogError('An admin is not allowed to update an user contribution')
} }
const creationDateObj = new Date(creationDate) const creationDateObj = new Date(creationDate)
let creations = await getUserCreation(emailContact.user.id, clientTimezoneOffset) let creations = await getUserCreation(contributionToUpdate.userId, clientTimezoneOffset)
// TODO: remove this restriction // TODO: remove this restriction
if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) {
@ -364,9 +352,9 @@ export class ContributionResolver {
result.amount = amount result.amount = amount
result.memo = contributionToUpdate.memo result.memo = contributionToUpdate.memo
result.date = contributionToUpdate.contributionDate result.date = contributionToUpdate.contributionDate
result.creation = await getUserCreation(emailContact.user.id, clientTimezoneOffset)
await EVENT_ADMIN_CONTRIBUTION_UPDATE( await EVENT_ADMIN_CONTRIBUTION_UPDATE(
emailContact.user, { id: contributionToUpdate.userId } as DbUser,
moderator, moderator,
contributionToUpdate, contributionToUpdate,
amount, amount,

View File

@ -4,12 +4,14 @@
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { testEnvironment, cleanDB } from '@test/helpers'
import { User as DbUser } from '@entity/User' import { User as DbUser } from '@entity/User'
import { GraphQLError } from 'graphql'
import { testEnvironment, cleanDB } from '@test/helpers'
import CONFIG from '@/config'
import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations' import { createUser, setPassword, forgotPassword } from '@/seeds/graphql/mutations'
import { queryOptIn } from '@/seeds/graphql/queries' import { queryOptIn } from '@/seeds/graphql/queries'
import CONFIG from '@/config'
import { GraphQLError } from 'graphql'
let mutate: any, query: any, con: any let mutate: any, query: any, con: any
let testEnv: any let testEnv: any

Some files were not shown because too many files have changed in this diff Show More