mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into fix-locales-nederlands
This commit is contained in:
commit
44a91950ac
@ -10,7 +10,7 @@ Decimal.set({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const constants = {
|
const constants = {
|
||||||
DB_VERSION: '0047-messages_tables',
|
DB_VERSION: '0048-add_is_moderator_to_contribution_messages',
|
||||||
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
|
||||||
|
|||||||
@ -13,6 +13,7 @@ export class ContributionMessage {
|
|||||||
this.userFirstName = user.firstName
|
this.userFirstName = user.firstName
|
||||||
this.userLastName = user.lastName
|
this.userLastName = user.lastName
|
||||||
this.userId = user.id
|
this.userId = user.id
|
||||||
|
this.isModerator = contributionMessage.isModerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Field(() => Number)
|
@Field(() => Number)
|
||||||
@ -38,6 +39,9 @@ export class ContributionMessage {
|
|||||||
|
|
||||||
@Field(() => Number, { nullable: true })
|
@Field(() => Number, { nullable: true })
|
||||||
userId: number | null
|
userId: number | null
|
||||||
|
|
||||||
|
@Field(() => Boolean)
|
||||||
|
isModerator: boolean
|
||||||
}
|
}
|
||||||
@ObjectType()
|
@ObjectType()
|
||||||
export class ContributionMessageListResult {
|
export class ContributionMessageListResult {
|
||||||
|
|||||||
@ -725,6 +725,7 @@ export class AdminResolver {
|
|||||||
contributionMessage.message = message
|
contributionMessage.message = message
|
||||||
contributionMessage.userId = user.id
|
contributionMessage.userId = user.id
|
||||||
contributionMessage.type = ContributionMessageType.DIALOG
|
contributionMessage.type = ContributionMessageType.DIALOG
|
||||||
|
contributionMessage.isModerator = true
|
||||||
await queryRunner.manager.insert(DbContributionMessage, contributionMessage)
|
await queryRunner.manager.insert(DbContributionMessage, contributionMessage)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export class ContributionMessageResolver {
|
|||||||
contributionMessage.message = message
|
contributionMessage.message = message
|
||||||
contributionMessage.userId = user.id
|
contributionMessage.userId = user.id
|
||||||
contributionMessage.type = ContributionMessageType.DIALOG
|
contributionMessage.type = ContributionMessageType.DIALOG
|
||||||
|
contributionMessage.isModerator = false
|
||||||
await queryRunner.manager.insert(DbContributionMessage, contributionMessage)
|
await queryRunner.manager.insert(DbContributionMessage, contributionMessage)
|
||||||
|
|
||||||
if (contribution.contributionStatus === ContributionStatus.IN_PROGRESS) {
|
if (contribution.contributionStatus === ContributionStatus.IN_PROGRESS) {
|
||||||
|
|||||||
@ -0,0 +1,54 @@
|
|||||||
|
import {
|
||||||
|
BaseEntity,
|
||||||
|
Column,
|
||||||
|
DeleteDateColumn,
|
||||||
|
Entity,
|
||||||
|
JoinColumn,
|
||||||
|
ManyToOne,
|
||||||
|
PrimaryGeneratedColumn,
|
||||||
|
} from 'typeorm'
|
||||||
|
import { Contribution } from '../Contribution'
|
||||||
|
import { User } from '../User'
|
||||||
|
|
||||||
|
@Entity('contribution_messages', {
|
||||||
|
engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci',
|
||||||
|
})
|
||||||
|
export class ContributionMessage extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn('increment', { unsigned: true })
|
||||||
|
id: number
|
||||||
|
|
||||||
|
@Column({ name: 'contribution_id', unsigned: true, nullable: false })
|
||||||
|
contributionId: number
|
||||||
|
|
||||||
|
@ManyToOne(() => Contribution, (contribution) => contribution.messages)
|
||||||
|
@JoinColumn({ name: 'contribution_id' })
|
||||||
|
contribution: Contribution
|
||||||
|
|
||||||
|
@Column({ name: 'user_id', unsigned: true, nullable: false })
|
||||||
|
userId: number
|
||||||
|
|
||||||
|
@ManyToOne(() => User, (user) => user.messages)
|
||||||
|
@JoinColumn({ name: 'user_id' })
|
||||||
|
user: User
|
||||||
|
|
||||||
|
@Column({ length: 2000, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||||
|
message: string
|
||||||
|
|
||||||
|
@Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' })
|
||||||
|
createdAt: Date
|
||||||
|
|
||||||
|
@Column({ type: 'datetime', default: null, nullable: true, name: 'updated_at' })
|
||||||
|
updatedAt: Date
|
||||||
|
|
||||||
|
@DeleteDateColumn({ name: 'deleted_at' })
|
||||||
|
deletedAt: Date | null
|
||||||
|
|
||||||
|
@Column({ name: 'deleted_by', default: null, unsigned: true, nullable: true })
|
||||||
|
deletedBy: number
|
||||||
|
|
||||||
|
@Column({ length: 12, nullable: false, collation: 'utf8mb4_unicode_ci' })
|
||||||
|
type: string
|
||||||
|
|
||||||
|
@Column({ name: 'is_moderator', type: 'bool', nullable: false, default: false })
|
||||||
|
isModerator: boolean
|
||||||
|
}
|
||||||
@ -1 +1 @@
|
|||||||
export { ContributionMessage } from './0047-messages_tables/ContributionMessage'
|
export { ContributionMessage } from './0048-add_is_moderator_to_contribution_messages/ContributionMessage'
|
||||||
|
|||||||
@ -0,0 +1,12 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
|
export async function upgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn(
|
||||||
|
`ALTER TABLE \`contribution_messages\` ADD COLUMN \`is_moderator\` boolean NOT NULL DEFAULT false;`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function downgrade(queryFn: (query: string, values?: any[]) => Promise<Array<any>>) {
|
||||||
|
await queryFn(`ALTER TABLE \`contribution_messages\` DROP COLUMN \`is_moderator\`;`)
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user