3263 modify timeline messagingservice to allow the frontend to get multiple participants in a thread (#3611)
* wip * wip * add pagination * wip * wip * wip * update resolver * wip * wip * endpoint is working but there is still work to do * merge main * wip * subject is now first subject * number of messages is working * improving query * fix bug * fix bug * added parameter * pagination introduced a bug * pagination is working * fix type * improve typing * improve typing * fix bug * add displayName * display displayName in the frontend * move entities * fix * generate metadata * add avatarUrl * modify after comments on PR * updates * remove email mocks * remove console log * move files * remove mock * use constant * use constant * use fragments * remove console.log * generate * changes made * update DTO * generate
This commit is contained in:
@ -1,43 +1,47 @@
|
||||
import { Args, Query, Field, Resolver, ObjectType } from '@nestjs/graphql';
|
||||
import {
|
||||
Args,
|
||||
Query,
|
||||
Resolver,
|
||||
Int,
|
||||
ArgsType,
|
||||
Field,
|
||||
ID,
|
||||
} from '@nestjs/graphql';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
|
||||
import { Column, Entity } from 'typeorm';
|
||||
import { Max } from 'class-validator';
|
||||
|
||||
import { JwtAuthGuard } from 'src/guards/jwt.auth.guard';
|
||||
import { Workspace } from 'src/core/workspace/workspace.entity';
|
||||
import { AuthWorkspace } from 'src/decorators/auth-workspace.decorator';
|
||||
import { TimelineMessagingService } from 'src/core/messaging/timeline-messaging.service';
|
||||
import { TimelineThread } from 'src/core/messaging/dtos/timeline-thread.dto';
|
||||
import { TIMELINE_THREADS_MAX_PAGE_SIZE } from 'src/core/messaging/constants/messaging.constants';
|
||||
|
||||
@Entity({ name: 'timelineThread', schema: 'core' })
|
||||
@ObjectType('TimelineThread')
|
||||
export class TimelineThread {
|
||||
@Field()
|
||||
@Column()
|
||||
read: boolean;
|
||||
@ArgsType()
|
||||
class GetTimelineThreadsFromPersonIdArgs {
|
||||
@Field(() => ID)
|
||||
personId: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
senderName: string;
|
||||
@Field(() => Int)
|
||||
page: number;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
senderPictureUrl: string;
|
||||
@Field(() => Int)
|
||||
@Max(TIMELINE_THREADS_MAX_PAGE_SIZE)
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
numberOfMessagesInThread: number;
|
||||
@ArgsType()
|
||||
class GetTimelineThreadsFromCompanyIdArgs {
|
||||
@Field(() => ID)
|
||||
companyId: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
subject: string;
|
||||
@Field(() => Int)
|
||||
page: number;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
body: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
receivedAt: Date;
|
||||
@Field(() => Int)
|
||||
@Max(TIMELINE_THREADS_MAX_PAGE_SIZE)
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ -50,12 +54,14 @@ export class TimelineMessagingResolver {
|
||||
@Query(() => [TimelineThread])
|
||||
async getTimelineThreadsFromPersonId(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('personId') personId: string,
|
||||
@Args() { personId, page, pageSize }: GetTimelineThreadsFromPersonIdArgs,
|
||||
) {
|
||||
const timelineThreads =
|
||||
await this.timelineMessagingService.getMessagesFromPersonIds(
|
||||
workspaceId,
|
||||
[personId],
|
||||
page,
|
||||
pageSize,
|
||||
);
|
||||
|
||||
return timelineThreads;
|
||||
@ -64,12 +70,14 @@ export class TimelineMessagingResolver {
|
||||
@Query(() => [TimelineThread])
|
||||
async getTimelineThreadsFromCompanyId(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('companyId') companyId: string,
|
||||
@Args() { companyId, page, pageSize }: GetTimelineThreadsFromCompanyIdArgs,
|
||||
) {
|
||||
const timelineThreads =
|
||||
await this.timelineMessagingService.getMessagesFromCompanyId(
|
||||
workspaceId,
|
||||
companyId,
|
||||
page,
|
||||
pageSize,
|
||||
);
|
||||
|
||||
return timelineThreads;
|
||||
|
||||
Reference in New Issue
Block a user