2929 fetch emails from backend and display them in the UI (#3092)
* sending mock data from the resolver * add sql raw query to the resolver * improve query * fix email component css * fix query * css adjustments * create hard limit for mail display * fix display name ellipsis * add service * fetching email on company page is working * graphql generate * move queries into separate files * add types * renaming * add early return * modified according to comments * graphql data generate * fix bug after renaming * fix issue with mock data
This commit is contained in:
@ -0,0 +1,77 @@
|
||||
import { Args, Query, Field, Resolver, ObjectType } from '@nestjs/graphql';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
|
||||
import { Column, Entity } from 'typeorm';
|
||||
|
||||
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';
|
||||
|
||||
@Entity({ name: 'timelineThread', schema: 'core' })
|
||||
@ObjectType('TimelineThread')
|
||||
class TimelineThread {
|
||||
@Field()
|
||||
@Column()
|
||||
read: boolean;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
senderName: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
senderPictureUrl: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
numberOfMessagesInThread: number;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
subject: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
body: string;
|
||||
|
||||
@Field()
|
||||
@Column()
|
||||
receivedAt: Date;
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Resolver(() => [TimelineThread])
|
||||
export class TimelineMessagingResolver {
|
||||
constructor(
|
||||
private readonly timelineMessagingService: TimelineMessagingService,
|
||||
) {}
|
||||
|
||||
@Query(() => [TimelineThread])
|
||||
async getTimelineThreadsFromPersonId(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('personId') personId: string,
|
||||
) {
|
||||
const timelineThreads =
|
||||
await this.timelineMessagingService.getMessagesFromPersonIds(
|
||||
workspaceId,
|
||||
[personId],
|
||||
);
|
||||
|
||||
return timelineThreads;
|
||||
}
|
||||
|
||||
@Query(() => [TimelineThread])
|
||||
async getTimelineThreadsFromCompanyId(
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
@Args('companyId') companyId: string,
|
||||
) {
|
||||
const timelineThreads =
|
||||
await this.timelineMessagingService.getMessagesFromCompanyId(
|
||||
workspaceId,
|
||||
companyId,
|
||||
);
|
||||
|
||||
return timelineThreads;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user