Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: hide user data from thread module
  • Loading branch information
gondar00 committed Sep 12, 2022
1 parent 6fc8b84 commit 37bf6de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/src/entities/thread.entity.ts
Expand Up @@ -29,7 +29,7 @@ export class Thread extends BaseEntity {
@Column({ default: false, name: 'is_resolved' })
isResolved: boolean;

@ManyToOne(() => User, (user) => user.id, { eager: true })
@ManyToOne(() => User, (user) => user.id)
@JoinColumn({ name: 'user_id' })
user: User;

Expand Down
15 changes: 11 additions & 4 deletions server/src/services/thread.service.ts
Expand Up @@ -4,6 +4,7 @@ import { Thread } from '../entities/thread.entity';
import { Comment } from '../entities/comment.entity';
import { CreateThreadDto, UpdateThreadDto } from '../dto/thread.dto';
import { ThreadRepository } from '../repositories/thread.repository';
import { createQueryBuilder } from 'typeorm';

@Injectable()
export class ThreadService {
Expand All @@ -17,13 +18,19 @@ export class ThreadService {
}

public async getThreads(appId: string, organizationId: string, appVersionsId: string): Promise<Thread[]> {
return await this.threadRepository.find({
where: {
return await createQueryBuilder(Thread, 'thread')
.innerJoin('thread.user', 'user')
.addSelect(['user.id', 'user.firstName', 'user.lastName'])
.andWhere('thread.appId = :appId', {
appId,
})
.andWhere('thread.organizationId = :organizationId', {
organizationId,
})
.andWhere('thread.appVersionsId = :appVersionsId', {
appVersionsId,
},
});
})
.getMany();
}

public async getOrganizationThreads(orgId: string): Promise<Thread[]> {
Expand Down

0 comments on commit 37bf6de

Please sign in to comment.